Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 193: Build path problems after maven project update #194

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand All @@ -34,6 +34,8 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -83,7 +85,7 @@

/**
* Generate descriptors from UIMA Ruta script files.
*
*
*/
@Mojo(name = "generate", defaultPhase = GENERATE_RESOURCES, requiresDependencyResolution = TEST, requiresDependencyCollection = TEST, threadSafe = true)
public class RutaGenerateDescriptorMojo extends AbstractMojo {
Expand Down Expand Up @@ -230,8 +232,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
buildContext.refresh(analysisEngineOutputDirectory);
}

this.project.addCompileSourceRoot(this.typeSystemOutputDirectory.getPath());
this.project.addCompileSourceRoot(this.analysisEngineOutputDirectory.getPath());
project.addCompileSourceRoot(typeSystemOutputDirectory.getPath());
project.addCompileSourceRoot(analysisEngineOutputDirectory.getPath());

String[] files = null;
if (scriptFiles != null) {
Expand All @@ -255,7 +257,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
return;
}

List<File> filesToBuild = new ArrayList<File>();
List<File> filesToBuild = new ArrayList<>();
for (String each : files) {
File file = new File(each);

Expand Down Expand Up @@ -314,7 +316,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
maxBuildRetries = filesToBuild.size() * 3;
}

Queue<RutaDescriptorInformation> toBuild = new LinkedList<RutaDescriptorInformation>();
Queue<RutaDescriptorInformation> toBuild = new LinkedList<>();

for (File file : filesToBuild) {
try {
Expand Down Expand Up @@ -393,7 +395,7 @@ private List<File> getPossibleDescriptors(File file) {
}

private List<String> getExtensionsFromClasspath(ClassLoader classloader) {
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(
true);
ResourceLoader resourceLoader = new DefaultResourceLoader(classloader);
Expand Down Expand Up @@ -451,7 +453,7 @@ private void write(XMLizable desc, String aFilename) throws SAXException, IOExce
public static URLClassLoader getClassloader(MavenProject project, Log aLog,
String includeScopeThreshold) throws MojoExecutionException {

List<URL> urls = new ArrayList<URL>();
List<URL> urls = new ArrayList<>();

for (String element : project.getCompileSourceRoots()) {
try {
Expand Down Expand Up @@ -495,7 +497,7 @@ public static URLClassLoader getClassloader(MavenProject project, Log aLog,
}

ScopeArtifactFilter filter = new ScopeArtifactFilter(includeScopeThreshold);
for (Artifact dep : (Set<Artifact>) project.getArtifacts()) {
for (Artifact dep : project.getArtifacts()) {
try {
if (!filter.include(dep)) {
aLog.debug("Not generating classpath entry for out-of-scope artifact: " + dep.getGroupId()
Expand Down Expand Up @@ -571,6 +573,7 @@ private void addRutaNature() throws MojoExecutionException {

private void addRutaBuildPath() throws MojoExecutionException {
File projectDir = project.getFile().getParentFile();
Path projectPath = Paths.get(projectDir.toURI());

if (buildPaths == null || buildPaths.length == 0) {
return;
Expand All @@ -579,14 +582,21 @@ private void addRutaBuildPath() throws MojoExecutionException {
File buildpathFile = new File(projectDir, ".buildpath");
Xpp3Dom buildpathNode = new Xpp3Dom("buildpath");
for (String eachBP : buildPaths) {
String[] split = eachBP.split(":");

String[] split = StringUtils.split(eachBP, ":", 2);
String type = "script";
String path = eachBP;

if (split.length == 2) {
type = split[0];
path = split[1];
}
addBuildPathEntry(buildpathNode, type, path);
Path bpPath = Paths.get(path);
String bp = path;
if (bpPath.isAbsolute()) {
bp = projectPath.relativize(bpPath).toString();
}
addBuildPathEntry(buildpathNode, type, bp);
}
Xpp3Dom buildpathentry = new Xpp3Dom("buildpathentry");
buildpathentry.setAttribute("kind", "con");
Expand Down
Loading