rfscholte closed pull request #6: [MCOMPILER-349] - changed dependency detection. URL: https://github.com/apache/maven-compiler-plugin/pull/6
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/src/it/MCOMPILER-349_dependencyChanged/dependent-module/pom.xml b/src/it/MCOMPILER-349_dependencyChanged/dependent-module/pom.xml new file mode 100644 index 0000000..c022050 --- /dev/null +++ b/src/it/MCOMPILER-349_dependencyChanged/dependent-module/pom.xml @@ -0,0 +1,44 @@ +<?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> + + <parent> + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>mcompiler349-test</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>dependent-module</artifactId> + + <dependencies> + <dependency> + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>service</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project> + + diff --git a/src/it/MCOMPILER-349_dependencyChanged/dependent-module/src/main/java/Main.java b/src/it/MCOMPILER-349_dependencyChanged/dependent-module/src/main/java/Main.java new file mode 100644 index 0000000..f77ad07 --- /dev/null +++ b/src/it/MCOMPILER-349_dependencyChanged/dependent-module/src/main/java/Main.java @@ -0,0 +1,27 @@ +/* + * 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 Main +{ + public static void main( String[] args ) + { + TestService testService = new TestService(); + testService.run(); + } +} \ No newline at end of file diff --git a/src/it/MCOMPILER-349_dependencyChanged/invoker.properties b/src/it/MCOMPILER-349_dependencyChanged/invoker.properties new file mode 100644 index 0000000..572447a --- /dev/null +++ b/src/it/MCOMPILER-349_dependencyChanged/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.goals = clean compile +invoker.goals.2 = groovy:execute +invoker.goals.3 = compile +invoker.buildResult.3 = failure diff --git a/src/it/MCOMPILER-349_dependencyChanged/pom.xml b/src/it/MCOMPILER-349_dependencyChanged/pom.xml new file mode 100644 index 0000000..d985a19 --- /dev/null +++ b/src/it/MCOMPILER-349_dependencyChanged/pom.xml @@ -0,0 +1,75 @@ +<?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>mcompiler349-test</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <description> + IT test to verify that dependent-module recompile, when run 'mvn compile' without 'clean' if module dependency + changed. + The compilation should fail as dependent-module use method that is no longer exists (run() method of TestService + renamed to + newMethodName()). + </description> + + <modules> + <module>dependent-module</module> + <module>service</module> + </modules> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>@project.version@</version> + </plugin> + <plugin> + <groupId>org.codehaus.gmaven</groupId> + <artifactId>groovy-maven-plugin</artifactId> + <version>2.0</version> + <configuration> + <source> + def fileToModify = new File(project.basedir, 'service/src/main/java/TestService.java') + processFileInplace(fileToModify) { text -> + text.replaceAll(/run/, 'newMethodName') + } + + def processFileInplace(file, Closure processText) { + file.write(processText(file.text)) + } + </source> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + +</project> + + diff --git a/src/it/MCOMPILER-349_dependencyChanged/service/pom.xml b/src/it/MCOMPILER-349_dependencyChanged/service/pom.xml new file mode 100644 index 0000000..57a08fa --- /dev/null +++ b/src/it/MCOMPILER-349_dependencyChanged/service/pom.xml @@ -0,0 +1,36 @@ +<?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> + + <parent> + <groupId>org.apache.maven.plugins.compiler.it</groupId> + <artifactId>mcompiler349-test</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>service</artifactId> + +</project> + + diff --git a/src/it/MCOMPILER-349_dependencyChanged/service/src/main/java/TestService.java b/src/it/MCOMPILER-349_dependencyChanged/service/src/main/java/TestService.java new file mode 100644 index 0000000..df21d26 --- /dev/null +++ b/src/it/MCOMPILER-349_dependencyChanged/service/src/main/java/TestService.java @@ -0,0 +1,27 @@ +/* + * 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 TestService +{ + + public void run() + { + + } +} \ No newline at end of file diff --git a/src/it/MCOMPILER-349_dependencyChanged/verify.groovy b/src/it/MCOMPILER-349_dependencyChanged/verify.groovy new file mode 100644 index 0000000..c218281 --- /dev/null +++ b/src/it/MCOMPILER-349_dependencyChanged/verify.groovy @@ -0,0 +1,26 @@ + +/* + * 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. + */ +def logFile = new File( basedir, 'build.log' ) +assert logFile.exists() +content = logFile.text + +assert content.contains( 'COMPILATION ERROR :' ) + + 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 e213f3b..9295499 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java @@ -1577,7 +1577,7 @@ protected boolean isDependencyChanged() if ( fileExtensions == null || fileExtensions.isEmpty() ) { fileExtensions = new ArrayList<String>(); - fileExtensions.add( ".class" ); + fileExtensions.add( "class" ); } Date buildStartTime = getBuildStartTime(); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
