commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Libbrecht <>
Subject [jelly] a first draft of jellypack...
Date Tue, 22 Jul 2003 21:57:36 GMT


Down here, I've pasted a script that should be the start of a jelly 
wrapping function.
The main functionality is to find the taglibs for a given jelly file 
then collect all dependencies.
With these, one can do several things.

Currently, one can generate a classpath to be used straight in the java 
command (using org.apache.commons.jelly.Jelly as main class).
	maven jellypack:generate-classpath \
which you can then use with something like
java -classpath `cat <classpathFile>` \
	org.apache.commons.jelly.Jelly <pathToJellyFile>

One can also create project.xml's dependency element which can be 
included in a project.xml to be completed (with meta-information).
maven jellypack:produce-dependency \
	-Djelly_file=file://pathToJellyFile \
	-Djelly_home=<pathToJelly> \

This script can be pasted in jelly's maven.xml and needs (oh shame) a 
dependency in jelly's project.xml on the xml tag-library.
Putting the jelly file's jelly-element's content as a goal in the 
maven.xml aside of the project.xml allows then such deployments as 
double-clickable jars webstart...

There's a whole lot more that could be done (including straight running 
(!), automating the possible products of the maven project generation), 
but... it's a start.

I am not too clear wether this script (well, an enhanced version of it) 
should actually be created as a maven plugin... probably.
The trouble is that its aim is to jumpstart people writing simple 
jelly-files... maybe as a subproject within jelly (so as to avoid 
jelly's dependency on xml-taglib) ?


     description="Creates the jellyNeededProjects list of poms"
     <!-- goes through the namespaces of the jelly file and collects them
       inferring from there the tag-libraries location. -->
     <!-- requires properties:
       jelly_file:   the jelly-file-name to be parsed
       jelly_home:   the root directory containing the jelly src and 
jelly-tags directories

     <!-- parse the jelly file -->
     <x:parse xml="${jelly_file}" var="jelly_src"/>
     <!-- find all namespace declarations in there, there must be 
faster! -->
     <j:set var="jellyTaglibNames"/>
     <j:new className="java.util.HashSet" var="namespaces"/>
     <x:forEach var="elt" select="$jelly_src//*" > <!-- ??? -->
       <j:if test="${elt.getNamespace().getURI() != null}">
       <!-- <j:set var="jellyTaglibNames">${jellyTaglibNames}, 
${elt.getNamespace().getURI().substring(6)}</j:set>  -->
     <echo>namespaces is "${namespaces}".</echo>
       <!--       ${namespaces.addAll(elt.additionalNamespaces())} -->

     <!-- go over the namespaces and fail if it's not jelly tag-libs -->
     <j:set var="jellyTaglibNames"/>
     <j:forEach var="tlName" items="${namespaces}">
       <echo>Considering taglib tlName "${tlName}".</echo>
       <j:if test="${'core' ne tlName}">
         <j:if test="${jellyTaglibNames.length() > 0}"><j:set 
var="jellyTaglibNames" trim="false">${jellyTaglibNames},</j:set></j:if>

     <echo>jellyTaglibNames is ${jellyTaglibNames}</echo>


     <j:set var="jellyNeededProjects" value="${reactorProjects}"/>

       <!-- defines
         allDependencies: a set of dependency objects (all merged)

     <j:new className="java.util.HashSet" var="allDependencies"/>
     <!-- put all project dependencies and project produced artifacts -->
     <j:forEach var="project" items="${jellyNeededProjects}">
       <!-- we iterate over a Project objects, see -->
       <echo>Project ${project}</echo>
       <j:new className="org.apache.maven.project.Dependency" 

     description="Generates the classpath needed to run the jelly-file 
from jars in the repository">

     <j:if test="${jelly_file.startsWith('file:')}">
       <j:set var="jelly_file" value="${jelly_file.substring(5)}"/>
     <property name="classpath_file" value="${jelly_file}.classpath"/>

     <x:parse var="trash">
       <j:new className="java.lang.StringBuffer" var="classpath"/>
       <j:forEach var="dep" items="${allDependencies}">
         <!-- we iterate over -->
         <!-- fixme... path is windows compatible ? -->
         <available file="${pathToDep}" property="depExists"/>
         <echo>Depfile ${pathToDep} exists ? ${depExists}</echo>

     <echo file="${classpath_file}">${classpath}</echo>
     <echo>Output classpath to file ${classpath_file}</echo>

   <goal name="jellypack:generate-maven-dependencies"
       description="creates the project.xml dependencies element to be 
included in a project.xml"
     <x:parse var="project-dependencies">
       <j:forEach items="${allDependencies}" var="dep">

   <goal name="jellypack:produce-dependency"
       description="produce the dependency project.xml element inside a 
file jellypack_dependencyFile"
     <property name="jellypack_dependencyFile" 
     <!-- <j:if test="${jellypack_dependencyFile eq 'dont obey 
me'}"><fail message="Please define property 
jellypack.dependencyFile"/></j:if> -->
     <j:file name="${jellypack_dependencyFile}" prettyPrint="true">
       <x:copyOf select="$project-dependencies"/>

View raw message