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.
This commit is contained in:
Mikolaj Izdebski 2014-03-28 19:42:06 +01:00
parent 06af4ec1f1
commit 8adb07ec4d
4 changed files with 103 additions and 2 deletions

View File

@ -1,7 +1,7 @@
From 6beaea7bae7bbe5fb17b1d9c9b13bb2d4072bc08 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Fri, 28 Mar 2014 16:56:12 +0100
Subject: [PATCH] Don't install artifacts which are not regular files
Subject: [PATCH 1/3] Don't install artifacts which are not regular files
This fixes rhbz#1078967
---

View File

@ -0,0 +1,34 @@
From bbe137765c8ac11c9adcd52e7063453b1c092735 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Fri, 28 Mar 2014 19:30:36 +0100
Subject: [PATCH 2/3] Protect against NPE in Install MOJO
---
.../java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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 0e64792..bbff4c2 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
@@ -130,7 +130,7 @@ public class InstallMojo
logger.debug( "Installing main artifact " + mainArtifact );
logger.debug( "Artifact file is " + mainArtifact.getFile() );
- if ( !mainArtifact.getFile().isFile() )
+ if ( mainArtifact.getFile() != null && !mainArtifact.getFile().isFile() )
{
logger.info( "Skipping installation of artifact " + mainArtifact.getFile()
+ ": artifact file is not a regular file" );
@@ -151,7 +151,7 @@ public class InstallMojo
logger.debug( "Installing attached artifact " + attachedArtifact );
logger.debug( "Artifact file is " + mavenArtifact.getFile() );
- if ( !mavenArtifact.getFile().isFile() )
+ if ( mavenArtifact.getFile() != null && !mavenArtifact.getFile().isFile() )
{
logger.info( "Skipping installation of attached artifact " + attachedArtifact
+ ": artifact file is not a regular file" );
--
1.8.5.3

View File

@ -0,0 +1,60 @@
From fa4de67d690423739343bc1a24f3e4536d65a900 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/3] 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.
---
.../java/org/fedoraproject/maven/rpminstall/plugin/InstallMojo.java | 3 ++-
.../main/java/org/fedoraproject/maven/rpminstall/plugin/Utils.java | 5 ++++-
2 files changed, 6 insertions(+), 2 deletions(-)
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..3a25171 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
@@ -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 );
}
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.8.5.3

View File

@ -1,6 +1,6 @@
Name: xmvn
Version: 1.5.0
Release: 0.23.gitcb3a0a6%{?dist}
Release: 0.24.gitcb3a0a6%{?dist}
Summary: Local Extensions for Apache Maven
License: ASL 2.0
URL: http://mizdebsk.fedorapeople.org/xmvn
@ -12,6 +12,8 @@ BuildArch: noarch
Source0: %{name}-%{version}-SNAPSHOT.tar.xz
Patch0: 0001-Don-t-install-artifacts-which-are-not-regular-files.patch
Patch1: 0002-Protect-against-NPE-in-Install-MOJO.patch
Patch2: 0003-Override-extensions-of-skipped-artifacts.patch
BuildRequires: maven >= 3.1.1-13
BuildRequires: maven-local
@ -41,6 +43,8 @@ This package provides %{summary}.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
# remove dependency plugin maven-binaries execution
# we provide apache-maven by symlink
@ -151,6 +155,9 @@ end
%doc LICENSE NOTICE
%changelog
* Fri Mar 28 2014 Mikolaj Izdebski <mizdebsk@redhat.com> - 1.5.0-0.24.gitcb3a0a6
- Override extensions of skipped artifacts
* Fri Mar 28 2014 Mikolaj Izdebski <mizdebsk@redhat.com> - 1.5.0-0.23.gitcb3a0a6
- Skip installation of artifacts which files are not regular files
- Resolves: rhbz#1078967