xmvn/0003-Override-extensions-of-skipped-artifacts.patch
2014-04-22 15:32:28 +02:00

102 lines
5.5 KiB
Diff

From 124340c288e5276968c0a7463a02eeadcca89772 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Fri, 28 Mar 2014 19:38:30 +0100
Subject: [PATCH 3/4] Override extensions of skipped artifacts
Artifacts which are not installed must set their exiension to "pom",
otherwise XMvn Installed would fail with "POM artifact has extension
different from 'pom': jar". This limitation is fixed in XMvn 2.x.
---
.../org/fedoraproject/maven/rpminstall/plugin/BuilddepMojo.java | 4 ++--
.../org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java | 7 ++++---
.../main/java/org/fedoraproject/maven/rpminstall/plugin/Utils.java | 5 ++++-
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/BuilddepMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/BuilddepMojo.java
index 789988e..a9f07c1 100644
--- a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/BuilddepMojo.java
+++ b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/BuilddepMojo.java
@@ -78,7 +78,7 @@ public class BuilddepMojo
for ( MavenProject project : reactorProjects )
{
- Artifact projectArtifact = Utils.aetherArtifact( project.getArtifact() );
+ Artifact projectArtifact = Utils.aetherArtifact( project.getArtifact(), null );
projectArtifact = projectArtifact.setFile( project.getFile() );
DependencyExtractionRequest request = new DependencyExtractionRequest();
@@ -96,7 +96,7 @@ public class BuilddepMojo
reactorArtifacts.add( projectArtifact );
for ( org.apache.maven.artifact.Artifact attachedArtifact : project.getAttachedArtifacts() )
- reactorArtifacts.add( Utils.aetherArtifact( attachedArtifact ) );
+ reactorArtifacts.add( Utils.aetherArtifact( attachedArtifact, null ) );
}
dependencies.removeAll( reactorArtifacts );
diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java
index bbff4c2..19525b3 100644
--- a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java
+++ b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java
@@ -88,7 +88,7 @@ public class InstallMojo
{
systemDepsFound = true;
- logger.error( "Reactor project " + aetherArtifact( project.getArtifact() )
+ logger.error( "Reactor project " + aetherArtifact( project.getArtifact(), null )
+ " has system-scoped dependencies: " + ArtifactUtils.collectionToString( systemDeps, true ) );
}
}
@@ -125,7 +125,7 @@ public class InstallMojo
{
for ( MavenProject project : reactorProjects )
{
- Artifact mainArtifact = aetherArtifact( project.getArtifact() );
+ Artifact mainArtifact = aetherArtifact( project.getArtifact(), null );
mainArtifact = mainArtifact.setFile( project.getArtifact().getFile() );
logger.debug( "Installing main artifact " + mainArtifact );
logger.debug( "Artifact file is " + mainArtifact.getFile() );
@@ -134,6 +134,7 @@ public class InstallMojo
{
logger.info( "Skipping installation of artifact " + mainArtifact.getFile()
+ ": artifact file is not a regular file" );
+ mainArtifact = aetherArtifact( project.getArtifact(), "pom" );
mainArtifact = mainArtifact.setFile( null );
}
@@ -146,7 +147,7 @@ public class InstallMojo
for ( org.apache.maven.artifact.Artifact mavenArtifact : project.getAttachedArtifacts() )
{
- Artifact attachedArtifact = aetherArtifact( mavenArtifact );
+ Artifact attachedArtifact = aetherArtifact( mavenArtifact, null );
attachedArtifact = attachedArtifact.setFile( mavenArtifact.getFile() );
logger.debug( "Installing attached artifact " + attachedArtifact );
logger.debug( "Artifact file is " + mavenArtifact.getFile() );
diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/Utils.java b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/Utils.java
index 623e414..31d7da9 100644
--- a/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/Utils.java
+++ b/xmvn-mojo/src/main/java/org/fedoraproject/maven/rpminstall/plugin/Utils.java
@@ -35,7 +35,7 @@ import org.fedoraproject.maven.utils.ArtifactUtils;
*/
class Utils
{
- public static Artifact aetherArtifact( org.apache.maven.artifact.Artifact mavenArtifact )
+ public static Artifact aetherArtifact( org.apache.maven.artifact.Artifact mavenArtifact, String overrideExtension )
{
String groupId = mavenArtifact.getGroupId();
String artifactId = mavenArtifact.getArtifactId();
@@ -50,6 +50,9 @@ class Utils
File artifactFile = mavenArtifact.getFile();
+ if ( overrideExtension != null )
+ extension = overrideExtension;
+
Artifact artifact = new DefaultArtifact( groupId, artifactId, classifier, extension, version );
artifact = ArtifactUtils.setStereotype( artifact, stereotype );
artifact = artifact.setFile( artifactFile );
--
1.9.0