You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by fg...@apache.org on 2006/10/09 22:29:14 UTC

svn commit: r454493 - in /maven/plugins/trunk/maven-eclipse-plugin/src: main/java/org/apache/maven/plugin/eclipse/ main/java/org/apache/maven/plugin/eclipse/writers/ test/java/org/apache/maven/plugin/eclipse/writers/

Author: fgiust
Date: Mon Oct  9 13:29:13 2006
New Revision: 454493

URL: http://svn.apache.org/viewvc?view=rev&rev=454493
Log:
MECLIPSE-140 SNAPSHOT plugin versions are not supported for PDE projects.

Added:
    maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/
    maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriterTest.java   (with props)
Modified:
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSourceDir.java
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSourceDir.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSourceDir.java?view=diff&rev=454493&r1=454492&r2=454493
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSourceDir.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseSourceDir.java Mon Oct  9 13:29:13 2006
@@ -43,11 +43,11 @@
      */
     public EclipseSourceDir( String path, String output, boolean test, String include, String exclude )
     {
-        this(path, output, test, false, include, exclude);
+        this( path, output, test, false, include, exclude );
     }
 
-
-    public EclipseSourceDir( String path, String output, boolean isResource, boolean test, String include, String exclude )
+    public EclipseSourceDir( String path, String output, boolean isResource, boolean test, String include,
+                             String exclude )
     {
         this.path = path;
         this.output = output;
@@ -160,6 +160,15 @@
     public void setTest( boolean test )
     {
         this.test = test;
+    }
+
+    /**
+     * Getter for <code>isResource</code>.
+     * @return Returns the isResource.
+     */
+    public boolean isResource()
+    {
+        return this.isResource;
     }
 
     /**

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java?view=diff&rev=454493&r1=454492&r2=454493
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriter.java Mon Oct  9 13:29:13 2006
@@ -26,6 +26,7 @@
 import org.apache.maven.plugin.eclipse.Messages;
 import org.apache.maven.plugin.ide.IdeDependency;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * The <code>EclipseOSGiManifestWriter</code> ensures that value of the "Bundle-Classpath" property 
@@ -177,6 +178,38 @@
         // OSGi manifest headers need to end with a line break
         manifestSb.append( NEWLINE );
         return manifestSb;
+    }
+
+    /**
+     * Normalize a version number, by moving snapshot identifier to the 5th token (first 4 tokens must be numeric for
+     * OSGI bundles)
+     * @param version original version
+     * @return a normalized version number
+     */
+    protected static String getNormalizedVersion( String version )
+    {
+
+        if ( version.endsWith( "-SNAPSHOT" ) )
+        {
+            String[] versionTokens = StringUtils.split( StringUtils.stripEnd( version, "-SNAPSHOT" ), "." );
+
+            int j = 0;
+            StringBuffer newVersion = new StringBuffer( 20 );
+            for ( ; j < versionTokens.length; j++ )
+            {
+                newVersion.append( versionTokens[j] );
+                newVersion.append( "." );
+            }
+            for ( ; j < 3; j++ )
+            {
+                newVersion.append( "0." );
+            }
+
+            newVersion.append( "SNAPSHOT" );
+            version = newVersion.toString();
+
+        }
+        return version;
     }
 
     /**

Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriterTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriterTest.java?view=auto&rev=454493
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriterTest.java (added)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriterTest.java Mon Oct  9 13:29:13 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.maven.plugin.eclipse.writers;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Fabrizio Giustina
+ * @version $Id$
+ */
+public class EclipseOSGiManifestWriterTest
+    extends TestCase
+{
+    /**
+     * Test normalization of a 2 digits snapshot version
+     */
+    public void testGetNormalizedVersionTwoDigitsSnapshot()
+    {
+        assertEquals( "2.1.0.SNAPSHOT", EclipseOSGiManifestWriter.getNormalizedVersion( "2.1-SNAPSHOT" ) );
+    }
+
+    /**
+     * Test normalization of a 3 digits snapshot version
+     */
+    public void testGetNormalizedVersionThreeDigitsSnapshot()
+    {
+        assertEquals( "2.1.3.SNAPSHOT", EclipseOSGiManifestWriter.getNormalizedVersion( "2.1.3-SNAPSHOT" ) );
+    }
+
+    /**
+     * Test normalization of a 4 digits snapshot version
+     */
+    public void testGetNormalizedVersionFourDigitsSnapshot()
+    {
+        assertEquals( "2.1.3.0.SNAPSHOT", EclipseOSGiManifestWriter.getNormalizedVersion( "2.1.3.0-SNAPSHOT" ) );
+    }
+}

Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriterTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseOSGiManifestWriterTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain