This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git


The following commit(s) were added to refs/heads/master by this push:
     new ea0691e  [FELIX-6494] add version to Created-By entry
     new 09025c6  Merge pull request #125 from hboutemy/FELIX-6494
ea0691e is described below

commit ea0691e1174762c2cfdea43eb009d787aba6092e
Author: HervĂ© Boutemy <[email protected]>
AuthorDate: Thu Dec 30 16:24:48 2021 +0100

    [FELIX-6494] add version to Created-By entry
---
 .../apache/felix/bundleplugin/BundlePlugin.java    | 28 +++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git 
a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
 
b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
index 3a8117f..b3575f7 100644
--- 
a/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
+++ 
b/tools/maven-bundle-plugin/src/main/java/org/apache/felix/bundleplugin/BundlePlugin.java
@@ -1139,7 +1139,8 @@ public class BundlePlugin extends AbstractMojo
             }
 
             Attributes mainMavenAttributes = mavenManifest.getMainAttributes();
-            mainMavenAttributes.putValue( "Created-By", "Apache Maven Bundle 
Plugin" );
+            mainMavenAttributes.putValue( "Created-By", createdBy( "Apache 
Maven Bundle Plugin", "org.apache.felix",
+                                                                   
"maven-bundle-plugin" ) );
 
             String[] removeHeaders = builder.getProperty( 
Constants.REMOVEHEADERS, "" ).split( "," );
 
@@ -1215,6 +1216,31 @@ public class BundlePlugin extends AbstractMojo
         builder.setJar( jar );
     }
 
+    private static String getCreatedByVersion( String groupId, String 
artifactId )
+    {
+        try
+        {
+            final Properties properties = PropertyUtils.loadProperties( 
MavenArchiver.class.getResourceAsStream(
+                "/META-INF/maven/" + groupId + "/" + artifactId + 
"/pom.properties" ) );
+    
+            return properties.getProperty( "version" );
+        }
+        catch ( IOException ioe )
+        {
+            return null;
+        }
+    }
+
+    private String createdBy( String description, String groupId, String 
artifactId )
+    {
+        String createdBy = description;
+        String version = getCreatedByVersion( groupId, artifactId );
+        if ( version != null )
+        {
+            createdBy += " " + version;
+        }
+        return createdBy;
+    }
 
     protected static void mergeManifest( Instructions instructions, 
Manifest... manifests ) throws IOException
     {

Reply via email to