maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r1508437 - in /maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util: DashClassifierValueSource.java MappingUtils.java
Date Tue, 30 Jul 2013 13:47:46 GMT
Author: dennisl
Date: Tue Jul 30 13:47:45 2013
New Revision: 1508437

URL: http://svn.apache.org/r1508437
Log:
Refactoring: extract class.

Added:
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/DashClassifierValueSource.java
  (with props)
Modified:
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/MappingUtils.java

Added: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/DashClassifierValueSource.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/DashClassifierValueSource.java?rev=1508437&view=auto
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/DashClassifierValueSource.java
(added)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/DashClassifierValueSource.java
Tue Jul 30 13:47:45 2013
@@ -0,0 +1,64 @@
+package org.apache.maven.plugin.war.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Properties;
+
+import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
+
+/**
+ * This is a ValueSource, that can be used in an Interpolator. It supports
+ * special expressions, like <code>dashClassifier</code> and
+ * <code>dashClassifier?</code>.
+ *
+ * @version $Id$
+ * @since 2.5
+ */
+public class DashClassifierValueSource
+    extends PropertiesBasedValueSource
+{
+    /**
+     * Create the ValueSource.
+     *
+     * @param classifier The classifier that should be used during interpolation
+     */
+    public DashClassifierValueSource( String classifier )
+    {
+        super( createDashClassifierProperties( classifier ) );
+    }
+
+    private static Properties createDashClassifierProperties( String classifier )
+    {
+        Properties classifierMask = new Properties();
+        classifierMask.setProperty( "classifier", "" );
+
+        if ( classifier != null )
+        {
+            classifierMask.setProperty( "dashClassifier?", "-" + classifier );
+            classifierMask.setProperty( "dashClassifier", "-" + classifier );
+        }
+        else
+        {
+            classifierMask.setProperty( "dashClassifier?", "" );
+            classifierMask.setProperty( "dashClassifier", "" );
+        }
+        return classifierMask;
+    }
+}

Propchange: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/DashClassifierValueSource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/DashClassifierValueSource.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author Id

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/MappingUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/MappingUtils.java?rev=1508437&r1=1508436&r2=1508437&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/MappingUtils.java
(original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/util/MappingUtils.java
Tue Jul 30 13:47:45 2013
@@ -65,36 +65,21 @@ public class MappingUtils
         String value = expression;
 
         // FIXME: This is BAD! Accessors SHOULD NOT change the behavior of the object.
+        // [dennisl; 2013-07-30] This was fixed in Maven 2.0.8
         artifact.isSnapshot();
 
         RegexBasedInterpolator interpolator = new RegexBasedInterpolator( "\\@\\{(", ")?([^}]+)\\}@"
);
         interpolator.addValueSource( new ObjectBasedValueSource( artifact ) );
         interpolator.addValueSource( new ObjectBasedValueSource( artifact.getArtifactHandler()
) );
 
-        Properties classifierMask = new Properties();
-        classifierMask.setProperty( "classifier", "" );
-
         // Support for special expressions, like @{dashClassifier?}@, see MWAR-212
-        String classifier = artifact.getClassifier();
-        if ( classifier != null )
-        {
-            classifierMask.setProperty( "dashClassifier?", "-" + classifier );
-            classifierMask.setProperty( "dashClassifier", "-" + classifier );
-        }
-        else
-        {
-            classifierMask.setProperty( "dashClassifier?", "" );
-            classifierMask.setProperty( "dashClassifier", "" );
-        }
-
-        interpolator.addValueSource( new PropertiesBasedValueSource ( classifierMask ) );
+        interpolator.addValueSource( new DashClassifierValueSource( artifact.getClassifier()
) );
 
         value = interpolator.interpolate( value, "__artifact" );
 
         return value;
     }
 
-
     /**
      * Internal implementation of {@link ValueSource}
      */



Mime
View raw message