Apply patch for rhbz#1015596

This commit is contained in:
Stanislav Ochotnicky 2013-10-07 17:37:24 +02:00
parent e7f5ac7098
commit 924c65a78a
2 changed files with 139 additions and 1 deletions

View File

@ -0,0 +1,132 @@
From 552733c90772f5e1a698aa6c2bef3cff41dc11a5 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Mon, 7 Oct 2013 16:31:54 +0200
Subject: [PATCH] Take stereotypes into account during dependency extraction
---
.../dependency/impl/BuildDependencyVisitor.java | 16 ++++++----
.../dependency/impl/RuntimeDependencyVisitor.java | 10 +++---
.../fedoraproject/maven/utils/ArtifactUtils.java | 37 ++++++++++++++++++++++
3 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/dependency/impl/BuildDependencyVisitor.java b/xmvn-core/src/main/java/org/fedoraproject/maven/dependency/impl/BuildDependencyVisitor.java
index 04dff90..0d47850 100644
--- a/xmvn-core/src/main/java/org/fedoraproject/maven/dependency/impl/BuildDependencyVisitor.java
+++ b/xmvn-core/src/main/java/org/fedoraproject/maven/dependency/impl/BuildDependencyVisitor.java
@@ -75,9 +75,11 @@ class BuildDependencyVisitor
if ( !buildScopes.contains( dependency.getScope() ) )
return;
- result.addDependencyArtifact( new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(),
- dependency.getClassifier(), dependency.getType(),
- dependency.getVersion() ) );
+ result.addDependencyArtifact( ArtifactUtils.createTypedArtifact( dependency.getGroupId(),
+ dependency.getArtifactId(),
+ dependency.getType(),
+ dependency.getClassifier(),
+ dependency.getVersion() ) );
}
@Override
@@ -111,8 +113,10 @@ class BuildDependencyVisitor
if ( !runtimeScopes.contains( dependency.getScope() ) )
return;
- result.addDependencyArtifact( new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(),
- dependency.getClassifier(), dependency.getType(),
- dependency.getVersion() ) );
+ result.addDependencyArtifact( ArtifactUtils.createTypedArtifact( dependency.getGroupId(),
+ dependency.getArtifactId(),
+ dependency.getType(),
+ dependency.getClassifier(),
+ dependency.getVersion() ) );
}
}
diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/dependency/impl/RuntimeDependencyVisitor.java b/xmvn-core/src/main/java/org/fedoraproject/maven/dependency/impl/RuntimeDependencyVisitor.java
index 6ef22b9..4bcc8ad 100644
--- a/xmvn-core/src/main/java/org/fedoraproject/maven/dependency/impl/RuntimeDependencyVisitor.java
+++ b/xmvn-core/src/main/java/org/fedoraproject/maven/dependency/impl/RuntimeDependencyVisitor.java
@@ -19,8 +19,8 @@ import java.util.Arrays;
import java.util.List;
import org.apache.maven.model.Dependency;
-import org.eclipse.aether.artifact.DefaultArtifact;
import org.fedoraproject.maven.model.AbstractModelVisitor;
+import org.fedoraproject.maven.utils.ArtifactUtils;
/**
* @author Mikolaj Izdebski
@@ -43,8 +43,10 @@ class RuntimeDependencyVisitor
if ( !scopes.contains( dependency.getScope() ) )
return;
- result.addDependencyArtifact( new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(),
- dependency.getClassifier(), dependency.getType(),
- dependency.getVersion() ) );
+ result.addDependencyArtifact( ArtifactUtils.createTypedArtifact( dependency.getGroupId(),
+ dependency.getArtifactId(),
+ dependency.getType(),
+ dependency.getClassifier(),
+ dependency.getVersion() ) );
}
}
diff --git a/xmvn-core/src/main/java/org/fedoraproject/maven/utils/ArtifactUtils.java b/xmvn-core/src/main/java/org/fedoraproject/maven/utils/ArtifactUtils.java
index b6ef806..b4a4062 100644
--- a/xmvn-core/src/main/java/org/fedoraproject/maven/utils/ArtifactUtils.java
+++ b/xmvn-core/src/main/java/org/fedoraproject/maven/utils/ArtifactUtils.java
@@ -23,10 +23,13 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.XmlSerializer;
import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.artifact.ArtifactType;
import org.eclipse.aether.artifact.DefaultArtifact;
+import org.eclipse.aether.artifact.DefaultArtifactType;
/**
* @author Mikolaj Izdebski
@@ -179,4 +182,38 @@ public class ArtifactUtils
Xpp3Dom dom = toXpp3Dom( artifact, tag );
dom.writeToSerializer( namespace, serializer );
}
+
+ private static final Map<String, ArtifactType> stereotypes = new HashMap<>();
+
+ private static void addStereotype( String type, String extension, String classifier )
+ {
+ stereotypes.put( type, new DefaultArtifactType( type, extension, classifier, "java" ) );
+ }
+
+ // The list was taken from MavenRepositorySystemUtils in maven-aether-provider.
+ static
+ {
+ addStereotype( "maven-plugin", "jar", "" );
+ addStereotype( "ejb", "jar", "" );
+ addStereotype( "ejb-client", "jar", "client" );
+ addStereotype( "test-jar", "jar", "tests" );
+ addStereotype( "javadoc", "jar", "javadoc" );
+ addStereotype( "java-source", "jar", "sources" );
+ }
+
+ public static Artifact createTypedArtifact( String groupId, String artifactId, String type, String classifier,
+ String version )
+ {
+ String extension = type;
+
+ ArtifactType artifactType = stereotypes.get( type );
+ if ( artifactType != null )
+ {
+ extension = artifactType.getExtension();
+ if ( StringUtils.isEmpty( classifier ) )
+ classifier = artifactType.getClassifier();
+ }
+
+ return new DefaultArtifact( groupId, artifactId, classifier, extension, version );
+ }
}
--
1.8.3.1

View File

@ -1,12 +1,14 @@
Name: xmvn
Version: 1.1.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Local Extensions for Apache Maven
License: ASL 2.0
URL: http://mizdebsk.fedorapeople.org/xmvn
BuildArch: noarch
Source0: https://fedorahosted.org/released/%{name}/%{name}-%{version}.tar.xz
Patch1: 0001-Take-stereotypes-into-account-during-dependency-extr.patch
BuildRequires: maven >= 3.1.0
BuildRequires: maven-local
BuildRequires: beust-jcommander
@ -32,6 +34,7 @@ This package provides %{summary}.
%prep
%setup -q
%patch1 -p1
# remove dependency plugin maven-binaries execution
# we provide apache-maven by symlink
@ -141,6 +144,9 @@ end
%doc LICENSE NOTICE
%changelog
* Mon Oct 07 2013 Stanislav Ochotnicky <sochotnicky@redhat.com> - 1.1.0-2
- Apply patch for rhbz#1015596
* Tue Oct 01 2013 Stanislav Ochotnicky <sochotnicky@redhat.com> - 1.1.0-1
- Update to upstream version 1.1.0