You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "marquiswang (via GitHub)" <gi...@apache.org> on 2023/04/20 22:22:37 UTC
[GitHub] [maven-shared-incremental] marquiswang opened a new pull request, #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
marquiswang opened a new pull request, #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23
The generatedSourcesDirectory (by default
target/generated-sources/annotations) contains source code generated by annotation processors. These generated sources are also outputs of the compiler, and thus should be cleaned along with the class files in the outputDirectory, in order to correctly do incremental compilations.
If this isn't done, then javac may not correctly compile the generated code, since it was there before. See
https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing
See https://github.com/marquiswang/incremental-compile-dagger-test for a reproducing example.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
Re: [PR] [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory [maven-shared-incremental]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#issuecomment-5749416320
This code has moved into the maven-compiler-plugin
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven-shared-incremental] elharo commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "elharo (via GitHub)" <gi...@apache.org>.
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<String> deleteFiles( File fileNameIndex, File parent ) throws IOException
+ {
+ List<String> 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 generatedSourcesDirectory )
Review Comment:
needs Javadoc
##########
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.
* @see #getDirectoryScanner();
*/
- private DirectoryScanner directoryScanner;
+ private DirectoryScanner directoryScanner = new DirectoryScanner();
+
+ /**
+ * Used for detecting changes in the generated sources directory between the Mojo execution.
Review Comment:
ditto
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -358,6 +368,79 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil
}
+ private void writeChangedFiles(
+ DirectoryScanner directoryScanner,
Review Comment:
This is a field in the same class so no need to pass it as an argument
##########
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
Review Comment:
This is a constant in the same class so no need to pass it as an argument
##########
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,
Review Comment:
make non-static and use the directoryScanner field
##########
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" ) );
Review Comment:
Just use String.join or StringJoiner here
##########
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<String> deleteFiles( File fileNameIndex, File parent ) throws IOException
+ {
+ List<String> oldFiles = Files.readAllLines( fileNameIndex.toPath() );
+ for ( String oldFileName : oldFiles )
+ {
+ File oldFile = new File( parent, oldFileName );
+ oldFile.delete();
+ }
+ return oldFiles;
+ }
+
+ private String[] scanDirectory( DirectoryScanner directoryScanner, File directory )
Review Comment:
make non-static and use the directoryScanner field
##########
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 )
Review Comment:
This is a constant in the same class so no need to pass it as an argument
##########
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 generatedSourcesDirectory )
+ {
+ this.generatedSourcesDirectory = generatedSourcesDirectory;
Review Comment:
Is it worth checking here that the file exists and is a directory? Throw an IllegalArgumentException if not.
##########
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 generatedSourcesDirectory )
+ {
+ this.generatedSourcesDirectory = generatedSourcesDirectory;
+ }
+
+ public IncrementalBuildHelperRequest generatedSourcesDirectory( File generatedSourcesDirectory )
+ {
+ this.generatedSourcesDirectory = generatedSourcesDirectory;
Review Comment:
Is it worth checking here that the file exists and is a directory?
##########
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()
Review Comment:
needs Javadoc that clearly explains what this directory is.
##########
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.
* @see #getDirectoryScanner();
*/
- private DirectoryScanner directoryScanner;
+ private DirectoryScanner directoryScanner = new DirectoryScanner();
Review Comment:
This class is deprecated. Consider using use java.nio.file.DirectoryStream or java.nio.Files.walkFileTree() and related classes instead. Those should definitely be safer in a multi-threaded environment.
##########
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<String> deleteFiles( File fileNameIndex, File parent ) throws IOException
+ {
+ List<String> oldFiles = Files.readAllLines( fileNameIndex.toPath() );
+ for ( String oldFileName : oldFiles )
+ {
+ File oldFile = new File( parent, oldFileName );
+ oldFile.delete();
+ }
+ return oldFiles;
+ }
+
+ private String[] scanDirectory( DirectoryScanner directoryScanner, File directory )
+ {
+ directoryScanner.setBasedir( directory );
Review Comment:
This is a little worrisome. I didn't realize directoryScanner was mutable. This might suggest not using a directoryScanner field at all and just creating one when we need it.
##########
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 generatedSourcesDirectory )
+ {
+ this.generatedSourcesDirectory = generatedSourcesDirectory;
+ }
+
+ public IncrementalBuildHelperRequest generatedSourcesDirectory( File generatedSourcesDirectory )
Review Comment:
needs Javadoc that clearly explains what this directory is.
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -66,12 +71,24 @@
*/
private DirectoryScanner directoryScanner;
+ /**
+ * Used for detecting changes between the Mojo execution.
+ * @see #getGeneratedSourcesDirectoryScanner() ;
+ */
+ private DirectoryScanner generatedSourcesDirectoryScanner;
+
/**
* Once the {@link #beforeRebuildExecution(org.apache.maven.shared.incremental.IncrementalBuildHelperRequest)} got
* called, this will contain the list of files in the build directory.
*/
private String[] filesBeforeAction = new String[0];
+ /**
+ * Once the {@link #beforeRebuildExecution(org.apache.maven.shared.incremental.IncrementalBuildHelperRequest)} got
Review Comment:
ping
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory [maven-shared-incremental]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo closed pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
URL: https://github.com/apache/maven-shared-incremental/pull/23
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven-shared-incremental] marquiswang commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "marquiswang (via GitHub)" <gi...@apache.org>.
marquiswang commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173883510
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -129,6 +146,30 @@ public void setDirectoryScanner( DirectoryScanner directoryScanner )
this.directoryScanner = directoryScanner;
}
+ /**
+ * Get the existing DirectoryScanner used by this helper,
+ * or create new a DirectoryScanner if none is yet set.
+ * The DirectoryScanner is used for detecting changes in a directory
+ */
+ public DirectoryScanner getGeneratedSourcesDirectoryScanner()
+ {
+ if ( generatedSourcesDirectoryScanner == null )
+ {
+ generatedSourcesDirectoryScanner = new DirectoryScanner();
+ }
+
+ return generatedSourcesDirectoryScanner;
+ }
+
+ /**
+ * Set the DirectoryScanner which shall get used by this build helper.
Review Comment:
Oops yeah just copy/pasted the javadocs. I will update them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] marquiswang commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "marquiswang (via GitHub)" <gi...@apache.org>.
marquiswang commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173837700
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -129,6 +146,30 @@ public void setDirectoryScanner( DirectoryScanner directoryScanner )
this.directoryScanner = directoryScanner;
}
+ /**
+ * Get the existing DirectoryScanner used by this helper,
+ * or create new a DirectoryScanner if none is yet set.
+ * The DirectoryScanner is used for detecting changes in a directory
+ */
+ public DirectoryScanner getGeneratedSourcesDirectoryScanner()
+ {
+ if ( generatedSourcesDirectoryScanner == null )
+ {
+ generatedSourcesDirectoryScanner = new DirectoryScanner();
+ }
+
+ return generatedSourcesDirectoryScanner;
+ }
+
+ /**
+ * Set the DirectoryScanner which shall get used by this build helper.
+ * @param generatedSourcesDirectoryScanner
+ */
+ public void setGeneratedSourcesDirectoryScanner( DirectoryScanner generatedSourcesDirectoryScanner )
Review Comment:
But I agree entirely with you that this class seems pointless. But I have no idea who uses it so it doesn't seem safe to change? Or would you prefer that I delete/inline this class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] marquiswang commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "marquiswang (via GitHub)" <gi...@apache.org>.
marquiswang commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173883936
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -358,6 +395,73 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil
}
+ private void writeChangedFiles(
+ DirectoryScanner directoryScanner,
+ String[] filesBeforeAction,
+ File mojoConfigBase,
+ String createdFilesLstFilename ) throws MojoExecutionException
+ {
+ if ( directoryScanner.getBasedir() == null )
+ {
+ return;
+ }
+
+ DirectoryScanResult outputDirectoryScanResult = scanDirectoryDiff(
+ directoryScanner, filesBeforeAction );
+
+ try
+ {
+ writeChangedFiles( outputDirectoryScanResult, mojoConfigBase, createdFilesLstFilename );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error while storing the mojo status", e );
+ }
+ }
+
+ private static void writeChangedFiles(
+ DirectoryScanResult outputDirectoryScanResult,
+ File mojoConfigBase,
+ String createdFilesLstFilename )
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] slachiewicz commented on pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "slachiewicz (via GitHub)" <gi...@apache.org>.
slachiewicz commented on PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#issuecomment-1577994032
@elharo please review again
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven-shared-incremental] marquiswang commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "marquiswang (via GitHub)" <gi...@apache.org>.
marquiswang commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173856763
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -129,6 +146,30 @@ public void setDirectoryScanner( DirectoryScanner directoryScanner )
this.directoryScanner = directoryScanner;
}
+ /**
+ * Get the existing DirectoryScanner used by this helper,
+ * or create new a DirectoryScanner if none is yet set.
+ * The DirectoryScanner is used for detecting changes in a directory
+ */
+ public DirectoryScanner getGeneratedSourcesDirectoryScanner()
+ {
+ if ( generatedSourcesDirectoryScanner == null )
+ {
+ generatedSourcesDirectoryScanner = new DirectoryScanner();
+ }
+
+ return generatedSourcesDirectoryScanner;
+ }
+
+ /**
+ * Set the DirectoryScanner which shall get used by this build helper.
+ * @param generatedSourcesDirectoryScanner
+ */
+ public void setGeneratedSourcesDirectoryScanner( DirectoryScanner generatedSourcesDirectoryScanner )
Review Comment:
Though this class is literally the only thing in `maven-shared-incremental`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] marquiswang commented on pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "marquiswang (via GitHub)" <gi...@apache.org>.
marquiswang commented on PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#issuecomment-1517971645
> As it is separate component we need separate jira issue 😄 to correctly build a release notes.
Should that still be MCOMPILER?
>
> I know that unit tests are missing here ... can you try add first one for your change?
Uhhhhhhhh... I'm not sure it is practical for me to write the unit tests for this file. If you are able to whip together a quick one I can add one for this change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] marquiswang commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "marquiswang (via GitHub)" <gi...@apache.org>.
marquiswang commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173838194
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -323,25 +362,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:
So yeah I was just going for consistency with the existing API!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] marquiswang commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "marquiswang (via GitHub)" <gi...@apache.org>.
marquiswang commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173842161
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -358,6 +395,73 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil
}
+ private void writeChangedFiles(
+ DirectoryScanner directoryScanner,
+ String[] filesBeforeAction,
+ File mojoConfigBase,
+ String createdFilesLstFilename ) throws MojoExecutionException
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] elharo commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173926787
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -323,25 +362,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:
That only makes sense if the existing API is correct. Consistency with bad code is not a goal.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] elharo commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173657637
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -129,6 +146,30 @@ public void setDirectoryScanner( DirectoryScanner directoryScanner )
this.directoryScanner = directoryScanner;
}
+ /**
+ * Get the existing DirectoryScanner used by this helper,
+ * or create new a DirectoryScanner if none is yet set.
+ * The DirectoryScanner is used for detecting changes in a directory
+ */
+ public DirectoryScanner getGeneratedSourcesDirectoryScanner()
+ {
+ if ( generatedSourcesDirectoryScanner == null )
+ {
+ generatedSourcesDirectoryScanner = new DirectoryScanner();
+ }
+
+ return generatedSourcesDirectoryScanner;
+ }
+
+ /**
+ * Set the DirectoryScanner which shall get used by this build helper.
Review Comment:
which shall get used by this build helper --> that scans the target/generated sources directory
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -66,12 +71,24 @@
*/
private DirectoryScanner directoryScanner;
+ /**
+ * Used for detecting changes between the Mojo execution.
+ * @see #getGeneratedSourcesDirectoryScanner() ;
+ */
+ private DirectoryScanner generatedSourcesDirectoryScanner;
+
/**
* Once the {@link #beforeRebuildExecution(org.apache.maven.shared.incremental.IncrementalBuildHelperRequest)} got
* called, this will contain the list of files in the build directory.
*/
private String[] filesBeforeAction = new String[0];
+ /**
+ * Once the {@link #beforeRebuildExecution(org.apache.maven.shared.incremental.IncrementalBuildHelperRequest)} got
Review Comment:
After the {@link #beforeRebuildExecution(org.apache.maven.shared.incremental.IncrementalBuildHelperRequest)} is
* called, this contains the list of files in the build directory.
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -129,6 +146,30 @@ public void setDirectoryScanner( DirectoryScanner directoryScanner )
this.directoryScanner = directoryScanner;
}
+ /**
+ * Get the existing DirectoryScanner used by this helper,
+ * or create new a DirectoryScanner if none is yet set.
+ * The DirectoryScanner is used for detecting changes in a directory
+ */
+ public DirectoryScanner getGeneratedSourcesDirectoryScanner()
Review Comment:
Do these methods need to be public? It looks like they can be package protected/default access
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -129,6 +146,30 @@ public void setDirectoryScanner( DirectoryScanner directoryScanner )
this.directoryScanner = directoryScanner;
}
+ /**
+ * Get the existing DirectoryScanner used by this helper,
+ * or create new a DirectoryScanner if none is yet set.
+ * The DirectoryScanner is used for detecting changes in a directory
+ */
+ public DirectoryScanner getGeneratedSourcesDirectoryScanner()
+ {
+ if ( generatedSourcesDirectoryScanner == null )
+ {
+ generatedSourcesDirectoryScanner = new DirectoryScanner();
+ }
+
+ return generatedSourcesDirectoryScanner;
+ }
+
+ /**
+ * Set the DirectoryScanner which shall get used by this build helper.
+ * @param generatedSourcesDirectoryScanner
+ */
+ public void setGeneratedSourcesDirectoryScanner( DirectoryScanner generatedSourcesDirectoryScanner )
Review Comment:
I'm not sure why these methods (or this class for that matter) is needed. It seems a directory scanner could be easily created without it.
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -323,25 +362,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:
These getter methods don't seem to help. They're an unnecessary layer of indirection. Just use the constructor directly.
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -323,25 +362,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(),
+ filesBeforeAction,
+ mojoConfigBase,
+ CREATED_FILES_LST_FILENAME );
+
+ writeChangedFiles(
+ getGeneratedSourcesDirectoryScanner(),
+ generatedSourcesBeforeAction,
+ mojoConfigBase,
+ GENERATED_FILES_LST_FILENAME );
// in case of clean compile the file is not created so next compile won't see it
// we mus create it here
+ File mojoConfigFile;
Review Comment:
declare on same line as initialize
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -358,6 +395,73 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil
}
+ private void writeChangedFiles(
+ DirectoryScanner directoryScanner,
+ String[] filesBeforeAction,
+ File mojoConfigBase,
+ String createdFilesLstFilename ) throws MojoExecutionException
+ {
+ if ( directoryScanner.getBasedir() == null )
+ {
+ return;
+ }
+
+ DirectoryScanResult outputDirectoryScanResult = scanDirectoryDiff(
+ directoryScanner, filesBeforeAction );
+
+ try
+ {
+ writeChangedFiles( outputDirectoryScanResult, mojoConfigBase, createdFilesLstFilename );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error while storing the mojo status", e );
+ }
+ }
+
+ private static void writeChangedFiles(
+ DirectoryScanResult outputDirectoryScanResult,
+ File mojoConfigBase,
+ String createdFilesLstFilename )
Review Comment:
Lst --> List
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -323,25 +362,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(),
+ filesBeforeAction,
+ mojoConfigBase,
+ CREATED_FILES_LST_FILENAME );
+
+ writeChangedFiles(
+ getGeneratedSourcesDirectoryScanner(),
+ generatedSourcesBeforeAction,
+ mojoConfigBase,
+ GENERATED_FILES_LST_FILENAME );
// in case of clean compile the file is not created so next compile won't see it
// we mus create it here
Review Comment:
mus --> must
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -358,6 +395,73 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil
}
+ private void writeChangedFiles(
+ DirectoryScanner directoryScanner,
+ String[] filesBeforeAction,
+ File mojoConfigBase,
+ String createdFilesLstFilename ) throws MojoExecutionException
Review Comment:
Lst --> List
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -358,6 +395,73 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil
}
+ private void writeChangedFiles(
+ DirectoryScanner directoryScanner,
+ String[] filesBeforeAction,
+ File mojoConfigBase,
+ String createdFilesLstFilename ) throws MojoExecutionException
+ {
+ if ( directoryScanner.getBasedir() == null )
+ {
+ return;
+ }
+
+ DirectoryScanResult outputDirectoryScanResult = scanDirectoryDiff(
+ directoryScanner, filesBeforeAction );
+
+ try
+ {
+ writeChangedFiles( outputDirectoryScanResult, mojoConfigBase, createdFilesLstFilename );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error while storing the mojo status", e );
+ }
+ }
+
+ private static void writeChangedFiles(
+ DirectoryScanResult outputDirectoryScanResult,
+ File mojoConfigBase,
+ String createdFilesLstFilename )
+ throws IOException
+ {
+ File createdFiles = new File( mojoConfigBase, createdFilesLstFilename );
+ FileUtils.fileWriteArray( createdFiles, outputDirectoryScanResult.getFilesAdded() );
Review Comment:
This method is deprecated. Use
java.nio.files.Files.write(file.toPath(), data.getBytes(encoding), StandardOpenOption.CREATE)
and specify UTF-8 encoding
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -358,6 +395,73 @@ public void afterRebuildExecution( IncrementalBuildHelperRequest incrementalBuil
}
+ private void writeChangedFiles(
+ DirectoryScanner directoryScanner,
+ String[] filesBeforeAction,
+ File mojoConfigBase,
+ String createdFilesLstFilename ) throws MojoExecutionException
+ {
+ if ( directoryScanner.getBasedir() == null )
+ {
+ return;
+ }
+
+ DirectoryScanResult outputDirectoryScanResult = scanDirectoryDiff(
+ directoryScanner, filesBeforeAction );
+
+ try
+ {
+ writeChangedFiles( outputDirectoryScanResult, mojoConfigBase, createdFilesLstFilename );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "Error while storing the mojo status", e );
+ }
+ }
+
+ private static void writeChangedFiles(
+ DirectoryScanResult outputDirectoryScanResult,
+ File mojoConfigBase,
+ String createdFilesLstFilename )
+ throws IOException
+ {
+ File createdFiles = new File( mojoConfigBase, createdFilesLstFilename );
+ FileUtils.fileWriteArray( createdFiles, outputDirectoryScanResult.getFilesAdded() );
+ }
+
+ 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 String[] deleteFiles( File fileNameIndex, File parent ) throws IOException
+ {
+ String[] oldFiles = FileUtils.fileReadArray( fileNameIndex );
Review Comment:
deprecated. use java.nio.files.Files.readAllLines() instead and specify UTF-8
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] marquiswang commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "marquiswang (via GitHub)" <gi...@apache.org>.
marquiswang commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173836928
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -129,6 +146,30 @@ public void setDirectoryScanner( DirectoryScanner directoryScanner )
this.directoryScanner = directoryScanner;
}
+ /**
+ * Get the existing DirectoryScanner used by this helper,
+ * or create new a DirectoryScanner if none is yet set.
+ * The DirectoryScanner is used for detecting changes in a directory
+ */
+ public DirectoryScanner getGeneratedSourcesDirectoryScanner()
Review Comment:
These are copy-pasted from the getDirectoryScanner(). It isn't clear to me why that one is public. I made this one public to be consistent.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org
[GitHub] [maven-shared-incremental] elharo commented on a diff in pull request #23: [MCOMPILER-333] Clean generatedSourcesDirectory along with outputDirectory
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on code in PR #23:
URL: https://github.com/apache/maven-shared-incremental/pull/23#discussion_r1173925890
##########
src/main/java/org/apache/maven/shared/incremental/IncrementalBuildHelper.java:
##########
@@ -129,6 +146,30 @@ public void setDirectoryScanner( DirectoryScanner directoryScanner )
this.directoryScanner = directoryScanner;
}
+ /**
+ * Get the existing DirectoryScanner used by this helper,
+ * or create new a DirectoryScanner if none is yet set.
+ * The DirectoryScanner is used for detecting changes in a directory
+ */
+ public DirectoryScanner getGeneratedSourcesDirectoryScanner()
+ {
+ if ( generatedSourcesDirectoryScanner == null )
+ {
+ generatedSourcesDirectoryScanner = new DirectoryScanner();
+ }
+
+ return generatedSourcesDirectoryScanner;
+ }
+
+ /**
+ * Set the DirectoryScanner which shall get used by this build helper.
+ * @param generatedSourcesDirectoryScanner
+ */
+ public void setGeneratedSourcesDirectoryScanner( DirectoryScanner generatedSourcesDirectoryScanner )
Review Comment:
Don't change existing public methods in this PR, but also don't compound problems by introducing new ones we don't need.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org