Skip to content

Commit

Permalink
Correctly extracting class path from maven output
Browse files Browse the repository at this point in the history
  • Loading branch information
rodinaarssen committed Aug 27, 2024
1 parent d5c655b commit 2aab716
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/org/rascalmpl/library/util/PathConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,6 @@ private static ISourceLocation setTargetScheme(ISourceLocation projectLoc) {
}
}


private static final Pattern FIND_CLASS_PATH = Pattern.compile("org.apache.maven.plugins.dependency.fromDependencies.BuildClasspathMojo - Dependencies classpath:\\s+(.+)$", Pattern.MULTILINE);


/**
* See if there is a pom.xml and extract the compile-time classpath from a mvn run
* if there is such a file.
Expand All @@ -661,11 +657,9 @@ private static IList getPomXmlCompilerClasspath(ISourceLocation manifestRoot) {
var maven = new MavenCli();
var tempFile = Files.createTempFile("rascal-classpath-", ".tmp");

maven.doMain(buildRequest(new String[] {"-o", "dependency:build-classpath", "-DincludeScope=compile", "-Dmdep.outputFile=" + tempFile.toString()}, manifestRoot));
maven.doMain(buildRequest(new String[] {"-quiet", "-o", "dependency:build-classpath", "-DincludeScope=compile", "-Dmdep.outputFile=" + tempFile.toString()}, manifestRoot));

var mavenOutput = Files.readAllLines(tempFile);
var match = FIND_CLASS_PATH.matcher(mavenOutput.get(0));
var foundClassPath = match.find() ? match.group(1) : "";
var foundClassPath = Files.readAllLines(tempFile).get(0);

Check warning on line 662 in src/org/rascalmpl/library/util/PathConfig.java

View check run for this annotation

Codecov / codecov/patch

src/org/rascalmpl/library/util/PathConfig.java#L662

Added line #L662 was not covered by tests

return Arrays.stream(foundClassPath.split(File.pathSeparator))
.filter(fileName -> new File(fileName).exists())
Expand Down

0 comments on commit 2aab716

Please sign in to comment.