This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MCOMPILER-323 in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
commit 0f4b1527e458995ca98bd5cfe71b1d4bef1092be Author: rfscholte <rfscho...@apache.org> AuthorDate: Fri May 18 11:13:31 2018 +0200 [MCOMPILER-323] Support multi-release jars Add multiReleaseOutput flag --- .../invoker.properties | 18 ++++++++ src/it/MCOMPILER-328_multiReleaseOutput/pom.xml | 48 ++++++++++++++++++++++ .../src/main/java/MyClass.java | 23 +++++++++++ .../MCOMPILER-328_multiReleaseOutput/verify.groovy | 22 ++++++++++ .../apache/maven/plugin/compiler/CompilerMojo.java | 26 ++++++++++-- 5 files changed, 134 insertions(+), 3 deletions(-) diff --git a/src/it/MCOMPILER-328_multiReleaseOutput/invoker.properties b/src/it/MCOMPILER-328_multiReleaseOutput/invoker.properties new file mode 100644 index 0000000..9511718 --- /dev/null +++ b/src/it/MCOMPILER-328_multiReleaseOutput/invoker.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# 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 +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +invoker.java.version = 9+ diff --git a/src/it/MCOMPILER-328_multiReleaseOutput/pom.xml b/src/it/MCOMPILER-328_multiReleaseOutput/pom.xml new file mode 100644 index 0000000..8a4de8c --- /dev/null +++ b/src/it/MCOMPILER-328_multiReleaseOutput/pom.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ 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 + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>mcompiler328</artifactId> + <version>1.0.0-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <release>9</release> + <multiReleaseOutput>true</multiReleaseOutput> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/it/MCOMPILER-328_multiReleaseOutput/src/main/java/MyClass.java b/src/it/MCOMPILER-328_multiReleaseOutput/src/main/java/MyClass.java new file mode 100644 index 0000000..4945381 --- /dev/null +++ b/src/it/MCOMPILER-328_multiReleaseOutput/src/main/java/MyClass.java @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * 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 + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class MyClass +{ + +} diff --git a/src/it/MCOMPILER-328_multiReleaseOutput/verify.groovy b/src/it/MCOMPILER-328_multiReleaseOutput/verify.groovy new file mode 100644 index 0000000..ea03de5 --- /dev/null +++ b/src/it/MCOMPILER-328_multiReleaseOutput/verify.groovy @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * 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 + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +assert !new File( basedir, 'target/classes/MyClass.class').exists() + +assert new File( basedir, 'target/classes/META-INF/versions/9/MyClass.class').exists() \ No newline at end of file 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 d1956ae..37eae70 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java @@ -114,9 +114,15 @@ public class CompilerMojo @Parameter( defaultValue = "${project.compileClasspathElements}", readonly = true, required = true ) private List<String> compilePath; - + + /** + * When set to {@code true}, the classes will be placed in <code>META-INF/versions/${release}</code> + * The release value must be set, otherwise the plugin will fail. + * + * @since 3.7.1 + */ @Parameter - private boolean allowPartialRequirements; + private boolean multiReleaseOutput; @Component private LocationManager locationManager; @@ -153,7 +159,16 @@ public class CompilerMojo protected File getOutputDirectory() { - return outputDirectory; + File dir; + if ( !multiReleaseOutput ) + { + dir = outputDirectory; + } + else + { + dir = new File( outputDirectory, "META-INF/versions/" + release ); + } + return dir; } public void execute() @@ -164,6 +179,11 @@ public class CompilerMojo getLog().info( "Not compiling main sources" ); return; } + + if ( multiReleaseOutput && release == null ) + { + throw new MojoExecutionException( "When using 'multiReleaseOutput' the release must be set" ); + } super.execute(); -- To stop receiving notification emails like this one, please contact rfscho...@apache.org.