Version 2

    Using the repository to manage thirdparty jars

    This page provides a build-thirdparty.xml example with targets for generating a thirdparty jar tree and license info based on declarative component dependency statements. To use the thirdparty repository to manage your project thirdparty jars/licenses, you need to use the jbossbuild tasks. To do this:

    • Integrate the tools module into your project. This contains the jbossbuild.jar and tasks.xml. For example, the jbossas jboss-head module alias definition

    jboss-head  -d jboss-head \
    &tools \
    ...
    

    cvs co tools can also be used to pull the content into an existing cvs workspace.

    • Create a build/build-thirdparty.xml similar to the following:

    <?xml version="1.0"?>
    
    <project name="main.build"
              default="synchronize"
              basedir=".">
    
       <!-- Property File definitions -->
       <property file="local.properties"></property>
       <property file="synchronize.properties"></property>
       <property environment="env"></property>
    
       <!-- Property Definitions -->
       <property name="generatedLibrariesFiles" value="../thirdparty/libraries.ent"></property>
    
       <!-- Allow jbossbuild.repository to be set from (in order or priority)
          + Command line -Djbossbuild.repository=...
          + synchronize.properties jbossbuild.repository setting
          + JBOSS_REPOSITORY environment variable
       -->
       <condition property="jbossbuild.repository" value="${env.JBOSS_REPOSITORY}">
          <isset property="env.JBOSS_REPOSITORY"></isset>
       </condition>
       <!-- Fall back to default -->
       <property name="jbossbuild.repository" value="http://repository.jboss.com"></property>
    
       <!-- File Imports -->
       <import file="../tools/etc/jbossbuild/tasks.xml"></import>
    
    
       <!-- Main Definition of dependencies -->
       <build id="jbosscache-thirdparty"
              impltitle="JBossCache"
              implversion="jboss-head"
              implvendor="JBoss Inc."
              implurl="http://www.jboss.org"
              description="JBoss Cache"
              cvsroot="${cvs.prefix}@cvs.forge.jboss.com:/cvsroot/jboss"
              thirdpartypath="../thirdparty/"
              location="${jbossbuild.repository}"
              targetdefs="targets">
    
          <!--
            The repository is in CVS under the module repository.jboss.com whose contents
            are pushed to the http://repository.jboss.com site.
          -->
    
          <componentref name="apache-bsf" version="2.3.0"></componentref>
          <componentref name="apache-log4j" version="1.2.8"></componentref>
          <componentref name="apache-logging" version="1.0.4jboss"></componentref>
          <componentref name="apache-xalan" version="j_2.6.0"></componentref>
          <componentref name="beanshell" version="1.3.0"></componentref>
          <componentref name="javassist" version="3.1RC2"></componentref>
          <componentref name="jfreechart" version="0.9.20"></componentref>
          <componentref name="jgroups" version="2.2.8"></componentref>
          <componentref name="junit" version="3.8.1"></componentref>
          <componentref name="oswego-concurrent" version="1.3.4"></componentref>
          <componentref name="qdox" version="1.4"></componentref>
          <componentref name="sleepycat" version="1.7.0"></componentref>
          <componentref name="trove" version="2.1.1"></componentref>
    
    
       </build>
    
       <synchronizeinfo></synchronizeinfo>
    
       <!-- Generate the targets -->
       <generate generate="jbosscache-thirdparty"></generate>
    
    
       <target name="generate-lib-file"
          description="generate libraries.ent and thirdparty license info"
          depends="synchronize">
             <gen-lib-file filename="${generatedLibrariesFiles}" ></gen-lib-file>
          <visit-componentref-graph
             componentVisitor="org.jboss.ant.util.graph.ComponentRefGraphLicenseVisitor" ></visit-componentref-graph>
       </target>
    
    </project>
    

     

    The default target jbosscache-thirdparty creates a thirdparty directory (../thirdparty relative to the build file) that contains the repository jars declared by the componentref elements. the generate-lib-file target:

    • generates a thirdparty/libraries.ent with the classpath definitions for the various components refs and their dependents. For the above components the following libraries.ent is generated:

    <!-- apache-bsf -->
    <property name="apache.bsf.root" value="${project.thirdparty}/apache-bsf"></property>
    <property name="apache.bsf.lib" value="${apache.bsf.root}/lib/"></property>
    <property name="apache.bsf.resources" value="${apache.bsf.root}/resources/"></property>
    <path id="apache.bsf.classpath">
       <pathelement path="${apache.bsf.lib}/bsf.jar"></pathelement>
    </path>
    
    <!-- apache-log4j -->
    <property name="apache.log4j.root" value="${project.thirdparty}/apache-log4j"></property>
    <property name="apache.log4j.lib" value="${apache.log4j.root}/lib/"></property>
    <property name="apache.log4j.resources" value="${apache.log4j.root}/resources/"></property>
    <path id="apache.log4j.classpath">
       <pathelement path="${apache.log4j.lib}/log4j.jar"></pathelement>
    </path>
    
    <!-- apache-logging -->
    <property name="apache.logging.root" value="${project.thirdparty}/apache-logging"></property>
    <property name="apache.logging.lib" value="${apache.logging.root}/lib/"></property>
    <property name="apache.logging.resources" value="${apache.logging.root}/resources/"></property>
    <path id="apache.logging.classpath">
       <pathelement path="${apache.logging.lib}/commons-logging.jar"></pathelement>
    </path>
    
    <!-- apache-xalan -->
    <property name="apache.xalan.root" value="${project.thirdparty}/apache-xalan"></property>
    <property name="apache.xalan.lib" value="${apache.xalan.root}/lib/"></property>
    <property name="apache.xalan.resources" value="${apache.xalan.root}/resources/"></property>
    <path id="apache.xalan.classpath">
       <pathelement path="${apache.xalan.lib}/xalan.jar"></pathelement>
    </path>
    
    <!-- beanshell -->
    <property name="beanshell.beanshell.root" value="${project.thirdparty}/beanshell"></property>
    <property name="beanshell.beanshell.lib" value="${beanshell.beanshell.root}/lib/"></property>
    <property name="beanshell.beanshell.resources" value="${beanshell.beanshell.root}/resources/"></property>
    <path id="beanshell.beanshell.classpath">
       <pathelement path="${beanshell.beanshell.lib}/bsh-1.3.0.jar"></pathelement>
    </path>
    
    <!-- javassist -->
    <property name="javassist.javassist.root" value="${project.thirdparty}/javassist"></property>
    <property name="javassist.javassist.lib" value="${javassist.javassist.root}/lib/"></property>
    <property name="javassist.javassist.resources" value="${javassist.javassist.root}/resources/"></property>
    <path id="javassist.javassist.classpath">
       <pathelement path="${javassist.javassist.lib}/javassist.jar"></pathelement>
    </path>
    
    <!-- jfreechart -->
    <property name="jfreechart.jfreechart.root" value="${project.thirdparty}/jfreechart"></property>
    <property name="jfreechart.jfreechart.lib" value="${jfreechart.jfreechart.root}/lib/"></property>
    <property name="jfreechart.jfreechart.resources" value="${jfreechart.jfreechart.root}/resources/"></property>
    <path id="jfreechart.jfreechart.classpath">
       <pathelement path="${jfreechart.jfreechart.lib}/jfreechart.jar"></pathelement>
       <pathelement path="${jfreechart.jfreechart.lib}/jcommon.jar"></pathelement>
    </path>
    
    <!-- jgroups -->
    <property name="jgroups.jgroups.root" value="${project.thirdparty}/jgroups"></property>
    <property name="jgroups.jgroups.lib" value="${jgroups.jgroups.root}/lib/"></property>
    <property name="jgroups.jgroups.resources" value="${jgroups.jgroups.root}/resources/"></property>
    <path id="jgroups.jgroups.classpath">
       <pathelement path="${jgroups.jgroups.lib}/jgroups.jar"></pathelement>
    </path>
    
    <!-- junit -->
    <property name="junit.junit.root" value="${project.thirdparty}/junit"></property>
    <property name="junit.junit.lib" value="${junit.junit.root}/lib/"></property>
    <property name="junit.junit.resources" value="${junit.junit.root}/resources/"></property>
    <path id="junit.junit.classpath">
       <pathelement path="${junit.junit.lib}/junit.jar"></pathelement>
    </path>
    
    <!-- oswego-concurrent -->
    <property name="oswego.concurrent.root" value="${project.thirdparty}/oswego-concurrent"></property>
    <property name="oswego.concurrent.lib" value="${oswego.concurrent.root}/lib/"></property>
    <property name="oswego.concurrent.resources" value="${oswego.concurrent.root}/resources/"></property>
    <path id="oswego.concurrent.classpath">
       <pathelement path="${oswego.concurrent.lib}/concurrent.jar"></pathelement>
    </path>
    
    <!-- qdox -->
    <property name="qdox.qdox.root" value="${project.thirdparty}/qdox"></property>
    <property name="qdox.qdox.lib" value="${qdox.qdox.root}/lib/"></property>
    <property name="qdox.qdox.resources" value="${qdox.qdox.root}/resources/"></property>
    <path id="qdox.qdox.classpath">
       <pathelement path="${qdox.qdox.lib}/qdox.jar"></pathelement>
    </path>
    
    <!-- sleepycat -->
    <property name="sleepycat.sleepycat.root" value="${project.thirdparty}/sleepycat"></property>
    <property name="sleepycat.sleepycat.lib" value="${sleepycat.sleepycat.root}/lib/"></property>
    <property name="sleepycat.sleepycat.resources" value="${sleepycat.sleepycat.root}/resources/"></property>
    <path id="sleepycat.sleepycat.classpath">
       <pathelement path="${sleepycat.sleepycat.lib}/je.jar"></pathelement>
    </path>
    
    <!-- trove -->
    <property name="trove.trove.root" value="${project.thirdparty}/trove"></property>
    <property name="trove.trove.lib" value="${trove.trove.root}/lib/"></property>
    <property name="trove.trove.resources" value="${trove.trove.root}/resources/"></property>
    <path id="trove.trove.classpath">
       <pathelement path="${trove.trove.lib}/trove.jar"></pathelement>
    </path>
    
    <!-- list of aliases used to bridge gap between buildmagic defs and jbossbuild -->
    
    
    <path id="apache.commons.classpath">
      <pathelement path="${apache.collections.lib}/commons-collections.jar"></pathelement>
      <pathelement path="${apache.logging.lib}/commons-logging.jar"></pathelement>
      <pathelement path="${apache.httpclient.lib}/commons-httpclient.jar"></pathelement>
      <pathelement path="${apache.pool.lib}/commons-pool.jar"></pathelement>
      <pathelement path="${apache.discovery.lib}/commons-discovery.jar"></pathelement>
      <pathelement path="${apache.fileupload.lib}/commons-fileupload.jar"></pathelement>
      <pathelement path="${apache.lang.lib}/commons-lang-2.0.jar"></pathelement>  
    </path>
    
    <path id="sax.classpath">
      <pathelement path="${xml-sax.classpath}"></pathelement>
    </path>
     
    <property name="xdoclet-xdoclet.lib" value="${xdoclet.xdoclet.lib}"></property>
    <path id="xdoclet.task.classpath">
      <path refid="xdoclet.xdoclet.classpath"></path>
    </path>
       
    <property name="gjt.jpl-util.lib" value="${gjt.jpl.util.lib}"></property>   
    <path id="gjt.jpl-util.classpath">
       <path refid="gjt.jpl.util.classpath"></path>
    </path>   
    
    <property name="opennms.joesnmp.lib" value="${joesnmp.joesnmp.lib}"></property>   
    <path id="opennms.joesnmp.classpath">
       <path refid="joesnmp.joesnmp.classpath"></path>
    </path>   
    
    <path id="jacorb.idl.classpath">
       <path refid="apache.avalon.logkit.classpath"></path>
       <pathelement path="${jacorb.jacorb.lib}/idl.jar"></pathelement>
    </path>
    
    <property name="jacorb.idl.include" value="${jacorb.jacorb.resources}"></property>
    <property name="jacorb.jacorb.properties" value="${jacorb.jacorb.resources}"></property>
      
    <property name="sleepycat.lib" value="${sleepycat.sleepycat.lib}"></property>
    <path id="sleepycat.classpath">
       <path refid="sleepycat.sleepycat.classpath"></path>
    </path>
      
    <property name="apache.tomcat55.root" value="${apache.tomcat.root}"></property>
    <property name="apache.tomcat55.lib" value="${apache.tomcat.lib}"></property>
    <path id="apache.tomcat55.classpath">
       <path refid="apache.tomcat.classpath"></path>
    </path>
      
    <property name="trove.lib" value="${trove.trove.lib}"></property>  
    <path id="trove.classpath">
       <path refid="trove.trove.classpath"></path>
    </path>
      
    <path id="qdox.classpath">
       <path refid="qdox.qdox.classpath"></path>
    </path>
      
    <property name="javassist.lib" value="${javassist.javassist.lib}"></property>
    <path id="javassist.classpath">
      <path refid="javassist.javassist.classpath"></path>
    </path>
      
    <property name="hibernate.lib" value="${hibernate.hibernate.lib}"></property>  
    <path id="hibernate3.classpath">
      <path refid="hibernate.hibernate.classpath"></path>
    </path>
    
    <property name="odmg.lib" value="${odmg.odmg.lib}"></property>
    <path id="odmg.classpath">
      <path refid="odmg.odmg.classpath"></path>
    </path>
    
    <property name="cglib.lib" value="${cglib.cglib.lib}"></property>
    <path id="cglib.classpath">
      <path refid="cglib.cglib.classpath"></path>  
    </path>
    
    <path id="ejb3-persistence.classpath">
       <path refid="hibernate.annotations.classpath"></path>
       <path refid="hibernate.entitymanager.classpath"></path>
    </path>
    
    <property name="spring.lib" value="${spring.spring.lib}"></property>
    <path id="spring.classpath">
      <path refid="spring.spring.classpath"></path>  
    </path>
    
    <!-- Ant -->
    <property name="apache.ant.root" value="${project.tools}"></property>
    <property name="apache.ant.lib" value="${apache.ant.root}/lib"></property>
    <path id="apache.ant.classpath">
      <pathelement path="${apache.ant.lib}/ant.jar"></pathelement>
    </path>
    
    • generate a ../thirdparty/licenses directory that contains all licenses for the thirdparty  components.

    [sstark@sstark build]$ ls ../thirdparty/licenses/
    apache-1.1.txt*  cpl-1.0.txt*    lgpl.txt*          oswego.txt*
    apache-2.0.txt*  ironsmith.txt*  license-info.xml*  thirdparty-licenses.xml*
    
    • generates a ../thirdparty/licenses/thirdparty-licenses.xml summary file that

    <thirdparty-licenses>
         <module name='jgroups'
              licenseType='lgpl'
              version='2.2.8'
              projectHome='http://www.jgroups.org'
              description='JGroups is a toolkit for reliable multicast communication'>
              <jar name='jgroups.jar' ></jar>
         </module>
         <module name='apache-bsf'
              licenseType='apache-1.1'
              version='2.3.0'
              projectHome='http://jakarta.apache.org/bsf/'
              description='no description'>
              <jar name='bsf.jar' ></jar>
         </module>
         <module name='qdox'
              licenseType='ironsmith'
              version='1.4'
              projectHome='http://qdox.codehaus.org/'
              description='Parser for extracting class/interface/method definitions from source files complete with JavaDoc @tags.'>
              <jar name='qdox.jar' ></jar>
         </module>
         <module name='oswego-concurrent'
              licenseType='oswego'
              version='1.3.4'
              projectHome='http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html'
              description='Oswego util.concurrent package'>
              <jar name='concurrent.jar' ></jar>
         </module>
         <module name='beanshell'
              licenseType='lgpl'
              version='1.3.0'
              projectHome='http://www.beanshell.org/'
              description='Lightweight Scripting for Java'>
              <jar name='bsh-1.3.0.jar' ></jar>
         </module>
         <module name='trove'
              licenseType='lgpl'
              version='2.1.1'
              projectHome='http://trove4j.sourceforge.net/'
              description='High performance collections for Java'>
              <jar name='trove.jar' ></jar>
         </module>
         <module name='jfreechart'
              licenseType='lgpl'
              version='0.9.20'
              projectHome='http://www.jfree.org/jfreechart/'
              description='A free Java class library for generating charts, including'>
              <jar name='jfreechart.jar' ></jar>
              <jar name='jcommon.jar' ></jar>
         </module>
         <module name='junit'
              licenseType='cpl-1.0'
              version='3.8.1'
              projectHome='http://www.junit.org/index.htm'
              description='Java unit testing framework'>
              <jar name='junit.jar' ></jar>
         </module>
         <module name='apache-logging'
              licenseType='apache-2.0'
              version='1.0.4jboss'
              projectHome='http://jakarta.apache.org/commons/logging/'
              description='Yet another logging api. Patched to use a WeakHashMap   such that it does not hold hard references to the classloaders.'>
              <jar name='commons-logging.jar' ></jar>
         </module>
         <module name='apache-xalan'
              licenseType='apache-2.0'
              version='j_2.6.0'
              projectHome='http://xml.apache.org/xalan-j/'
              description='Xalan-Java is an XSLT processor for transforming XML documents'>
              <jar name='xalan.jar' ></jar>
         </module>
         <module name='apache-log4j'
              licenseType='apache-2.0'
              version='1.2.8'
              projectHome='http://logging.apache.org/'
              description='Java logging framework'>
              <jar name='log4j.jar' ></jar>
              <jar name='snmpTrapAppender.jar' ></jar>
         </module>
         <module name='javassist'
              licenseType='mozilla-1.0.1.txt'
              version='3.1RC2'
              projectHome='http://sourceforge.net/projects/jboss'
              description='Simple Java bytecode manipulation'>
              <jar name='javassist.jar' ></jar>
         </module>
         <module name='sleepycat'
              licenseType='null'
              version='1.7.0'
              projectHome='http://www.sleepycat.com'
              description='Used for Sleepcat-based CacheLoader (org.jboss.cache.loader.bdbje.BdbjeCacheLoader)'>
              <jar name='je.jar' ></jar>
         </module>
    </thirdparty-licenses>