This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MCOMPILER-336 in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
commit 42c48492e221b9adacd16cd5e69fde85ce34dfc8 Author: rfscholte <rfscho...@apache.org> AuthorDate: Fri Apr 13 23:52:27 2018 +0200 [MCOMPILER-336] Dependency that should be on modulepath sometime put on classpath --- .../MCOMPILER-336_incremental-modulepath/a/pom.xml | 35 +++++++++++++++ .../a/src/main/java/module-info.java | 21 +++++++++ .../MCOMPILER-336_incremental-modulepath/b/pom.xml | 43 +++++++++++++++++++ .../b/src/main/java/module-info.java | 22 ++++++++++ .../b/src/main/java/test/Foo.java | 23 ++++++++++ .../b/src/main/java/test/package-info.java | 20 +++++++++ .../invoker.properties | 21 +++++++++ .../MCOMPILER-336_incremental-modulepath/pom.xml | 50 ++++++++++++++++++++++ .../plugin/compiler/AbstractCompilerMojo.java | 34 ++++++++++----- 9 files changed, 259 insertions(+), 10 deletions(-) diff --git a/src/it/MCOMPILER-336_incremental-modulepath/a/pom.xml b/src/it/MCOMPILER-336_incremental-modulepath/a/pom.xml new file mode 100644 index 0000000..f558ee6 --- /dev/null +++ b/src/it/MCOMPILER-336_incremental-modulepath/a/pom.xml @@ -0,0 +1,35 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>mcompiler336</artifactId> + <version>1</version> + </parent> + <artifactId>a</artifactId> + <version>1.0-SNAPSHOT</version> + +</project> diff --git a/src/it/MCOMPILER-336_incremental-modulepath/a/src/main/java/module-info.java b/src/it/MCOMPILER-336_incremental-modulepath/a/src/main/java/module-info.java new file mode 100644 index 0000000..234b5f9 --- /dev/null +++ b/src/it/MCOMPILER-336_incremental-modulepath/a/src/main/java/module-info.java @@ -0,0 +1,21 @@ +/* + * 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. + */ +module test.a +{ +} diff --git a/src/it/MCOMPILER-336_incremental-modulepath/b/pom.xml b/src/it/MCOMPILER-336_incremental-modulepath/b/pom.xml new file mode 100644 index 0000000..03d5ad0 --- /dev/null +++ b/src/it/MCOMPILER-336_incremental-modulepath/b/pom.xml @@ -0,0 +1,43 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>mcompiler336</artifactId> + <version>1</version> + </parent> + <artifactId>b</artifactId> + <version>1.0-SNAPSHOT</version> + + <dependencies> + <dependency> + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>a</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project> diff --git a/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/module-info.java b/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/module-info.java new file mode 100644 index 0000000..c9f16f1 --- /dev/null +++ b/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/module-info.java @@ -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. + */ +module test.b +{ + requires transitive test.a; +} diff --git a/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/test/Foo.java b/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/test/Foo.java new file mode 100644 index 0000000..c22b20a --- /dev/null +++ b/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/test/Foo.java @@ -0,0 +1,23 @@ +package org.opengis.annotation; + +/* + * 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 Foo { +} diff --git a/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/test/package-info.java b/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/test/package-info.java new file mode 100644 index 0000000..41a65d1 --- /dev/null +++ b/src/it/MCOMPILER-336_incremental-modulepath/b/src/main/java/test/package-info.java @@ -0,0 +1,20 @@ +package org.opengis.annotation; + +/* + * 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. + */ \ No newline at end of file diff --git a/src/it/MCOMPILER-336_incremental-modulepath/invoker.properties b/src/it/MCOMPILER-336_incremental-modulepath/invoker.properties new file mode 100644 index 0000000..98fca41 --- /dev/null +++ b/src/it/MCOMPILER-336_incremental-modulepath/invoker.properties @@ -0,0 +1,21 @@ +# 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+ + +invoker.goals.1 = verify +invoker.goals.2 = verify diff --git a/src/it/MCOMPILER-336_incremental-modulepath/pom.xml b/src/it/MCOMPILER-336_incremental-modulepath/pom.xml new file mode 100644 index 0000000..b6dad04 --- /dev/null +++ b/src/it/MCOMPILER-336_incremental-modulepath/pom.xml @@ -0,0 +1,50 @@ +<?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/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>mcompiler336</artifactId> + <version>1</version> + <packaging>pom</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>@project.version@</version> + <configuration> + <release>9</release> + <useIncrementalCompilation>false</useIncrementalCompilation> <!-- https://issues.apache.org/jira/browse/MCOMPILER-209 --> + </configuration> + </plugin> + </plugins> + </build> + + <modules> + <module>a</module> + <module>b</module> + </modules> +</project> diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java index 294ae23..1d09853 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java @@ -746,7 +746,7 @@ public abstract class AbstractCompilerMojo IncrementalBuildHelper incrementalBuildHelper = new IncrementalBuildHelper( mojoExecution, session ); - Set<File> sources; + final Set<File> sources; IncrementalBuildHelperRequest incrementalBuildHelperRequest = null; @@ -789,6 +789,7 @@ public abstract class AbstractCompilerMojo else { getLog().debug( "useIncrementalCompilation disabled" ); + Set<File> staleSources; try { @@ -804,17 +805,10 @@ public abstract class AbstractCompilerMojo // TODO: This second scan for source files is sub-optimal String inputFileEnding = compiler.getInputFileEnding( compilerConfiguration ); - sources = computeStaleSources( compilerConfiguration, compiler, + staleSources = computeStaleSources( compilerConfiguration, compiler, getSourceInclusionScanner( inputFileEnding ) ); - - compilerConfiguration.setSourceFiles( sources ); - } - else - { - compilerConfiguration.setSourceFiles( staleSources ); } - preparePaths( compilerConfiguration.getSourceFiles() ); } catch ( CompilerException e ) { @@ -827,8 +821,28 @@ public abstract class AbstractCompilerMojo return; } + + compilerConfiguration.setSourceFiles( staleSources ); + + try + { + // MCOMPILER-366: if sources contain the module-descriptor it must be used to define the modulepath + sources = getCompileSources( compiler, compilerConfiguration ); + + getLog().debug( "#sources: " + sources.size() ); + for ( File file : sources ) + { + getLog().debug( file.getPath() ); + } + + preparePaths( sources ); + } + catch ( CompilerException e ) + { + throw new MojoExecutionException( "Error while computing stale sources.", e ); + } } - + // Dividing pathElements of classPath and modulePath is based on sourceFiles compilerConfiguration.setClasspathEntries( getClasspathElements() ); -- To stop receiving notification emails like this one, please contact rfscho...@apache.org.