You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/03/29 20:04:51 UTC
[maven] branch MNG-4660 created (now ace3d16)
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a change to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git.
at ace3d16 Use Stream#iterator to lazily traverse outputFiles
This branch includes the following new commits:
new d367562 Include already built submodules in Reactor for local dependency resolving.
new 288fa74 Do not check whether calculated directory actually exists
new c9ba80d Inspect all projects in Reactor when retrieving metadata
new aad6443 Update comment
new 450e0ca Make ReactorReader aware of possible previous built artifacts
new 3274c23 Only use module output directory when it has been compiled in this session
new 88eda1b Update contributors list
new 4637045 Prefer the target/classes directory when the packaged artifact is not up-to-date.
new 59d6cd4 Use Files.walk instead of .list to recursively check for newer class files when checking if the packaged artifact is up-to-date
new 51a774b Also include build output directory when the project does not have a compile lifecycle when reading local artifacts. This is needed for resolving intermodule dependencies which are not built in this session (for example with -rf, -pl flags).
new 010f270 Checkstyle fixes
new 0be5e94 More sophisticated rules for determining project artifact
new 1b66245 Remove obsolete comment
new 0125718 Replace checking if the project has the lifecyclePhase "validate" by checking if the project consists in the reactor.
new 008b52e Checkstyle - Removed unused import
new bce3d14 Using Files.getLastModifiedTime instead of File#lastModified to avoid a bug in JDK8 on linux.
new ace3d16 Use Stream#iterator to lazily traverse outputFiles
The 17 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[maven] 12/17: More sophisticated rules for determining project
artifact
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 0be5e94b843122a64ce5308a2b4c192261c3894d
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Thu Mar 26 13:59:38 2020 +0100
More sophisticated rules for determining project artifact
It now properly distinguishes between two situations:
1. project artifact has been built during earlier Maven session
2. project artifact has been built during this session
---
.../src/main/java/org/apache/maven/ReactorReader.java | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 7c85668..71e70b9 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -194,9 +194,22 @@ class ReactorReader
else
{
String type = artifact.getProperty( "type", "" );
- if ( COMPILE_PHASE_TYPES.contains( type ) )
+ File outputDirectory = new File( project.getBuild().getOutputDirectory() );
+
+ // Check if the target project is being built during this session, and if we can expect any output.
+ // There is no need to check if the build has created any outputs, see MNG-2222.
+ boolean projectCompiledDuringThisSession
+ = project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type );
+
+ // Check if the target project lacks 'validate' so we know it's not part of the build at all. If so, we
+ // check if a possible earlier Maven invocation produced some output for that project.
+ boolean projectHasOutputFromPreviousSession
+ = !project.hasLifecyclePhase( "validate" ) && outputDirectory.exists();
+
+ if ( projectHasOutputFromPreviousSession || projectCompiledDuringThisSession )
{
- return new File( project.getBuild().getOutputDirectory() );
+ // If the target project is not part of the build,
+ return outputDirectory;
}
}
}
[maven] 04/17: Update comment
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit aad644383b1f00920610219fd5f491308cf55c01
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Fri Feb 14 12:50:18 2020 +0100
Update comment
---
maven-core/src/main/java/org/apache/maven/execution/MavenSession.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
index 5b56df3..8da252f 100644
--- a/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
+++ b/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java
@@ -297,7 +297,7 @@ public class MavenSession
private final Settings settings;
@Deprecated
- /** @deprecated This appears to only be used in the ReactorReader and we can do any processing required there */
+ /** @deprecated This appears not to be used anywhere within Maven itself. */
public Map<String, MavenProject> getProjectMap()
{
return projectMap;
[maven] 07/17: Update contributors list
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 88eda1b3690fa1c90cd259a7cd44c4a028b98651
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Fri Feb 14 13:40:28 2020 +0100
Update contributors list
---
pom.xml | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index ef2764d..7976341 100644
--- a/pom.xml
+++ b/pom.xml
@@ -158,7 +158,12 @@ under the License.
<name>Mike Mol (MNG-6665)</name>
</contributor>
<contributor>
- <name>Martin Kanters (MNG-6665, MNG-6065)</name>
+ <name>Martin Kanters</name>
+ <organization>Info Support</organization>
+ </contributor>
+ <contributor>
+ <name>Maarten Mulders</name>
+ <organization>Info Support</organization>
</contributor>
<contributor>
<name>Luc Klaassen (MNG-6065)</name>
[maven] 03/17: Inspect all projects in Reactor when retrieving
metadata
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit c9ba80d8d635be6620a7f99cca1e7cc7e6bff86f
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Fri Feb 14 12:49:53 2020 +0100
Inspect all projects in Reactor when retrieving metadata
---
.../org/apache/maven/project/artifact/MavenMetadataSource.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
index 1c40af8..cacbd9d 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
@@ -194,9 +194,11 @@ public class MavenMetadataSource
DependencyManagement dependencyManagement = model.getDependencyManagement();
managedDependencies = dependencyManagement == null ? null : dependencyManagement.getDependencies();
MavenSession session = legacySupport.getSession();
- MavenProject project = session.getProjectMap().get(
- ArtifactUtils.key( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ) );
- pomRepositories = project.getRemoteArtifactRepositories();
+ pomRepositories = session.getProjects().stream()
+ .filter(p -> artifact.equals( p.getArtifact() ) )
+ .map(MavenProject::getRemoteArtifactRepositories)
+ .findFirst()
+ .orElseGet(ArrayList::new);
}
else if ( artifact instanceof ArtifactWithDependencies )
{
[maven] 08/17: Prefer the target/classes directory when the
packaged artifact is not up-to-date.
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 4637045a7071ef5382b754a30007181afc8f0972
Author: Martin Kanters <Ma...@ing.com>
AuthorDate: Mon Mar 9 12:29:26 2020 +0100
Prefer the target/classes directory when the packaged artifact is not up-to-date.
---
.../main/java/org/apache/maven/ReactorReader.java | 45 +++++++++++++++++++++-
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 2bfb9ee..3f320a1 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -20,6 +20,10 @@ package org.apache.maven;
*/
import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -28,6 +32,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.function.Predicate;
+import java.util.stream.Stream;
import javax.inject.Inject;
import javax.inject.Named;
@@ -37,6 +43,7 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Model;
import org.apache.maven.project.MavenProject;
import org.apache.maven.repository.internal.MavenWorkspaceReader;
+import org.codehaus.plexus.logging.Logger;
import org.eclipse.aether.artifact.Artifact;
import org.eclipse.aether.repository.WorkspaceRepository;
import org.eclipse.aether.util.artifact.ArtifactIdUtils;
@@ -57,6 +64,8 @@ class ReactorReader
private static final Collection<String> COMPILE_PHASE_TYPES =
Arrays.asList( "jar", "ejb-client", "war", "rar", "ejb3", "par", "sar", "wsr", "har", "app-client" );
+ private Logger logger;
+
private Map<String, MavenProject> projectsByGAV;
private Map<String, List<MavenProject>> projectsByGA;
@@ -64,8 +73,9 @@ class ReactorReader
private WorkspaceRepository repository;
@Inject
- ReactorReader( MavenSession session )
+ ReactorReader( MavenSession session, Logger logger )
{
+ this.logger = logger;
this.projectsByGAV = new HashMap<>( session.getAllProjects().size() * 2 );
session.getAllProjects().forEach( project ->
{
@@ -164,7 +174,8 @@ class ReactorReader
return projectArtifact.getFile();
}
// Check whether an earlier Maven run might have produced an artifact that is still on disk.
- else if ( packagedArtifactFile != null && packagedArtifactFile.exists() )
+ else if ( packagedArtifactFile != null && packagedArtifactFile.exists()
+ && isPackagedArtifactUpToDate( project, packagedArtifactFile ) )
{
return packagedArtifactFile;
}
@@ -211,6 +222,36 @@ class ReactorReader
return projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists();
}
+ private boolean isPackagedArtifactUpToDate( MavenProject project, File packagedArtifactFile )
+ {
+ Path outputDirectory = Paths.get( project.getBuild().getOutputDirectory() );
+ if ( !outputDirectory.toFile().exists() )
+ {
+ return true;
+ }
+
+ try ( Stream<Path> outputFiles = Files.list( outputDirectory ) )
+ {
+ long artifactLastModified = packagedArtifactFile.lastModified();
+ Predicate<Path> isNewerThanPackagedArtifact = path -> path.toFile().lastModified() > artifactLastModified;
+ boolean isPackagedArtifactUpToDate = outputFiles.noneMatch( isNewerThanPackagedArtifact );
+
+ if ( !isPackagedArtifactUpToDate )
+ {
+ logger.warn( "Packaged artifact is not up-to-date compared to the build output directory" );
+ }
+
+ return isPackagedArtifactUpToDate;
+ }
+ catch ( IOException e )
+ {
+ logger.warn( "An I/O error occurred while checking if the packaged artifact is up-to-date "
+ + "against the build output directory. "
+ + "Continuing with the assumption that it is up-to-date.", e );
+ return true;
+ }
+ }
+
private boolean hasBeenPackagedDuringThisSession( MavenProject project )
{
return project.hasLifecyclePhase( "package" ) || project.hasLifecyclePhase( "install" )
[maven] 06/17: Only use module output directory when it has been
compiled in this session
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 3274c2359d559e19a297dcfc2e7a26ec6f42f997
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Fri Feb 14 15:18:30 2020 +0100
Only use module output directory when it has been compiled in this session
---
maven-core/src/main/java/org/apache/maven/ReactorReader.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 7c52ff2..2bfb9ee 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -183,7 +183,7 @@ class ReactorReader
else
{
String type = artifact.getProperty( "type", "" );
- if ( COMPILE_PHASE_TYPES.contains( type ) )
+ if ( project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type ) )
{
return new File( project.getBuild().getOutputDirectory() );
}
[maven] 13/17: Remove obsolete comment
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 1b66245d35226405bf779b1990913f0e9cea5bf1
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Thu Mar 26 14:10:47 2020 +0100
Remove obsolete comment
---
maven-core/src/main/java/org/apache/maven/ReactorReader.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 71e70b9..0d28a3a 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -208,7 +208,6 @@ class ReactorReader
if ( projectHasOutputFromPreviousSession || projectCompiledDuringThisSession )
{
- // If the target project is not part of the build,
return outputDirectory;
}
}
[maven] 02/17: Do not check whether calculated directory actually
exists
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 288fa74c9dc668110a965359fdcd78046201dbd0
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Wed Jan 29 21:35:10 2020 +0100
Do not check whether calculated directory actually exists
---
maven-core/src/main/java/org/apache/maven/ReactorReader.java | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index b9434ee..f840cb5 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -179,11 +179,7 @@ class ReactorReader
String type = artifact.getProperty( "type", "" );
if ( COMPILE_PHASE_TYPES.contains( type ) )
{
- File outputDirectory = new File( project.getBuild().getOutputDirectory() );
- if ( outputDirectory.exists() )
- {
- return outputDirectory;
- }
+ return new File( project.getBuild().getOutputDirectory() );
}
}
}
[maven] 17/17: Use Stream#iterator to lazily traverse outputFiles
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit ace3d16ed9acba73cc8cc967c552eb9a4dba5762
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Sun Mar 29 21:28:46 2020 +0200
Use Stream#iterator to lazily traverse outputFiles
---
maven-core/src/main/java/org/apache/maven/ReactorReader.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 13d7205..ebcf452 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -30,9 +30,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.inject.Inject;
@@ -250,8 +250,10 @@ class ReactorReader
// Not using File#lastModified() to avoid a Linux JDK8 milliseconds precision bug: JDK-8177809.
long artifactLastModified = Files.getLastModifiedTime( packagedArtifactFile.toPath() ).toMillis();
- for ( Path outputFile : outputFiles.collect( Collectors.toList() ) )
+ Iterator<Path> iterator = outputFiles.iterator();
+ while ( iterator.hasNext() )
{
+ Path outputFile = iterator.next();
long outputFileLastModified = Files.getLastModifiedTime( outputFile ).toMillis();
if ( outputFileLastModified > artifactLastModified )
{
[maven] 01/17: Include already built submodules in Reactor for
local dependency resolving.
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit d367562c7faba78a3a85c6eb1720e72ee3861559
Author: Martin Kanters <Ma...@ing.com>
AuthorDate: Wed Jan 29 16:21:39 2020 +0100
Include already built submodules in Reactor for local dependency resolving.
---
.../src/main/java/org/apache/maven/ReactorReader.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 831a4b6..b9434ee 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -66,7 +66,12 @@ class ReactorReader
@Inject
ReactorReader( MavenSession session )
{
- projectsByGAV = session.getProjectMap();
+ this.projectsByGAV = new HashMap<>( session.getAllProjects().size() * 2 );
+ session.getAllProjects().forEach( project ->
+ {
+ String projectId = ArtifactUtils.key( project.getGroupId(), project.getArtifactId(), project.getVersion() );
+ this.projectsByGAV.put( projectId, project );
+ } );
projectsByGA = new HashMap<>( projectsByGAV.size() * 2 );
for ( MavenProject project : projectsByGAV.values() )
@@ -172,9 +177,13 @@ class ReactorReader
else
{
String type = artifact.getProperty( "type", "" );
- if ( project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type ) )
+ if ( COMPILE_PHASE_TYPES.contains( type ) )
{
- return new File( project.getBuild().getOutputDirectory() );
+ File outputDirectory = new File( project.getBuild().getOutputDirectory() );
+ if ( outputDirectory.exists() )
+ {
+ return outputDirectory;
+ }
}
}
}
[maven] 11/17: Checkstyle fixes
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 010f270c1623bc4c7022ca9bd40ccea32c9f91ff
Author: Martin Kanters <Ma...@infosupport.com>
AuthorDate: Thu Mar 26 11:18:19 2020 +0100
Checkstyle fixes
---
.../java/org/apache/maven/project/artifact/MavenMetadataSource.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
index cacbd9d..1c718e3 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
@@ -195,10 +195,10 @@ public class MavenMetadataSource
managedDependencies = dependencyManagement == null ? null : dependencyManagement.getDependencies();
MavenSession session = legacySupport.getSession();
pomRepositories = session.getProjects().stream()
- .filter(p -> artifact.equals( p.getArtifact() ) )
- .map(MavenProject::getRemoteArtifactRepositories)
+ .filter( p -> artifact.equals( p.getArtifact() ) )
+ .map( MavenProject::getRemoteArtifactRepositories )
.findFirst()
- .orElseGet(ArrayList::new);
+ .orElseGet( ArrayList::new );
}
else if ( artifact instanceof ArtifactWithDependencies )
{
[maven] 09/17: Use Files.walk instead of .list to recursively check
for newer class files when checking if the packaged artifact is up-to-date
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 59d6cd42d4c5533e983973fb979dab331fc97a25
Author: Martin Kanters <Ma...@infosupport.com>
AuthorDate: Mon Mar 9 14:22:25 2020 +0100
Use Files.walk instead of .list to recursively check for newer class files when checking if the packaged artifact is up-to-date
---
maven-core/src/main/java/org/apache/maven/ReactorReader.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 3f320a1..e029660 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -230,7 +230,7 @@ class ReactorReader
return true;
}
- try ( Stream<Path> outputFiles = Files.list( outputDirectory ) )
+ try ( Stream<Path> outputFiles = Files.walk( outputDirectory ) )
{
long artifactLastModified = packagedArtifactFile.lastModified();
Predicate<Path> isNewerThanPackagedArtifact = path -> path.toFile().lastModified() > artifactLastModified;
[maven] 16/17: Using Files.getLastModifiedTime instead of
File#lastModified to avoid a bug in JDK8 on linux.
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit bce3d147eb1bfc5d2a2a6992116a5db739c8d9b4
Author: Martin Kanters <Ma...@infosupport.com>
AuthorDate: Sun Mar 29 17:16:34 2020 +0200
Using Files.getLastModifiedTime instead of File#lastModified to avoid a bug in JDK8 on linux.
---
.../src/main/java/org/apache/maven/ReactorReader.java | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index ddc74f7..13d7205 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -32,7 +32,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.function.Predicate;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.inject.Inject;
@@ -247,16 +247,20 @@ class ReactorReader
try ( Stream<Path> outputFiles = Files.walk( outputDirectory ) )
{
- long artifactLastModified = packagedArtifactFile.lastModified();
- Predicate<Path> isNewerThanPackagedArtifact = path -> path.toFile().lastModified() > artifactLastModified;
- boolean isPackagedArtifactUpToDate = outputFiles.noneMatch( isNewerThanPackagedArtifact );
+ // Not using File#lastModified() to avoid a Linux JDK8 milliseconds precision bug: JDK-8177809.
+ long artifactLastModified = Files.getLastModifiedTime( packagedArtifactFile.toPath() ).toMillis();
- if ( !isPackagedArtifactUpToDate )
+ for ( Path outputFile : outputFiles.collect( Collectors.toList() ) )
{
- logger.warn( "Packaged artifact is not up-to-date compared to the build output directory" );
+ long outputFileLastModified = Files.getLastModifiedTime( outputFile ).toMillis();
+ if ( outputFileLastModified > artifactLastModified )
+ {
+ logger.warn( "Packaged artifact is not up-to-date compared to the build output directory" );
+ return false;
+ }
}
- return isPackagedArtifactUpToDate;
+ return true;
}
catch ( IOException e )
{
[maven] 10/17: Also include build output directory when the project
does not have a compile lifecycle when reading local artifacts. This is
needed for resolving intermodule dependencies which are not built in this
session (for example with -rf, -pl flags).
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 51a774bee20dff42de1dbfc6f38b689864fb8ba8
Author: Martin Kanters <Ma...@infosupport.com>
AuthorDate: Thu Mar 26 11:17:16 2020 +0100
Also include build output directory when the project does not have a compile lifecycle when reading local artifacts. This is needed for resolving intermodule dependencies which are not built in this session (for example with -rf, -pl flags).
---
maven-core/src/main/java/org/apache/maven/ReactorReader.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index e029660..7c85668 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -194,7 +194,7 @@ class ReactorReader
else
{
String type = artifact.getProperty( "type", "" );
- if ( project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type ) )
+ if ( COMPILE_PHASE_TYPES.contains( type ) )
{
return new File( project.getBuild().getOutputDirectory() );
}
[maven] 05/17: Make ReactorReader aware of possible previous built
artifacts
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 450e0ca67edb5397a286d4da78bd7b7fc8221f81
Author: Maarten Mulders <ma...@infosupport.com>
AuthorDate: Fri Feb 14 12:51:16 2020 +0100
Make ReactorReader aware of possible previous built artifacts
---
.../main/java/org/apache/maven/ReactorReader.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index f840cb5..7c52ff2 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -157,12 +157,18 @@ class ReactorReader
}
Artifact projectArtifact = findMatchingArtifact( project, artifact );
+ File packagedArtifactFile = determinePreviouslyPackagedArtifactFile( project, projectArtifact );
if ( hasArtifactFileFromPackagePhase( projectArtifact ) )
{
return projectArtifact.getFile();
}
- else if ( !hasBeenPackaged( project ) )
+ // Check whether an earlier Maven run might have produced an artifact that is still on disk.
+ else if ( packagedArtifactFile != null && packagedArtifactFile.exists() )
+ {
+ return packagedArtifactFile;
+ }
+ else if ( !hasBeenPackagedDuringThisSession( project ) )
{
// fallback to loose class files only if artifacts haven't been packaged yet
// and only for plain old jars. Not war files, not ear files, not anything else.
@@ -189,12 +195,23 @@ class ReactorReader
return null;
}
+ private File determinePreviouslyPackagedArtifactFile( MavenProject project, Artifact artifact )
+ {
+ if ( artifact == null )
+ {
+ return null;
+ }
+
+ String fileName = String.format( "%s.%s", project.getBuild().getFinalName(), artifact.getExtension() );
+ return new File( project.getBuild().getDirectory(), fileName );
+ }
+
private boolean hasArtifactFileFromPackagePhase( Artifact projectArtifact )
{
return projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists();
}
- private boolean hasBeenPackaged( MavenProject project )
+ private boolean hasBeenPackagedDuringThisSession( MavenProject project )
{
return project.hasLifecyclePhase( "package" ) || project.hasLifecyclePhase( "install" )
|| project.hasLifecyclePhase( "deploy" );
[maven] 14/17: Replace checking if the project has the
lifecyclePhase "validate" by checking if the project consists in the
reactor.
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 01257189e9e9de76c860448cedf50011cbd2ba02
Author: Martin Kanters <Ma...@infosupport.com>
AuthorDate: Thu Mar 26 18:09:28 2020 +0100
Replace checking if the project has the lifecyclePhase "validate" by checking if the project consists in the reactor.
---
maven-core/src/main/java/org/apache/maven/ReactorReader.java | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 0d28a3a..ddc74f7 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -66,6 +66,8 @@ class ReactorReader
private Logger logger;
+ private MavenSession session;
+
private Map<String, MavenProject> projectsByGAV;
private Map<String, List<MavenProject>> projectsByGA;
@@ -76,6 +78,7 @@ class ReactorReader
ReactorReader( MavenSession session, Logger logger )
{
this.logger = logger;
+ this.session = session;
this.projectsByGAV = new HashMap<>( session.getAllProjects().size() * 2 );
session.getAllProjects().forEach( project ->
{
@@ -196,15 +199,15 @@ class ReactorReader
String type = artifact.getProperty( "type", "" );
File outputDirectory = new File( project.getBuild().getOutputDirectory() );
- // Check if the target project is being built during this session, and if we can expect any output.
+ // Check if the project is being built during this session, and if we can expect any output.
// There is no need to check if the build has created any outputs, see MNG-2222.
boolean projectCompiledDuringThisSession
= project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type );
- // Check if the target project lacks 'validate' so we know it's not part of the build at all. If so, we
- // check if a possible earlier Maven invocation produced some output for that project.
+ // Check if the project is part of the session (not filtered by -pl, -rf, etc). If so, we check
+ // if a possible earlier Maven invocation produced some output for that project which we can use.
boolean projectHasOutputFromPreviousSession
- = !project.hasLifecyclePhase( "validate" ) && outputDirectory.exists();
+ = !session.getProjects().contains( project ) && outputDirectory.exists();
if ( projectHasOutputFromPreviousSession || projectCompiledDuringThisSession )
{
[maven] 15/17: Checkstyle - Removed unused import
Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rfscholte pushed a commit to branch MNG-4660
in repository https://gitbox.apache.org/repos/asf/maven.git
commit 008b52e25b54093e9e187609ce8ea1e099e16319
Author: Martin Kanters <Ma...@infosupport.com>
AuthorDate: Sat Mar 28 15:22:40 2020 +0100
Checkstyle - Removed unused import
---
.../main/java/org/apache/maven/project/artifact/MavenMetadataSource.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
index 1c718e3..6b3a09a 100644
--- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
+++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
@@ -34,7 +34,6 @@ import java.util.Set;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;