You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2020/12/25 10:02:22 UTC
[maven-artifact-plugin] branch master updated: support POMs with
overridden finalName
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-artifact-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 0e2b6f7 support POMs with overridden finalName
0e2b6f7 is described below
commit 0e2b6f7f2ef76564242ab550ba2c29595a1df6e1
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Fri Dec 25 11:02:18 2020 +0100
support POMs with overridden finalName
---
.../maven/plugins/artifact/buildinfo/BuildinfoMojo.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java
index 8abbbce..ca62cc0 100644
--- a/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java
+++ b/src/main/java/org/apache/maven/plugins/artifact/buildinfo/BuildinfoMojo.java
@@ -22,6 +22,7 @@ package org.apache.maven.plugins.artifact.buildinfo;
import org.apache.commons.codec.Charsets;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -138,6 +139,9 @@ public class BuildinfoMojo
@Parameter( defaultValue = "${project.remoteProjectRepositories}", readonly = true )
private List<RemoteRepository> remoteRepos;
+ @Component
+ private ArtifactRepositoryLayout artifactRepositoryLayout;
+
public void execute()
throws MojoExecutionException
{
@@ -353,11 +357,19 @@ public class BuildinfoMojo
private String diffoscope( Artifact a, File referenceDir )
{
File actual = a.getFile();
- File reference = new File( referenceDir, actual.getName() );
+ // notice: actual file name may have been defined in pom
+ // reference file name is taken from repository format
+ File reference = new File( referenceDir, getRepositoryFilename( a ) );
return ": investigate with "
+ MessageUtils.buffer().project( "diffoscope " + relative( reference ) + " " + relative( actual ) );
}
+ private String getRepositoryFilename( Artifact a )
+ {
+ String path = artifactRepositoryLayout.pathOf( a );
+ return path.substring( path.lastIndexOf( '/' ) );
+ }
+
private String relative( File file )
{
return file.getPath().substring( getExecutionRoot().getBasedir().getPath().length() + 1 );