The attached patch to the plugin.jelly script for the maven-jar-plugin will
allow you to add arbitrary values to the manifest--complete with sections
which will make the sealing of classes/packages possible.  The new values
are added like this:


maven.jar.manifest.attributes.list = GUIApp-Conf,GUIApp-Instrument,GUIApp-Log
maven.jar.manifest.attribute.GUIApp-Conf = org/d_haven/demoapp/DemoApp.xconf
maven.jar.manifest.attribute.GUIApp-Instrument = org/d_haven/demoapp/DemoApp.instruments
maven.jar.manifest.attribute.GUIApp-Log = org/d_haven/demoapp/DemoApp.xlog


maven.jar.manifest.groups.list = DemoAppConstants,ValidateQuitApplication
maven.jar.manifest.DemoAppConstants.name=org/d_haven/demoapp/DemoAppConstants.class
maven.jar.manifest.DemoAppConstants.attributes.list=Description,Foo
maven.jar.manifest.DemoAppConstants.attribute.Description=It's ok
maven.jar.manifest.DemoAppConstants.attribute.Foo=bar

maven.jar.manifest.ValidateQuitApplication.name=org/d_haven/demoapp/screens/ValidateQuitApplication.class
maven.jar.manifest.ValidateQuitApplication.attributes.list=Description
maven.jar.manifest.ValidateQuitApplication.attribute.Description=We are rockin'

This will add to the Maven generated Manifest like this:

.... skip maven generated content ....
GUIApp-Conf: org/d_haven/demoapp/DemoApp.xconf
GUIApp-Instrument: org/d_haven/demoapp/DemoApp.instruments
GUIApp-Log: org/d_haven/demoapp/DemoApp.xlog

Name: org/d_haven/demoapp/DemoAppConstants.class
Description: It's ok
Foo: bar

Name: org/d_haven/demoapp/screens/ValidateQuitApplication.class
Description: We are rockin'



Please note that all the existing functionality has been preserved.  We are
only adding the ability to add sections and attributes of our own design.
I personally don't like having to specify these things in property format,
but I don't know much about extending the POM so I can't propose a nicer
format.  Anyway, this makes it easy for plugins to add new attributes, etc.

--- plugin.jelly.old    2003-07-14 17:36:46.000000000 -0400
+++ plugin.jelly        2003-09-04 16:44:33.000000000 -0400
@@ -9,7 +9,8 @@
   xmlns:resources="resources"
   xmlns:util="jelly:util"
   xmlns:doc="doc"
-  xmlns:m="maven">
+  xmlns:m="maven"
+  xmlns:log="jelly:log">
 
   <!-- ================================================================== -->
   <!-- J A R                                                              -->
@@ -71,7 +72,6 @@
             <ant:attribute name="Extension-List" value="${extensionList}"/>
           </j:if>
 
-        
           <j:forEach var="artifact" items="${pom.artifacts}">
             <j:set var="dep" value="${artifact.dependency}"/>
                <ant:attribute name="${dep.artifactId}-Extension-Name" 
value="${dep.artifactId}"/>
@@ -79,6 +79,36 @@
             <ant:attribute name="${dep.artifactId}-Implementation-URL" 
value="http://www.ibiblio.org/maven${artifact.urlPath}"/>
           </j:forEach>        
         </j:if>
+
+        <j:if test="${context.getVariable('maven.jar.manifest.attributes.list') != 
null}">
+            <util:tokenize var="attributeList" delim="," 
trim="true">${maven.jar.manifest.attributes.list}</util:tokenize>
+            <j:forEach var="attribute" items="${attributeList}">
+                <j:set var="name" value="maven.jar.manifest.attribute.${attribute}"/>
+                <j:set var="value" value="${context.findVariable(name)}"/>
+                <log:debug>[user attribute] ${attribute}: ${value}</log:debug>
+                <ant:attribute name="${attribute}" value="${value}"/>
+            </j:forEach>
+        </j:if>
+
+        <j:if test="${context.getVariable('maven.jar.manifest.groups.list') != null}">
+            <util:tokenize var="groupList" delim="," 
trim="true">${maven.jar.manifest.groups.list}</util:tokenize>
+            <j:forEach var="group" items="${groupList}">
+                <j:set var="nameVar" value="maven.jar.manifest.${group}.name"/>
+                <j:set var="groupName" value="${context.findVariable(nameVar)}"/>
+                <j:set var="attributeListVar" 
value="maven.jar.manifest.${group}.attributes.list"/>
+                <j:set var="groupAttributes" 
value="${context.findVariable(attributeListVar)}"/>
+                <util:tokenize var="attributeList" delim="," 
trim="true">${groupAttributes}</util:tokenize>
+                <log:debug>[group] Name: ${groupName}</log:debug>
+                <ant:section name="${groupName}">
+                    <j:forEach var="attribute" items="${attributeList}">
+                        <j:set var="name" 
value="maven.jar.manifest.${group}.attribute.${attribute}"/>
+                        <j:set var="value" value="${context.findVariable(name)}"/>
+                        <log:debug>[attribute] ${attribute}: ${value}</log:debug>
+                        <ant:attribute name="${attribute}" value="${value}"/>
+                    </j:forEach>
+                </ant:section>
+            </j:forEach>
+        </j:if>
       </ant:manifest>
     </ant:jar>
   </goal>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to