FELIX-3520: allow groupId to be a prefix of the artifactId without repetition when computing Bundle-SymbolicName
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1342631 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
index a622d78..3bbe15a 100644
--- a/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
+++ b/bundleplugin/src/main/java/org/apache/maven/shared/osgi/DefaultMaven2OsgiConverter.java
@@ -68,6 +68,8 @@
* org.apache.maven:maven -> org.apache.maven</li>
* <li>if artifactId starts with last section of groupId that portion is removed. eg.
* org.apache.maven:maven-core -> org.apache.maven.core</li>
+ * <li>if artifactId starts with groupId then the artifactId is removed. eg.
+ * org.apache:org.apache.maven.core -> org.apache.maven.core</li>
* </ul>
*/
public String getBundleSymbolicName( Artifact artifact )
@@ -128,6 +130,11 @@
{
return artifact.getGroupId();
}
+ if ( artifact.getArtifactId().equals( artifact.getGroupId() )
+ || artifact.getArtifactId().startsWith( artifact.getGroupId() + "." ) )
+ {
+ return artifact.getArtifactId();
+ }
if ( artifact.getArtifactId().startsWith( lastSection ) )
{
String artifactId = artifact.getArtifactId().substring( lastSection.length() );
diff --git a/bundleplugin/src/test/java/org/apache/maven/shared/osgi/Maven2OsgiConverterTest.java b/bundleplugin/src/test/java/org/apache/maven/shared/osgi/Maven2OsgiConverterTest.java
index 3670a6f..340d9a8 100644
--- a/bundleplugin/src/test/java/org/apache/maven/shared/osgi/Maven2OsgiConverterTest.java
+++ b/bundleplugin/src/test/java/org/apache/maven/shared/osgi/Maven2OsgiConverterTest.java
@@ -51,6 +51,11 @@
s = maven2Osgi.getBundleSymbolicName( artifact );
assertEquals( "org.apache.commons.commons-logging", s );
+ artifact.setGroupId( "org.apache" );
+ artifact.setArtifactId( "org.apache.commons-logging" );
+ s = maven2Osgi.getBundleSymbolicName( artifact );
+ assertEquals( "org.apache.commons-logging", s );
+
artifact.setFile( getTestFile( "junit-3.8.2.jar" ) );
artifact.setGroupId( "junit" );
artifact.setArtifactId( "junit" );