You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2018/07/08 15:26:30 UTC
[maven-compiler-plugin] branch MCOMPILER-320 updated:
[MCOMPILER-320] Allow additional class path items to be given during
compilation Use multiReleaseOutput,
which seems sufficient. No need for additionalClasspathElements
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MCOMPILER-320
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
The following commit(s) were added to refs/heads/MCOMPILER-320 by this push:
new 0b52a5d [MCOMPILER-320] Allow additional class path items to be given during compilation Use multiReleaseOutput, which seems sufficient. No need for additionalClasspathElements
0b52a5d is described below
commit 0b52a5d2e2eef9bf0bf84488283b9285e33aec27
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Jul 8 17:26:21 2018 +0200
[MCOMPILER-320] Allow additional class path items to be given during compilation
Use multiReleaseOutput, which seems sufficient. No need for additionalClasspathElements
---
src/it/MCOMPILER-320_mrjar/lib/pom.xml | 8 ++-----
.../apache/maven/plugin/compiler/CompilerMojo.java | 26 ++++++++++++++++++++--
2 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/it/MCOMPILER-320_mrjar/lib/pom.xml b/src/it/MCOMPILER-320_mrjar/lib/pom.xml
index 8b1b0a4..3a86962 100644
--- a/src/it/MCOMPILER-320_mrjar/lib/pom.xml
+++ b/src/it/MCOMPILER-320_mrjar/lib/pom.xml
@@ -65,10 +65,8 @@
</goals>
<configuration>
<release>9</release>
- <buildDirectory>${project.build.directory}</buildDirectory>
+ <multiReleaseOutput>true</multiReleaseOutput>
<compileSourceRoots>${project.basedir}/src/main/java9</compileSourceRoots>
- <!-- we can output directly into the appropriate target directory; this works out nicely -->
- <outputDirectory>${project.build.directory}/classes/META-INF/versions/9</outputDirectory>
</configuration>
</execution>
</executions>
@@ -94,10 +92,8 @@
</goals>
<configuration>
<release>10</release>
- <buildDirectory>${project.build.directory}</buildDirectory>
+ <multiReleaseOutput>true</multiReleaseOutput>
<compileSourceRoots>${project.basedir}/src/main/java10</compileSourceRoots>
- <!-- we can output directly into the appropriate target directory; this works out nicely -->
- <outputDirectory>${project.build.directory}/classes/META-INF/versions/10</outputDirectory>
</configuration>
</execution>
</executions>
diff --git a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
index 04811c5..9ac8cf3 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -313,7 +313,29 @@ public class CompilerMojo
}
else
{
- classpathElements = compilePath;
+ if ( multiReleaseOutput )
+ {
+ classpathElements = new ArrayList<>( compilePath.size() + 3 );
+
+ File versionsFolder = new File( outputDirectory, "META-INF/versions" );
+
+ // in reverse order
+ for ( int version = Integer.parseInt( getRelease() ) - 1; version >= 9 ; version-- )
+ {
+ File versionSubFolder = new File( versionsFolder, String.valueOf( version ) );
+ if ( versionSubFolder.exists() )
+ {
+ classpathElements.add( versionSubFolder.getAbsolutePath() );
+ }
+ }
+
+ classpathElements.addAll( compilePath );
+ }
+ else
+ {
+ classpathElements = compilePath;
+ }
+
modulepathElements = Collections.emptyList();
}
}
@@ -321,7 +343,7 @@ public class CompilerMojo
private List<File> getCompileClasspathElements( MavenProject project )
{
// 3 is outputFolder + 2 preserved for multirelease
- List<File> list = new ArrayList<File>( project.getArtifacts().size() + 3 );
+ List<File> list = new ArrayList<>( project.getArtifacts().size() + 3 );
if ( multiReleaseOutput )
{