From 0f1fcd70668be2c35fa69e4aedde0425f570b103 Mon Sep 17 00:00:00 2001 From: Igor Fedorenko Date: Thu, 13 Feb 2014 21:36:03 -0500 Subject: [PATCH] Revert "MNG-5552 made classifier part of MavenProject.artifactMap key" This reverts commit f35698c790da5329590d1ceba0502c02f942efdf. There are plugins that rely on the broken behaviour and I don't have the time to fix this in backwards compatible way right now. http://markmail.org/message/gjfuofw5gpsr5yxz Signed-off-by: Igor Fedorenko --- .../apache/maven/artifact/ArtifactUtils.java | 15 +------- ...luginParameterExpressionEvaluatorTest.java | 38 ------------------- 2 files changed, 2 insertions(+), 51 deletions(-) diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java index a373c33d46..8efc45cd21 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/ArtifactUtils.java @@ -68,15 +68,10 @@ public final class ArtifactUtils public static String versionlessKey( Artifact artifact ) { - return versionlessKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier() ); + return versionlessKey( artifact.getGroupId(), artifact.getArtifactId() ); } public static String versionlessKey( String groupId, String artifactId ) - { - return versionlessKey( groupId, artifactId, null ); - } - - public static String versionlessKey( String groupId, String artifactId, String classifier ) { if ( groupId == null ) { @@ -86,13 +81,7 @@ public final class ArtifactUtils { throw new NullPointerException( "artifactId is null" ); } - StringBuilder key = new StringBuilder(); - key.append( groupId ).append( ':' ).append( artifactId ); - if ( classifier != null && !"".equals( classifier.trim() ) ) - { - key.append( ':' ).append( classifier ); - } - return key.toString(); + return groupId + ":" + artifactId; } public static String key( Artifact artifact ) diff --git a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java index aca8afd4d7..5f6744c945 100644 --- a/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java +++ b/maven-core/src/test/java/org/apache/maven/plugin/PluginParameterExpressionEvaluatorTest.java @@ -22,11 +22,9 @@ package org.apache.maven.plugin; import java.io.File; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Set; import org.apache.maven.AbstractCoreMavenComponentTestCase; import org.apache.maven.artifact.Artifact; @@ -382,28 +380,6 @@ public class PluginParameterExpressionEvaluatorTest assertEquals( "testGroup", result.getGroupId() ); } - public void testProjectArtifactMap() - throws Exception - { - Model model = new Model(); - MavenProject project = new MavenProject( model ); - Set artifacts = new HashSet(); - artifacts.add( createArtifact( "testGroup", "testArtifact", "1.0" ) ); - artifacts.add( createArtifact( "testGroup", "testArtifact", "1.0", "testClassifier" ) ); - project.setArtifacts( artifacts ); - ExpressionEvaluator ee = createExpressionEvaluator( project, null, new Properties() ); - - @SuppressWarnings( "unchecked" ) - Map depResults = (Map) ee.evaluate( "${project.artifactMap}" ); - assertEquals( 2, depResults.size() ); - assertNotNull( depResults.get( "testGroup:testArtifact" ) ); - assertNotNull( depResults.get( "testGroup:testArtifact:testClassifier" ) ); - - assertNull( ( (Artifact) ee.evaluate( "${project.artifactMap(testGroup:testArtifact)}" ) ).getClassifier() ); - assertEquals( "testClassifier", - ( (Artifact) ee.evaluate( "${project.artifactMap(testGroup:testArtifact:testClassifier)}" ) ).getClassifier() ); - } - private MavenProject createDefaultProject() { return new MavenProject( new Model() ); @@ -440,20 +416,6 @@ public class PluginParameterExpressionEvaluatorTest return factory.createDependencyArtifact( dependency ); } - protected Artifact createArtifact( String groupId, String artifactId, String version, String classifier ) - throws Exception - { - Dependency dependency = new Dependency(); - dependency.setGroupId( groupId ); - dependency.setArtifactId( artifactId ); - dependency.setVersion( version ); - dependency.setClassifier( classifier ); - dependency.setType( "jar" ); - dependency.setScope( "compile" ); - - return factory.createDependencyArtifact( dependency ); - } - private MojoExecution newMojoExecution() { PluginDescriptor pd = new PluginDescriptor();