jicarilla-sandbox/buildsystem README.txt,NONE,1.1 gump-template.xml,NONE,1.1 build-project.xml,1.14,1.15 jbs-init.sh,1.1,1.2

[email protected]
Newsgroups gmane.comp.java.jicarilla.cvs
Message-ID <[email protected]>
Update of /cvsroot/jicarilla/jicarilla-sandbox/buildsystem
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27852/buildsystem

Modified Files:
	build-project.xml jbs-init.sh 
Added Files:
	README.txt gump-template.xml 
Log Message:
automate gump integration, add some docs

--- NEW FILE: README.txt ---
Basics
======
To start a project that uses JBS, create a build.xml that looks like the
following:

build.xml sample
----------------
    <?xml version="1.0"?>

    <project default="jar:install-snapshot" name="JBS-based build" basedir=".">
        <property file="project.properties"/>
        <property name="jbs.home" value="${user.home}/.jbs"/>
        <import file="${jbs.home}/build-project.xml"/>
    </project>

Next, create a file named project.properties that contains the name for
your project as the value for a project.name:

project.properties sample
-------------------------
project.name = myproject

That's it!

Dependencies
============
if your project has any compile or runtime dependencies, create a text file
named dependencies.list. This file contains lines of dependencies. Each
line has several fields that are space-seperated. You can create comments
on empty lines by starting the line with '#' or '//' or a space. Empty lines
are also allowed.
The recognized fields are as follows:

artifact-id [version [group-id [repository [gump-id [opts]]]]]

artifact-id:        the name of the jar
version:            the version of the jar required. Defaults to SNAPSHOT.
group-id:           the group the jar belongs to. Defaults to whatever
                    you set for the artifact id.
repository          the remote (maven-compatible) repository from which the
                    jar can be fetched. Defaults to the repository maintained
                    at ibiblio.
gump-id             the name of the project to depend on during gump
                    integration. Defaults to whatever you set for the artifact
                    id. Use a value of "SKIP" if this dependency should not
                    be included during gump testing.
opts                A comma-seperated list (no spaces allowed!) of options
                    to apply to the dependency (only used during gump
                    integration right now). Options include:

        runtime     to indicate this is a runtime dependency (otherwise it is
                    assumed this is a compile-time dependency only)
        optional    to indicate the project will compile and run without this
                    dependency (otherwise it is considered non-optional)
        inherit     to indicate the inheritance policy to apply during gump
                    integration. If only the keyword is given, a value of "all"
                    is assumed. If no keyword is given, a value of "none" is
                    assumed. You can specify what policy to apply by using
                    an "=" followed by the policy (without spaces), like this:

                    inherit=jars

                    possible values include "all","jars","none","hard" and
                    "runtime"

While everything after the last field is ignored, you should not depend on this
behaviour, and not place any comments or other stuff there, because new fields
may be added in the future.

For example, if your project depends on commons-collections version 1.0 and
uses it during runtime as well (and you are okay with the jar being downloaded
from ibiblio if it doesn't exist in your local repository yet, add a line like
the following:

commons-collections 1.0 - - - runtime,inherit=runtime

If your project depends on the picocontainer tck and you want to grab it from
the dist.codehaus.org repository, add a line like this:

picocontainer-tck SNAPSHOT picocontainer http://dist.codehaus.org SKIP

(you need to use SKIP because picocontainer does not participate in gump
integration. Your project will probably fail during gump integration as a
result).

Gump integration
================
JBS can generate a gump descriptor for your project. To create one, create
your dependencies.list file, and make sure all the gump-specific fields are
correct as well. Then, invoke ant with the 'jbs:gump-descriptor' target:

    ant jbs:gump-descriptor

this will create a file named gump-${project.name}.xml. Include this file from
your main module definition (which you'll need to write by hand).

Overriding JBS behaviour
========================
You can override any part of the JBS default behaviour by defining targets in
your build.xml with the same names as the JBS targets. For example, if you
want to change how the 'compile' functionality works, define a new target
in your buildfile named 'jbs:java-compile':

<?xml version="1.0"?>

<project default="jar:install-snapshot" name="JBS-based build" basedir=".">
    <property file="project.properties"/>
    <property name="jbs.home" value="${user.home}/.jbs"/>
    <import file="${jbs.home}/build-project.xml"/>

    <target name="jbs:java-compile" if="java.src.present"
            depends="jbs:init,jbs:get-dependencies">
        <echo>=======================================================================
   Compiling Sources for ${project.name} (CUSTOM TARGET!)
=======================================================================</echo>

        <!-- we want to apply a commonly used trick: filter copyright info -->
        <mkdir dir="${jbs.build.dir}"/>
        <mkdir dir="${jbs.build.dir}/classes"/>
        <mkdir dir="${jbs.build.dir}/src/java"/>

        <tstamp>
            <format property="copyright.year" pattern="yyyy"/>
        </tstamp>
        <copy todir="${jbs.build.dir}/src/java">
            <fileset dir="${jbs.src.dir}/java"/>
            <filterset>
                <filter token="COYYRIGHTYEAR" value="1997-${copyright.year}"/>
                <filter token="COYYRIGHTHOLDER" value="The Apache Software Foundation"/>
            </filterset>
        </copy>

        <javac
                destdir="${jbs.build.dir}/classes"
                excludes="**/package.html"
                debug="${jbs.compile.debug}"
                deprecation="${jbs.compile.deprecation}"
                optimize="${jbs.compile.optimize}">

            <src>
                <!-- use the filtered sources -->
                <pathelement path="${jbs.build.dir}/src/java"/>
            </src>
            <classpath>
                <pathelement path="${dependency.classpath}"/>
            </classpath>
        </javac>
    </target>
</project>

This is a quite advanced technique, and I advise caution before using it. It's
also subject to breakage as JBS evolves. But its the only real alternative to
maven's <pregoal/> and <postgoal/> functionality at the moment.
--- NEW FILE: gump-template.xml ---
<?xml version="1.0"?>

<!-- This descriptor was autogenerated by the Jicarilla Build System -->

<project name="${project.name}">
    <package>${project.package}</package>
    <ant basedir="${project.dir}" target="${project.gump.target}">
        <property name="project.version" value="@@DATE@@"/>
    </ant>

    <!-- common dependencies -->
    <depend project="ant" inherit="runtime"/>
    <depend project="xml-xalan2"/><!-- support for <junitreport/> -->
    <depend project="xml-xerces"/>

    <!-- project dependencies -->
${project.dependencies}

    <work nested="${project.dir}/target/classes"/>
    <work nested="${project.dir}/target/test-classes"/>

    <home nested="${project.dir}"/>
    <jar name="target/${project.name}-@@DATE@@.jar"/>
    <javadoc nested="${project.dir}/target/docs/apidocs"/>
    <junitreport nested="${project.dir}/target/docs/junitreports"/>

    <nag from="Gump Integration Build &lt;[email protected]&gt;"
            to="[email protected]"/>
</project>
Index: build-project.xml
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/buildsystem/build-project.xml,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- build-project.xml	22 Feb 2004 20:32:59 -0000	1.14
+++ build-project.xml	23 Feb 2004 21:38:32 -0000	1.15
@@ -493,8 +493,8 @@
         <!--
 file format:
 
-$artifact [$version [$group [$repository]]] [everything after the fourth space is ignored]\n
-$artifact [$version [$group [$repository]]] [everything after the fourth space is ignored]
+$artifact [$version [$group [$repository]]]
+$artifact [$version [$group [$repository]]]
 // this is a comment
 # this is also a comment
  this is also a
@@ -552,15 +552,15 @@
 
               artifact = dependency[0];
               version = "SNAPSHOT";
-              if( dependency.length > 1 )
+              if( dependency.length > 1 && dependency[1] != "-" )
                   version = dependency[1];
 
               group = artifact;
               repository = defaultRepository;
-              if(dependency.length > 2 )
+              if(dependency.length > 2 && dependency[2] != "-" )
               {
                 group = dependency[2];
-                if( dependency.length > 3 )
+                if( dependency.length > 3 && dependency[3] != "-" )
                 {
                   repository = dependency[3];
                 }
@@ -648,8 +648,8 @@
         <!--
 file format:
 
-$artifact $version [$group [$repository]] [everything after the fourth space is ignored]\n
-$artifact $version [$group [$repository]] [everything after the fourth space is ignored]
+$artifact $version [$group [$repository]]
+$artifact $version [$group [$repository]]
 // this is a comment
 # this is also a comment
  this is also a
@@ -668,7 +668,6 @@
             basedir = project.getProperty("basedir");
             sep = System.getProperty("file.separator");
             dependencyFilename = basedir + sep + "dependencies.list";
-            System.out.println( "Getting: " + dependencyFilename );
 
             loadfile = project.createTask("loadfile");
             loadfile.setProperty("jbs.dependencies.file");
@@ -699,11 +698,11 @@
 
               artifact = dependency[0];
               version = "SNAPSHOT";
-              if( dependency.length > 1 )
+              if( dependency.length > 1 && dependency[1] != "-" )
                   version = dependency[1];
 
               group = artifact;
-              if(dependency.length > 2 )
+              if(dependency.length > 2 && dependency[2] != "-" )
               {
                 group = dependency[2];
               }
@@ -750,4 +749,137 @@
                 file="${jbs.build.dir}/${project.name}-${project.version}.jar"/>
     </target>
 
+    <!-- Gump descriptor -->
+
+    <target name="jbs:gump-descriptor" depends="jbs:init">
+        <echo>=======================================================================
+   Creating gump descriptor for ${project.name}
+=======================================================================
+ The descriptor will be generated as gump-${project.name}.xml. You may
+ want to do some hand-editing before renaming it to gump.xml (or moving
+ it elsewhere). If you want to automate the editing of the file (or publish
+ it somewhere), define a target named "customize-gump-descritor" in your
+ project buildfile.</echo>
+
+        <!--
+file format:
+
+$artifact $version [$group [$repository [$gumpproject [$gumpopts]]]]
+        -->
+        <property name="project.gump.target" value="jar"/>
+
+        <loadfile property="jbs.cvs.repository" srcFile="CVS/Repository">
+            <filterchain>
+                <striplinebreaks/>
+            </filterchain>
+        </loadfile>
+        <script language="javascript">
+        <![CDATA[
+            importClass(java.lang.System);
+            importClass(java.lang.Character);
+
+            basedir = project.getProperty("basedir");
+            sep = System.getProperty("file.separator");
+            dependencyFilename = basedir + sep + "dependencies.list";
+
+            loadfile = project.createTask("loadfile");
+            loadfile.setProperty("jbs.dependencies.file");
+            loadfile.setSrcFile( new java.io.File( dependencyFilename ) );
+            loadfile.execute();
+
+            dependencyFile = project.getProperty("jbs.dependencies.file");
+            localRepository = project.getProperty("jbs.repository.local");
+            libDir = project.getProperty("jbs.build.dist.lib.dir");
+
+            dependencies = dependencyFile.split( "(\n|\r|\r\n)" );
+
+            hash = new Character("#".charAt(0));
+            space = new Character(" ".charAt(0));
+            slash = new Character("/".charAt(0));
+
+            depString = "";
+
+            for( i=0; i < dependencies.length; i++ )
+            {
+              if( dependencies[i].length() == 0 ||
+                  hash.equals( new Character( dependencies[i].charAt(0) ) ) ||
+                  dependencies[i].charAt(0) == space ||
+                  (dependencies[i].length() > 1 && dependencies[i].charAt(0) == slash && dependencies[i].charAt(1) == slash) )
+              {
+                continue; // blank line or comment
+              }
+
+              dependency = dependencies[i].split(" ");
+
+              artifact = dependency[0];
+              version = "SNAPSHOT";
+              if( dependency.length > 1 && dependency[1] != "-" )
+                  version = dependency[1];
+
+              group = artifact;
+              if(dependency.length > 2 && dependency[2] != "-" )
+              {
+                group = dependency[2];
+              }
+
+              gumpProject = artifact;
+              if(dependency.length > 4 && dependency[4] != "-" )
+              {
+                gumpProject = dependency[4];
+                if(gumpProject == "SKIP")
+                    continue;
+              }
+
+              runtime="false";
+              inherit="none";
+              optional="false";
+              if(dependency.length > 5 && dependency[5] != "-" )
+              {
+                opts = dependency[5];
+                if( opts.indexOf( "runtime" ) != -1 )
+                    runtime = "true";
+                if( opts.indexOf( "inherit" ) != -1 )
+                {
+                    if( opts.indexOf( "inherit=all" ) != -1 )
+                        inherit = "all";
+                    else if( opts.indexOf( "inherit=runtime" ) != -1 )
+                        inherit = "runtime";
+                    else if( opts.indexOf( "inherit=jars" ) != -1 )
+                        inherit = "jars";
+                    else if( opts.indexOf( "inherit=hard" ) != -1 )
+                        inherit = "hard";
+                    else if( opts.indexOf( "inherit=none" ) != -1 )
+                        inherit = "none";
+                    else
+                        inherit = "all"; // default
+                }
+                if( opts.indexOf( "optional" ) != -1 )
+                    optional="true";
+              }
+
+              depString += '    <dependency name="' + gumpProject + '" runtime="' + runtime + '" inherit="' + inherit +'" optional="' + optional + '"/>\n';
+            }
+
+            project.setProperty( "project.dependencies", depString );
+            repo = project.getProperty( "jbs.cvs.repository" );
+            path = repo.substring( repo.indexOf(sep)+1 );
+
+            project.setProperty( "project.dir", path );
+        ]]>
+        </script>
+        
+        <loadfile property="jbs.gump.template" srcFile="${jbs.home}/gump-template.xml">
+            <filterchain>
+                <expandproperties/>
+            </filterchain>
+        </loadfile>
+        <echo file="gump-${project.name}.xml">${jbs.gump.template}</echo>
+        <echo>Gump descriptor generated successfully!</echo>
+        <antcall target="customize-gump-descriptor"/>
+    </target>
+    <target name="customize-gump-descriptor"/><!-- here to be overridden -->
+
+    <target name="jbs:gump-module-descriptor" depends="jbs:init">
+
+    </target>
 </project>
\ No newline at end of file

Index: jbs-init.sh
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/buildsystem/jbs-init.sh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- jbs-init.sh	12 Feb 2004 16:16:39 -0000	1.1
+++ jbs-init.sh	23 Feb 2004 21:38:32 -0000	1.2
@@ -4,6 +4,6 @@
 mv build-project.xml build.xml
 echo '# Dependencies (test file)
 #
-# artifact-id [version [groupid [repository [comment]]]]
+# artifact-id [version [groupid [repository [gump-id [gump-opts]]]]]
 #
 ' > dependencies.list



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.