cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r470225 - in /incubator/cxf/trunk: codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/ common/common/src/main/java/org/apache/cxf/common/util/ common/common/src/test/java/org/apache/cxf/common/util/
Date Thu, 02 Nov 2006 04:26:00 GMT
Author: mmao
Date: Wed Nov  1 20:25:59 2006
New Revision: 470225

URL: http://svn.apache.org/viewvc?view=rev&rev=470225
Log:
Eclipse-plugin update

* The eclipse plugin version can not have characters, it must compatible with format digital.digital.[ditital]
format.

Modified:
    incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java
    incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java

Modified: incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java?view=diff&rev=470225&r1=470224&r2=470225
==============================================================================
--- incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java
(original)
+++ incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java
Wed Nov  1 20:25:59 2006
@@ -89,8 +89,7 @@
         baseDir = new File(targetDirectory, project.getGroupId() + "_" + project.getVersion());
         libPath = new File(baseDir, LIB_PATH);
         zipFile = new File(targetDirectory, project.getGroupId() + "_" + project.getVersion()
+ ".zip");
-
-        // TODO: reuse the file create/detele in tools.
+     
         if (baseDir.exists()) {
             FileUtils.removeDir(baseDir);
         }
@@ -184,6 +183,10 @@
     private String getVelocityLogFile(String log) {
         return new File(targetDirectory, log).toString();
     }
+    
+    private String getVersion() {
+        return StringUtils.formatVersionNumber(project.getVersion());
+    }
 
     // TODO: Reuse the velocity in the tools 
     private void initVelocity() throws Exception {
@@ -208,7 +211,7 @@
 
         VelocityContext ctx = new VelocityContext();
         ctx.put("ECLIPSE_VERSION", "3.0");
-        ctx.put("PLUGIN_VERSION", project.getVersion());
+        ctx.put("PLUGIN_VERSION", getVersion());
         ctx.put("GROUP_ID", project.getGroupId());
         ctx.put("libPath", LIB_PATH);
         ctx.put("jars", jars);

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java?view=diff&rev=470225&r1=470224&r2=470225
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/StringUtils.java
Wed Nov  1 20:25:59 2006
@@ -139,6 +139,18 @@
         return str;
     }
     
+    public static String getFirstNotEmpty(List<String> list) {
+        if (isEmpty(list)) {
+            return null;
+        }
+        for (String item : list) {
+            if (!isEmpty(item)) {
+                return item;
+            }       
+        }
+        return null;
+    }
+    
     public static List<String> getFound(String contents, String regex) {
         if (isEmpty(regex) || isEmpty(contents)) {
             return null;
@@ -156,4 +168,12 @@
         }
         return results;
     } 
+    
+    public static String formatVersionNumber(String target) {
+        List<String> found = StringUtils.getFound(target, "\\d+\\.\\d+\\.?\\d*");
+        if (isEmpty(found)) {
+            return target;
+        }
+        return getFirstNotEmpty(found);
+    }
 }

Modified: incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java?view=diff&rev=470225&r1=470224&r2=470225
==============================================================================
--- incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
(original)
+++ incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/StringUtilsTest.java
Wed Nov  1 20:25:59 2006
@@ -59,4 +59,9 @@
         assertFalse(StringUtils.isEmpty(StringUtils.getFound("velocity-1.4.jar", regex)));
         assertTrue(StringUtils.isEmpty(StringUtils.getFound(null, regex)));
     }
+    
+    public void testFormatVersionNumber() throws Exception {
+        assertEquals("2.0", StringUtils.formatVersionNumber("2.0-incubator-M1-SNAPSHOT"));
+        assertEquals("2.0.12", StringUtils.formatVersionNumber("2.0.12-incubator-M1-SNAPSHOT"));
+    }
 }



Mime
View raw message