From what I have seen, the only way to generate the classpath in a manifest is to generate an EJB jar, wich is an ejb dependency, instead of a jar dependency.
 
I modiifed the jar plugin script based on the article "Maven magic" to include this feature,
 
This classpath can be added in a  way similar to ejb jars.
The folowwing would inlcude the jar in the manifest classpath
 
      <dependency>
        <groupId>dom4j</groupId>
        <artifactId>dom4j</artifactId>
        <version>1.4</version>
        <properties>
              <jar.manifest.classpath>true</jar.manifest.classpath>
        </properties>       
      </dependency>
 
Here is the Jelly script and diff If someone want's to include it in the jar plugin. I include it inline in case the attachment get corrupted/kicked out.
 
I may have to update war file also, let me know if you want the files
 
Thanks
 
=======diff is :
23a24,31
>     <!-- add dependencies to the classpath  -->
>     <j:forEach var="dep" items="${pom.dependencies}">
>       <j:if
>        test="${dep.getProperty('jar.manifest.classpath')=='true'}">
>         <j:set var="maven.jar.classpath"
>                value="${maven.jar.classpath} ${dep.artifact}"/>
>       </j:if>
>     </j:forEach>
44a53
>         <ant:attribute name="Class-Path" value="${maven.jar.classpath}"/>
 
 
=========== modified file
<?xml version="1.0"?>
 
<project
  xmlns:j="jelly:core"
  xmlns:ant="jelly:ant"
  xmlns:license="license"
  xmlns:maven="jelly:maven"
  xmlns:deploy="deploy"
  xmlns:util="jelly:util"
  xmlns:doc="doc">
 
  <!-- ================================================================== -->
  <!-- J A R                                                              -->
  <!-- ================================================================== -->
  <goal name="jar" prereqs="jar:jar"
    description="Create the deliverable jar file."/>
   
  <goal name="jar:jar"
        description="Create the deliverable jar file."
        prereqs="test:test">
 
    <ant:available property="maven.jar.manifest.available"
      file="${maven.jar.manifest}"/>
    <!-- add dependencies to the classpath  -->
    <j:forEach var="dep" items="${pom.dependencies}">
      <j:if
       test="${dep.getProperty('jar.manifest.classpath')=='true'}">
        <j:set var="maven.jar.classpath"
               value="${maven.jar.classpath} ${dep.artifact}"/>
      </j:if>
    </j:forEach>
 
    <!-- See http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html -->
    <!-- See http://java.sun.com/j2se/1.4.1/docs/guide/jar/jar.html -->
    <ant:jar
      jarfile="${maven.build.dir}/${maven.final.name}.jar"
      basedir="${maven.build.dest}"
      index="${maven.jar.index}"
      compress="${maven.jar.compress}"
      excludes="${maven.jar.excludes}">
     
      <j:if test="${maven.jar.manifest.available}">
        <ant:setProperty name="manifest" value="${maven.jar.manifest}" />
      </j:if>
 
      <j:set var="licenseFileName"><license:fileName/></j:set>
      <util:file name="${licenseFileName}" var="licenseFile"/>
      <ant:metainf dir="${licenseFile.canonicalFile.parent}">
        <ant:include name="${licenseFile.canonicalFile.name}"/>
      </ant:metainf>
      <ant:manifest>
        <ant:attribute name="Built-By" value="${user.name}"/>
        <ant:attribute name="Class-Path" value="${maven.jar.classpath}"/>
        <ant:attribute name="Created-By" value="Apache Jakarta Maven"/>
        <ant:attribute name="Package" value="${pom.package}"/>
        <ant:attribute name="Build-Jdk" value="${java.version}"/>
        <!-- added supplementary entries -->
        <ant:attribute name="Extension-Name" value="${pom.artifactId}"/>
        <ant:attribute name="Specification-Version" value="${pom.specificationVersion}"/>
        <ant:attribute name="Specification-Vendor" value="${pom.organization.name}"/>
        <ant:attribute name="Specification-Title" value="${pom.shortDescription}"/>
        <ant:attribute name="Implementation-Version" value="${pom.currentVersion}"/>
        <ant:attribute name="Implementation-Vendor" value="${pom.organization.name}"/>
        <ant:attribute name="Implementation-Vendor-Id" value="${pom.organization.identifier}"/>
        <j:set var="mainclass" value="${pom.getPluginContext('maven-java-plugin').getVariable('maven.jar.mainclass')}"/>
        <j:if test="${!empty(mainclass)}">
            <ant:attribute name="Main-Class" value="${mainclass}"/>
        </j:if>
       
        <j:if test="${maven.jar.manifest.extensions.add == 'true'}">
          <j:set var="extensionList" value=""/>
          <j:forEach var="artifact" items="${pom.artifacts}">
            <j:set var="dep" value="${artifact.dependency}"/>
            <j:set var="extensionList" value="${extensionList} ${dep.artifactId}"/>
          </j:forEach>
 
          <j:if test="${extensionList.length() != 0}">       
            <j:set var="extensionList" value="${extensionList.substring(1)}"/>
            <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}"/>
            <ant:attribute name="${dep.artifactId}-Implementation-Version" value="${dep.version}"/>
            <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)}"/>
                <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>
                <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)}"/>
                        <ant:attribute name="${attribute}" value="${value}"/>
                    </j:forEach>
                </ant:section>
            </j:forEach>
         </j:if>
      </ant:manifest>
    </ant:jar>
  </goal>
 
  <!-- ================================================================== -->
  <!-- S N A P S H O T  J A R                                             -->
  <!-- ================================================================== -->
 
  <goal
    name="jar:snapshot"
    description="Create a snapshot jar, ie 'id-YYYYMMDD.hhmmss.jar'">
 
    <maven:snapshot project="${pom}"/>   
 
    <j:set var="maven.final.name" value="${snapshotSignature}"/>
    <ant:echo>Building snapshot JAR: ${maven.final.name}</ant:echo>
   
    <attainGoal name="jar:jar"/>
   
  </goal>
 
  <!-- ================================================================== -->
  <!-- D E P L O Y  S N A P S H O T                                       -->
  <!-- ================================================================== -->
 
  <goal
    name="jar:deploy-snapshot"
    description="Deploy a snapshot jar to the remote repository">
 
    <maven:user-check user="${maven.username}"/>
    <attainGoal name="jar:snapshot"/>
    <ant:property name="maven.jar.to.deploy" value="${maven.final.name}.jar"/>
    <ant:property name="dir"
      value="${maven.repo.central.directory}/${pom.artifactDirectory}/jars"/>
   
    <util:replace var="jarToDeploy" oldChar="\" newChar="/">${maven.build.dir}/${maven.jar.to.deploy}</util:replace>
    <util:replace var="forwardSlashBaseDir" oldChar="\" newChar="/" value="${basedir}"/>
    <j:if test="${!forwardSlashBaseDir.endsWith('/')}">
      <j:set var="base" value="${forwardSlashBaseDir}/" />
    </j:if>
    <j:set var="relativePath">${jarToDeploy.substring(base.length())}</j:set>
   
    <deploy:artifact
      artifact="${relativePath}"
      type="jars"
      assureDirectoryCommand="mkdir -p"
      siteCommand="cd @deployDirectory@; chmod g+w ${maven.jar.to.deploy}; chgrp ${maven.remote.group} ${maven.jar.to.deploy}; ln -sf ${maven.jar.to.deploy} ${pom.artifactId}-SNAPSHOT.jar; echo ${snapshotVersion} > ${pom.artifactId}-snapshot-version"
    />
                   
  </goal>
 
  <!-- ================================================================== -->
  <!-- D E P L O Y  J A R                                                 -->
  <!-- ================================================================== -->
 
  <goal
    name="jar:deploy"
    description="Deploy a jar to the remote repository">
 
    <maven:user-check user="${maven.username}"/>
    <attainGoal name="jar:jar"/>
    <ant:property name="maven.jar.to.deploy" value="${maven.final.name}.jar"/>
   
    <j:set var="sl" value="/"/>
    <util:replace var="jarToDeploy" oldChar="\" newChar="/">${maven.build.dir}/${maven.jar.to.deploy}</util:replace>
    <util:replace var="forwardSlashBaseDir" oldChar="\" newChar="/" value="${basedir}"/>
    <j:if test="${!forwardSlashBaseDir.endsWith('/')}">
      <j:set var="base" value="${forwardSlashBaseDir}/" />
    </j:if>
    <j:set var="relativePath">${jarToDeploy.substring(base.length())}</j:set>
 
    <deploy:artifact
      artifact="${relativePath}"
      type="jars"
      assureDirectoryCommand="mkdir -p"
      siteCommand="cd @deployDirectory@; chmod g+w ${maven.jar.to.deploy}; chgrp ${maven.remote.group} ${maven.jar.to.deploy}"
    />
 
  </goal>
 
  <!-- ================================================================== -->
  <!-- I N S T A L L   J A R                                              -->
  <!-- ================================================================== -->
 
  <goal name="jar:install" prereqs="jar:jar"
    description="Install the jar in the local repository">
   
    <ant:echo>
    id = '${pom.artifactId}'
    groupId = '${pom.groupId}'
    artifactDirectory = '${pom.artifactDirectory}'
    </ant:echo>
   
    <ant:property name="jardir__" value="${maven.repo.local}/${pom.artifactDirectory}/jars"/>
    <ant:mkdir dir="${jardir__}"/>   
    <ant:copy
      file="${maven.build.dir}/${maven.final.name}.jar"
      todir="${jardir__}"
      overwrite="true"
    />
  </goal>
 
  <!-- ================================================================== -->
  <!-- I N S T A L L  S N A P S H O T                                       -->
  <!-- ================================================================== -->
 
  <goal
    name="jar:install-snapshot" prereqs="jar:snapshot"
    description="Install a snapshot jar in the local repository">
 
    <ant:property name="jardir__" value="${maven.repo.local}/${pom.artifactDirectory}/jars"/>
    <ant:mkdir dir="${jardir__}"/>
    <ant:copy
      file="${maven.build.dir}/${maven.final.name}.jar"
      tofile="${jardir__}/${pom.artifactId}-SNAPSHOT.jar"
      overwrite="true"
    />
    <ant:copy
      file="${maven.build.dir}/${maven.final.name}.jar"
      tofile="${jardir__}/${maven.final.name}.jar"
    />
  </goal>
</project>
 
 
 
 

<<ebCard JM.gif>>

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

Reply via email to