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/28 15:36:33 UTC
[maven] branch MNG-4660 created (now fe4dbd4)
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 fe4dbd4 Checkstyle - Removed unused import
This branch includes the following new commits:
new 5a5fad4 Include already built submodules in Reactor for local dependency resolving.
new 3ebc665 Do not check whether calculated directory actually exists
new 5f5ee82 Inspect all projects in Reactor when retrieving metadata
new 6589821 Update comment
new d29b715 Make ReactorReader aware of possible previous built artifacts
new 428e909 Only use module output directory when it has been compiled in this session
new 82db451 Update contributors list
new b3b5829 Prefer the target/classes directory when the packaged artifact is not up-to-date.
new 7e056c2 Use Files.walk instead of .list to recursively check for newer class files when checking if the packaged artifact is up-to-date
new ecd07f3 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 f87b2ef Checkstyle fixes
new 2661777 More sophisticated rules for determining project artifact
new 7f0e124 Remove obsolete comment
new 3360bba Replace checking if the project has the lifecyclePhase "validate" by checking if the project consists in the reactor.
new fe4dbd4 Checkstyle - Removed unused import
The 15 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] 07/15: 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 82db45167fdbfc4abd49bfda5a47846e218a5073
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] 08/15: 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 b3b5829a2d2a6c61bc84d66fc7aa44a409aec654
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] 04/15: 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 6589821ffb204ec463158afad88a76f1c583227d
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] 09/15: 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 7e056c2d891e5a058ea8213c3a0e10e064c40999
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] 14/15: 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 3360bba73ed4570a7a0bc05f114ba254cc4812b8
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] 12/15: 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 26617777b6f00cd9833c52f7d760f4f8522c0cf7
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] 10/15: 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 ecd07f3fd2547220bdcda959a249f555bfaa5ef7
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] 01/15: 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 5a5fad4d771855edc26df9819a55e3b1c1c42a4c
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] 03/15: 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 5f5ee82fb6617beed26cdfb46d107b413be19bb6
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] 15/15: 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 fe4dbd4205e852a2527973d8c9cc1d486d5cb326
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;
[maven] 13/15: 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 7f0e124c603b1a9579a4007077c54eb901d0a19c
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] 06/15: 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 428e90957b3cec7f4ff0c6955f261710546c0cfe
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] 05/15: 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 d29b7155614d2a5126d527c7c3e426f55c547667
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] 11/15: 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 f87b2efa464d12f0cfb2495125ef3829b7016ba1
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] 02/15: 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 3ebc66563f789ce532d24f74a9197b9c61da2861
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() );
}
}
}