[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17855568#comment-17855568 ] ASF GitHub Bot commented on MCOMPILER-333: -- ktoda-code commented on PR #214: URL: https://github.com/apache/maven-compiler-plugin/pull/214#issuecomment-2172889162 Why this was a bug? > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Assignee: Olivier Lamy >Priority: Major > Fix For: 3.12.0 > > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17794013#comment-17794013 ] ASF GitHub Bot commented on MCOMPILER-333: -- olamy merged PR #214: URL: https://github.com/apache/maven-compiler-plugin/pull/214 > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Priority: Major > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17793967#comment-17793967 ] ASF GitHub Bot commented on MCOMPILER-333: -- olamy commented on PR #186: URL: https://github.com/apache/maven-compiler-plugin/pull/186#issuecomment-1843942300 done via https://github.com/apache/maven-compiler-plugin/pull/214 > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Priority: Major > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17793966#comment-17793966 ] ASF GitHub Bot commented on MCOMPILER-333: -- olamy closed pull request #186: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory URL: https://github.com/apache/maven-compiler-plugin/pull/186 > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Priority: Major > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17793965#comment-17793965 ] ASF GitHub Bot commented on MCOMPILER-333: -- jorsol opened a new pull request, #214: URL: https://github.com/apache/maven-compiler-plugin/pull/214 Following this checklist to help us incorporate your contribution quickly and easily: - [X] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MCOMPILER) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [X] Each commit in the pull request should have a meaningful subject line and body. - [X] Format the pull request title like `[MCOMPILER-XXX] - Fixes bug in ApproximateQuantiles`, where you replace `MCOMPILER-XXX` with the appropriate JIRA issue. Best practice is to use the JIRA issue title in the pull request title and in the first line of the commit message. - [X] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [X] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [X] You have run the integration tests successfully (`mvn -Prun-its clean verify`). If your pull request is about ~20 lines of code you don't need to sign an [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure please ask on the developers list. To make clear that you license your contribution under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) you have to acknowledge this by using the following check-box. - [X] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) - [X] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). Closes #186 > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Priority: Major > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17729703#comment-17729703 ] ASF GitHub Bot commented on MCOMPILER-333: -- elharo commented on code in PR #23: URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1219477223 ## src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java: ## @@ -61,17 +69,28 @@ private MavenProject mavenProject; /** - * Used for detecting changes between the Mojo execution. + * Used for detecting changes in the output directory between the Mojo execution. Review Comment: something's off with "between the Mojo execution". possibly should be "between Mojo executions" or perhaps something else is meant? ## src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java: ## @@ -323,25 +335,23 @@ public String[] beforeRebuildExecution( IncrementalBuildHelperRequest incrementa public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuildHelperRequest ) throws MojoExecutionException { -DirectoryScanner diffScanner = getDirectoryScanner(); -// now scan the same directory again and create a diff -diffScanner.scan(); -DirectoryScanResult scanResult = diffScanner.diffIncludedFiles( filesBeforeAction ); - File mojoConfigBase = getMojoStatusDirectory(); -File mojoConfigFile = new File( mojoConfigBase, CREATED_FILES_LST_FILENAME ); -try -{ -FileUtils.fileWriteArray( mojoConfigFile, scanResult.getFilesAdded() ); -} -catch ( IOException e ) -{ -throw new MojoExecutionException( "Error while storing the mojo status", e ); -} +writeChangedFiles( +getDirectoryScanner(), Review Comment: no need to call a getter method in the same class, just use the directoryScanner field directly ## src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java: ## @@ -358,6 +368,79 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil } +private void writeChangedFiles( +DirectoryScanner directoryScanner, +String[] filesBeforeAction, +File mojoConfigBase, +String createdFilesListFileName ) throws MojoExecutionException +{ +if ( directoryScanner.getBasedir() == null ) +{ +return; +} + +DirectoryScanResult outputDirectoryScanResult = scanDirectoryDiff( +directoryScanner, filesBeforeAction ); + +try +{ +writeChangedFiles( outputDirectoryScanResult, mojoConfigBase, createdFilesListFileName ); +} +catch ( IOException e ) +{ +throw new MojoExecutionException( "Error while storing the mojo status", e ); +} +} + +private static void writeChangedFiles( +DirectoryScanResult outputDirectoryScanResult, +File mojoConfigBase, +String createdFilesListFileName ) +throws IOException +{ +File createdFiles = new File( mojoConfigBase, createdFilesListFileName ); +String[] filesAdded = outputDirectoryScanResult.getFilesAdded(); +String filesAddedAsString = Stream.of( filesAdded ).collect( Collectors.joining( "\n" ) ); + +Files.write( +createdFiles.toPath(), +filesAddedAsString.getBytes( StandardCharsets.UTF_8 ), +StandardOpenOption.CREATE ); +} + +private static DirectoryScanResult scanDirectoryDiff( +DirectoryScanner directoryScanner, +String[] filesBeforeAction ) +{ +// now scan the same directory again and create a diff +directoryScanner.scan(); +DirectoryScanResult outputScanResult = +directoryScanner.diffIncludedFiles( filesBeforeAction ); +return outputScanResult; +} + +private static List deleteFiles( File fileNameIndex, File parent ) throws IOException +{ +List oldFiles = Files.readAllLines( fileNameIndex.toPath() ); +for ( String oldFileName : oldFiles ) +{ +File oldFile = new File( parent, oldFileName ); +oldFile.delete(); Review Comment: what if this method returns false? i.e. delete failed. Do we care? ## src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelperRequest.java: ## @@ -73,4 +75,20 @@ public IncrementalBuildHelperRequest outputDirectory( File outputDirectory ) this.outputDirectory = outputDirectory; return this; } + +public File getGeneratedSourcesDirectory() +{ +return generatedSourcesDirectory; +} + +public void setGeneratedSourcesDirectory( File
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17729609#comment-17729609 ] ASF GitHub Bot commented on MCOMPILER-333: -- slachiewicz commented on PR #23: URL: https://github.com/apache/maven-shared-incremental/pull/23#issuecomment-1577994032 @elharo please review again > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Priority: Major > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714763#comment-17714763 ] Marquis Wang commented on MCOMPILER-333: I have an example project that shows this: https://github.com/marquiswang/incremental-compile-dagger-test > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Priority: Major > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16551759#comment-16551759 ] Anthony Vanelverdinghe commented on MCOMPILER-333: -- No, I don't have any at hand. I'd assume any project that creates the "generated-sources" directory would do. > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Priority: Major > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (MCOMPILER-333) Incremental compilation causes "mvn clean compile compile" to fail
[ https://issues.apache.org/jira/browse/MCOMPILER-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16551752#comment-16551752 ] Karl Heinz Marbaise commented on MCOMPILER-333: --- Do you have an example project for this? > Incremental compilation causes "mvn clean compile compile" to fail > -- > > Key: MCOMPILER-333 > URL: https://issues.apache.org/jira/browse/MCOMPILER-333 > Project: Maven Compiler Plugin > Issue Type: Bug >Affects Versions: 3.7.0 >Reporter: Anthony Vanelverdinghe >Priority: Major > > With true, my build > fails if I do "mvn clean compile compile". From the > [comment|https://issues.apache.org/jira/browse/MCOMPILER-205?focusedCommentId=16390065=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16390065] > in MCOMPILER-205, I understand that incremental compilation deletes the > "classes" directory. But it seems that it doesn't delete the > "generated-sources" directory. > When I do "mvn clean compile" and "mvn compile", the second build fails. > However, if I delete the "generated-sources" directory between the 2 builds, > they both succeed. > So I guess the bug here is that incremental compilation doesn't delete the > "generated-sources" directory. -- This message was sent by Atlassian JIRA (v7.6.3#76005)