blob: f5e7dc67da62437037107dfaf366805a795ff05d [file] [log] [blame]
<!---
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project default="jar" xmlns:j="jelly:core" xmlns:maven="jelly:maven" xmlns:util="jelly:util" xmlns:ant="jelly:ant" xmlns:u="jelly:util">
<!-- ================================================================== -->
<!-- START : C O M M O N S - B U I L D -->
<!-- ================================================================== -->
<!-- Required: Look and Feel for documentation within distributions -->
<!-- ================================================================== -->
<postGoal name="xdoc:copy-resources">
<!-- check commons-build is available before using -->
<j:set var="commonsBuildStyle" value="${basedir}/../commons-build/xdocs/style" />
<util:available file="${commonsBuildStyle}">
<copy todir="${basedir}/target/docs/style/" failonerror="false">
<fileset dir="${commonsBuildStyle}">
<include name='**/*'/>
<exclude name='**/CVS/**'/>
</fileset>
</copy>
</util:available>
<!-- check commons-build is available for a taglib before using -->
<j:set var="commonsBuildStyle" value="${basedir}/../.././commons-build/xdocs/style" />
<util:available file="${commonsBuildStyle}">
<copy todir="${basedir}/target/docs/style/" failonerror="false">
<fileset dir="${commonsBuildStyle}">
<include name='**/*'/>
<exclude name='**/CVS/**'/>
</fileset>
</copy>
</util:available>
</postGoal>
<!-- ================================================================== -->
<!-- END: C O M M O N S - B U I L D -->
<!-- ================================================================== -->
<!-- build the timestamp after compiling -->
<postGoal name="java:jar-resources">
<j:file name="${maven.build.dest}/org/apache/commons/jelly/jelly-version.txt" omitXmlDeclaration="true"
>${pom.currentVersion}</j:file>
<tstamp><format property="now" pattern="yyyy-MM-dd kk:mm:ss zzz"/></tstamp>
<j:file name="${maven.build.dest}/org/apache/commons/jelly/jelly-build-date.txt" omitXmlDeclaration="true"
>${now}</j:file>
</postGoal>
<!-- Ripped from dist plugin. The dist plugin is notoriously inflexible -->
<goal
name="dist:build-bin"
prereqs="dist:build-setup,dist:prepare-bin-filesystem"
description="Build the binary distribution.">
<!-- Create a tar.gz file -->
<ant:tar compression="gzip" longfile="gnu" tarfile="${maven.dist.dir}/${maven.final.name}.tar.gz">
<ant:tarfileset dir="${maven.dist.bin.archive.dir}">
<ant:exclude name="bin/jelly" />
</ant:tarfileset>
<ant:tarfileset dir="${maven.dist.bin.archive.dir}" mode="755">
<ant:include name="bin/jelly" />
</ant:tarfileset>
</ant:tar>
<ant:fixcrlf srcdir="${maven.dist.bin.archive.dir}" eol="crlf" includes="*.txt" />
<!-- Create a zip file -->
<ant:zip zipfile="${maven.dist.dir}/${maven.final.name}.zip">
<ant:zipfileset dir="${maven.dist.bin.archive.dir}"/>
</ant:zip>
</goal>
<postGoal name="dist:prepare-src-filesystem">
<ant:copy todir="${maven.dist.src.assembly.dir}">
<ant:fileset dir=".">
<ant:include name="parent-project.xml" />
<ant:include name="NOTICE.txt" />
<ant:include name="RELEASE-NOTES.txt" />
</ant:fileset>
</ant:copy>
<ant:copy todir="${maven.dist.src.assembly.dir}/xdocs">
<ant:fileset dir="xdocs"/>
</ant:copy>
</postGoal>
<!-- create the lib and bin directories in the binary distro -->
<postGoal name="dist:prepare-bin-filesystem">
<echo>About to create lib and bin directories in ${maven.dist.bin.assembly.dir}</echo>
<mkdir dir="${maven.dist.bin.assembly.dir}/bin"/>
<mkdir dir="${maven.dist.bin.assembly.dir}/lib"/>
<mkdir dir="${maven.dist.bin.assembly.dir}/custom"/>
<copy todir="${maven.dist.bin.assembly.dir}">
<fileset dir=".">
<ant:include name="NOTICE.txt" />
<ant:include name="RELEASE-NOTES.txt" />
</fileset>
</copy>
<copy file="README-binary-dist.txt" overwrite="true"
tofile="${maven.dist.bin.assembly.dir}/README.txt"/>
<copy todir="${maven.dist.bin.assembly.dir}/bin">
<fileset dir="src/bin"/>
</copy>
<chmod file="${maven.dist.bin.assembly.dir}/bin/jelly" perm="ugo+rx" />
<ant:fixcrlf srcdir="${maven.dist.bin.assembly.dir}" eol="crlf" includes="bin/jelly.bat" />
<ant:fixcrlf srcdir="${maven.dist.bin.assembly.dir}" eol="lf" includes="bin/jelly" />
<j:forEach var="dep" items="${pom.dependencies}">
<j:choose>
<j:when test="${dep.id == 'forehead'}">
<copy tofile="${maven.dist.bin.assembly.dir}/lib/forehead.jar"
file="${maven.repo.local}/${dep.artifactDirectory}/${dep.type}s/${dep.artifact}"/>
</j:when>
<j:otherwise>
<copy todir="${maven.dist.bin.assembly.dir}/lib"
file="${maven.repo.local}/${dep.artifactDirectory}/${dep.type}s/${dep.artifact}"/>
</j:otherwise>
</j:choose>
</j:forEach>
<!-- put a copy of Jelly's jar there too -->
<copy todir="${maven.dist.bin.assembly.dir}/lib"
file="${maven.build.dir}/${maven.final.name}.jar"/>
<delete file="${maven.dist.bin.assembly.dir}/${maven.final.name}.jar" />
<!-- Grab some taglibs -->
<maven:reactor
includes="bean/project.xml,define/project.xml,dynabean/project.xml,interaction/project.xml,junit/project.xml,swing/project.xml,util/project.xml,fmt/project.xml,log/project.xml,xml/project.xml"
basedir="${basedir}/jelly-tags"
postProcessing="true"
collectOnly="true"
banner="Gathering"
/>
<j:forEach var="reactorProject" items="${reactorProjects}">
<j:set var="version" value="${reactorProject.versions[size(reactorProject.versions)-1]}" />
<j:if test="${version.tag == 'HEAD'}">
<j:set var="version" value="${reactorProject.versions[size(reactorProject.versions)-2]}" />
</j:if>
<j:if test="${empty(version)}">
<ant:fail>WARNING: no version for ${reactorProject}</ant:fail>
</j:if>
<u:file var="localFile" name="${maven.repo.local}/${reactorProject.groupId}/jars/${reactorProject.artifactId}-${version}.jar" />
<j:if test="${!localFile.exists()}">
<ant:mkdir dir="${localFile.parent}" />
<j:set var="repoList">${maven.repo.remote}</j:set>
<u:tokenize var="repos" delim=",">${repoList.trim()}</u:tokenize>
<j:forEach var="repo" items="${repos}">
<j:set var="remoteFile" value="${repo}/${reactorProject.groupId}/jars/${reactorProject.artifactId}-${version}.jar" />
<echo>Downloading ${remoteFile}</echo>
<j:catch var="ex">
<j:invokeStatic var="dummy" method="getFile"
className="org.apache.maven.util.HttpUtils">
<j:arg type="java.lang.String" value="${remoteFile}" />
<j:arg type="java.io.File" value="${localFile}"/>
<j:arg type="boolean" value="false"/>
<j:arg type="boolean" value="true"/>
<j:arg type="java.lang.String" value="${maven.proxy.host}" />
<j:arg type="java.lang.String" value="${maven.proxy.port}" />
<j:arg type="java.lang.String" value="${maven.proxy.username}" />
<j:arg type="java.lang.String" value="${maven.proxy.password}" />
<j:arg type="boolean" value="false"/>
</j:invokeStatic>
</j:catch>
<j:break test="${localFile.exists()}"/>
</j:forEach>
<j:set var="downloaded" value="${localFile.exists()}"/>
<j:if test="${!downloaded}">
<ant:fail message="Unable to find tag library" />
</j:if>
</j:if>
<echo>Installing tag library from ${localFile}</echo>
<ant:copy file="${localFile}" todir="${maven.dist.bin.assembly.dir}/lib" />
</j:forEach>
</postGoal>
<!-- TAG LIBS BUILD -->
<goal
name="tags:build"
description="Build each tag into an installable jar">
<maven:reactor
basedir="jelly-tags"
includes="*/project.xml"
goals="clean,jar:install"
banner="Building tag"
ignoreFailures="false"/>
</goal>
<!-- TAG DOCUMENTATION -->
<goal
name="tags:doc"
description="Build the documentation for each tag library">
<j:set var="maven.jellydoc.packages" value="org.apache.commons.jelly.*"/>
<maven:reactor
basedir="jelly-tags"
includes="*/project.xml"
goals="jellydoc,xdoc"
banner="Building tag"
ignoreFailures="false"/>
</goal>
<!-- Do the same goal on all Tag Libs -->
<goal
name="tags:do"
description="Do a specific goal on each taglib">
<maven:reactor
basedir="jelly-tags"
includes="*/project.xml"
goals="${goal}"
banner="Building tag"
ignoreFailures="false"/>
</goal>
<!-- ===================================================================== -->
<!-- D I S T : I N S T A L L -->
<!-- ===================================================================== -->
<!-- This installs Jelly on your system. With an installed Jelly, you'll -->
<!-- be able to run Jelly scripts from wherever your are, using : -->
<!-- "jelly <script> <outputfile>". -->
<!-- The installation dir is set in the project.properties file, under the -->
<!-- name "maven.dist.install.dir", which defaults to "/usr/local/jelly" -->
<!-- (yep, that's a Linux path :). Please override it to suit your needs -->
<!-- ===================================================================== -->
<goal name="dist:install"
description="Installs Jelly on your system."
prereqs="dist:build">
<echo>
+-------------------------------------------------------+
| I N S T A L L I N G J E L L Y |
| to ${maven.dist.install.dir} |
+-------------------------------------------------------+
</echo>
<delete dir="${maven.dist.install.dir}"/>
<mkdir dir="${maven.dist.install.dir}"/>
<copy todir="${maven.dist.install.dir}">
<fileset dir="${maven.dist.bin.assembly.dir}"/>
</copy>
<chmod file="${maven.dist.install.dir}/bin/jelly" perm="ugo+rx" />
<echo>
* ===================================================== *
* W A R N I N G *
* ===================================================== *
* Jelly is now almost installed on your system ! *
* Next, you must set JELLY_HOME to point to *
* "${maven.dist.install.dir}", and add JELLY_HOME/bin *
* to your PATH. *
* *
* Then, you will be able to run Jelly scripts using the *
* command : "jelly script outputfile". *
* *
* Enjoy ! *
* *
* p.s. if ${maven.dist.install.dir} isn't where you'd *
* like Jelly installed, please set a property called *
* maven.dist.install.dir to the appropriate directory *
* ===================================================== *
</echo>
</goal>
<!-- ===================================================================== -->
<!-- GENERATE THE TAG-LIBRARY LIST -->
<!-- ===================================================================== -->
<preGoal name="xdoc:transform">
<!-- can't pass anything into the jellydoc doclet so its hard coded to target -->
<mkdir dir="target"/>
<mkdir dir="${maven.gen.docs}/libs/"/>
<j:file name="${maven.gen.docs}/libs/index.xml"
prettyPrint="true">
<document>
<properties>
<title>Jelly Libraries</title>
<author email="dion@multitask.com.au">dIon Gillard</author>
</properties>
<body>
<section name="Jelly Libraries">
<p>
The following libraries are available for Jelly as part of the standard distribution.
Other libraries are maintained elsewhere - please see the
<a href="../poweredby.html">powered by</a> page for more details.
</p>
<ul>
<fileScanner var="pluginProjects">
<fileset dir="${basedir}">
<include name="jelly-tags/*/project.xml" />
</fileset>
</fileScanner>
<j:forEach items="${pluginProjects.iterator()}" var="plugin">
<j:set var="pluginName" value="${plugin.parentFile.name}" />
<li>
<a href="./${pluginName}/index.html">${pluginName}</a> :
<a href="./${pluginName}/tags.html">tags</a>
</li>
</j:forEach>
</ul>
</section>
</body>
</document>
</j:file>
<!-- now lets implement the jellydoc for the core package -->
<j:set var="maven.jellydoc.packages" value="org.apache.commons.jelly.tags.core.*"/>
<attainGoal name="jellydoc"/>
</preGoal>
<preGoal name="xdoc">
<j:if test="${!empty(fullSite)}">
<echo>Building site for Jelly and all taglibs</echo>
<sleep seconds="5" />
<!--
This runs out of memory - have a feeling its the velocity & xdoc plugin
-->
<!-- <maven:reactor
basedir="${basedir}"
includes="jelly-tags/*/project.xml"
goals="site"
banner="Generating site for"
ignoreFailures="false"
/>-->
<!-- PL: instead... invoke maven from the command-line directly for
each directory in jelly-tags. -->
<attainGoal name="tags:build-site-individually"/>
<!-- then copy all the results to docs/libs -->
<j:if test="${context.getVariable('maven.docs.dest') == null}">
<j:set var="maven.docs.dest" value="target/docs"/>
</j:if>
<!-- create the parent directory for the docs -->
<mkdir dir="${maven.docs.dest}/libs" />
<!-- copy them all to ${maven.docs.dest}/libs/${plugin.id}/ -->
<j:forEach items="${pluginProjects.iterator()}" var="plugin">
<j:set var="pluginName" value="${plugin.parentFile.name}" />
<mkdir dir="${maven.docs.dest}/libs/${pluginName}/" />
<copy toDir="${maven.docs.dest}/libs/${pluginName}/">
<fileset dir="jelly-tags/${pluginName}/target/docs/">
<include name="**" />
</fileset>
</copy>
</j:forEach>
</j:if>
</preGoal>
<goal name="tags:build-site-individually">
<fileScanner var="taglibProjects">
<fileset dir="${basedir}">
<include name="jelly-tags/*/project.xml" />
</fileset>
</fileScanner>
<j:choose>
<j:when test="${systemScope['os.name'].startsWith('Windows')}">
<j:set var="mavenCmd" value="${maven.home}/bin/maven.bat"/>
</j:when>
<j:otherwise>
<j:set var="mavenCmd" value="${maven.home}/bin/maven"/>
</j:otherwise>
</j:choose>
<j:forEach items="${taglibProjects.iterator()}" var="taglib">
<j:set var="tlName" value="${taglib.parentFile.name}" />
<echo>Processing tag-library ${tlName}.</echo>
<j:set var="dir" value="${basedir}/jelly-tags/${tlName}"/>
<j:set var="testVar" value="siteIsBuilt${tlName}"/>
<uptodate property="${testVar}">
<srcfiles dir="${dir}" excludes="target/**/*"/>
<mapper type="merge" to="${dir}/target/docs/index.html"/>
</uptodate>
<echo>Tag-library ${tlname}'s site is up-to-date ? "${context.getVariable(testVar)}"</echo>
<j:if test="${!context.getVariable(testVar)}">
<echo>Building tag-library ${tlname}'s site.</echo>
<exec executable="${mavenCmd}" failonerror="true" dir="${dir}">
<arg value="site"/>
</exec>
</j:if>
</j:forEach>
</goal>
<!-- demo programs -->
<!-- a sample of using the command line interface to invoke Jelly -->
<goal name="demo:cmdline" prereqs="create-classpath"
description="Demonstrates how to use the command line interface to Jelly">
<java classname="org.apache.commons.jelly.Jelly" fork="yes">
<classpath refid="test.classpath"/>
<arg value="src/test/org/apache/commons/jelly/testCmdLineOptions.jelly"/>
<arg value="-a"/>
<arg value="valueOfA"/>
<arg value="-b"/>
<arg value="valueOfB"/>
<arg value="-c"/>
<arg value="valueOfC"/>
<arg value="-Dtestsysprop=valueOfTestSystemProp"/>
</java>
</goal>
<goal name="test:benchmark" prereqs="create-classpath"
description="A simple bit of Jelly script used as a benchmark to guage performance">
<java classname="org.apache.commons.jelly.Jelly" fork="yes">
<classpath refid="test.classpath"/>
<arg value="src/test/org/apache/commons/jelly/benchmark/benchmark.jelly"/>
</java>
</goal>
<goal name="demo:embed" prereqs="create-classpath"
description="A sample Swing app which lets you build a personalized homepage, and uses Jelly as a templating engine">
<java classname="org.apache.commons.jelly.demos.HomepageBuilder" fork="yes">
<classpath refid="test.classpath"/>
</java>
</goal>
<goal name="demo:async"
description="An example of using asynchronous invocation of goals">
<j:thread>
<attainGoal name="demo:asyncOtherThread"/>
</j:thread>
<echo>XXXX</echo>
</goal>
<goal name="demo:asyncOtherThread"
description="A private target invoked by the async demo">
<echo>YYYY</echo>
</goal>
<!-- define the classpath used to run examples -->
<goal name="create-classpath" prereqs="java:compile,test:compile">
<path id="test.classpath">
<pathelement path="${maven.build.dest}"/>
<pathelement path="target/classes"/>
<pathelement path="target/test-classes"/>
<path refid="maven.dependency.classpath"/>
</path>
</goal>
<goal name="clean-build">
<attainGoal name="clean"/>
<attainGoal name="jar:install-snapshot"/>
${systemScope.put('goal','clean,jar:install-snapshot')}
<attainGoal name="multiproject:goal"/>
</goal>
<goal name="pack-fat-jar" prereqs=""
description="Creates a jar with all the dependencies of jelly and the taglibs indicated in ${tagLibs}.">
<!-- variables:
- tagLibs: a comma-separated list of taglib-names (without the "jelly:")
- doBuildAll: a boolean that says wether we invoke build (of jelly, and the taglibs)
When true, invokes jar:install-snapshot on jelly and each taglib included
- fatJarName: the location of the fat-jar collected
-->
<!-- this goal isn't really much tested yet but could be the key
to get a better packaging -->
<property name="tagLibs" value="ant,bean,beanshell,betwixt,define,dynabean,fmt,html,http,interaction,junit,jsl,log,swing,threads,util,validate,velocity,xml,xmlunit"/>
<!-- arbitrary set of taglibs with dependencies that should have no problems -->
<property name="doBuildAll" value="false"/>
<property name="fatJarPath" value="${maven.build.dir}/fatjelly.jar"/>
<property name="classpathFile" value="${maven.build.dir}/classpath-with-deps.txt"/>
<property name="mergedDepsFile" value="${maven.build.dir}/mergedDeps.xml"/>
<!-- if we need to build, we need to build first jelly -->
<j:if test="${doBuildAll}"><attainGoal name="jar:install-snapshot"/></j:if>
<j:new var="jellyTaglibNames" className="java.util.HashSet"/>
<j:set var="taglibs_projects" value=""/>
<util:tokenize delim="," var="tagLibnames">${tagLibs}</util:tokenize>
<j:forEach var="tlName" items="${tagLibnames}">
<echo>Considering taglib tlName "${tlName}".</echo>
<j:if test="${'core' ne tlName}">
<j:if test="${taglibs_projects.length() > 0}"><j:set var="taglibs_projects" trim="false">${taglibs_projects},</j:set></j:if>
<j:set var="taglibs_projects">${taglibs_projects}jelly-tags/${tlName}/project.xml</j:set>
${jellyTaglibNames.add(tlName)}
</j:if>
</j:forEach>
<!-- collect all dependencies in a set -->
<j:new var="deps" className="java.util.HashSet"/>
<j:choose>
<j:when test="${doBuildAll}">
<maven:reactor basedir="."
postProcessing="true"
goals="jar:install-snapshot"
includes="${taglibs_projects}"
ignoreFailures="false"/>
</j:when>
<j:otherwise>
<maven:reactor basedir="." postProcessing="true"
includes="${taglibs_projects}" ignoreFailures="false"/>
</j:otherwise>
</j:choose>
<j:forEach var="reactorProject" items="${reactorProjects}">
<j:forEach var="dep" items="${reactorProject.dependencies}">
<j:if test="${dep.groupId eq 'commons-jelly'}">${dep.setVersion("SNAPSHOT")}</j:if>
${deps.add(dep)}
</j:forEach>
</j:forEach>
<j:forEach var="tl" items="${jellyTaglibNames}">
<j:new var="tlD" className="org.apache.maven.project.Dependency"/>
${tlD.setGroupId("commons-jelly")}
<j:set var="artId" value="commons-jelly-tags-${tl}"/>
${tlD.setArtifactId(artId)}
${tlD.setType("jar")}
${tlD.setVersion("SNAPSHOT")}
${deps.add(tlD)}
</j:forEach>
<!-- <maven:reactor
basedir="."
postProcessing="true"
includes="project.xml"
ignoreFailures="false">
</maven:reactor>
<j:forEach var="reactorProject" items="${reactorProjects}">
<j:forEach var="dep" items="${reactorProject.dependencies}">${deps.add(dep)}</j:forEach>
</j:forEach> -->
<j:if test="${'' ne classpathFile}">
<j:file name="${classpathFile}" omitXmlDeclaration="true"><j:forEach items="${deps}" trim="true" var="dep">${maven.repo.local}/${dep.groupId}/${dep.type}s/${dep.artifactId}-${dep.version}.${dep.type}${path.separator}</j:forEach></j:file>
</j:if>
<!-- merging it all -->
<j:if test="${'' ne fatJarPath}">
<jar destfile="${fatJarPath}" update="yes">
<manifest><attribute name="Main-Class" value="org.apache.commons.jelly.Jelly"/></manifest>
<j:forEach var="dep" items="${deps}">
<zipfileset src="${maven.repo.local}/${dep.groupId}/${dep.type}s/${dep.artifact}">
<exclude name="META-INF/*"/>
</zipfileset>
<echo>Adding jar ${maven.repo.local}/${dep.groupId}/${dep.type}s/${dep.artifact}.</echo>
</j:forEach>
</jar>
</j:if>
<j:if test="${!empty(mergedDepsFile)}">
<j:file prettyPrint="true" name="${mergedDepsFile}">
<dependencyList project="commons-jelly"
withAddOns="${tagLibs}">
<j:forEach var="dep" items="${deps}">
<dependency groupId="${dep.groupId}" artifactId="${dep.artifactId}" version="${dep.version}"/>
</j:forEach>
</dependencyList>
</j:file>
</j:if>
</goal>
<goal name="generate-gump">
<j:set var="maven.multiproject.includes" value="project.xml,jelly-tags/*/project.xml" />
<j:set var="maven.multiproject.excludes" value="" />
<attainGoal name="gump:multiproject" />
</goal>
</project>