Slightly improved version of previous version number conversion patch,
submitted by Steven Harris.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@484698 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
index 12f3fb7..e3b83f9 100644
--- a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
+++ b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
@@ -692,16 +692,14 @@
if (!matcher.lookingAt())
return version;
- final StringBuffer sb = new StringBuffer(version.length());
+ // Leave extra space for worst-case additional insertion:
+ final StringBuffer sb = new StringBuffer(version.length() + 4);
sb.append(matcher.group(1));
- int count = 0;
- for ( int i = matcher.groupCount(); i != 0; --i )
- if ( null != matcher.group( i ) )
- ++count;
-
- if ( 3 != count )
- sb.append(versionCompleters[count - 1]);
+ if (null == matcher.group(3)) {
+ final int count = null != matcher.group(2) ? 2 : 1;
+ sb.append(versionCompleters[count - 1]);
+ }
sb.append('.');
sb.append(version.substring(matcher.end(), version.length()));