Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

400 lines (361 sloc) 17.053 kb
<?xml version="1.0"?>
<!-- =========================================================
Restlet build script - Copyright 2005-2012 Restlet S.A.S.
========================================================= -->
<project name="Restlet" default="build">
<!-- ============================ -->
<!-- === Properties setting === -->
<!-- ============================ -->
<!-- Load system specific properties -->
<property file="custom.properties" />
<!-- Load default properties -->
<property file="build.properties" />
<!-- General properties -->
<!-- Increment the build number -->
<buildnumber />
<!-- Current year -->
<tstamp>
<format property="current-year" pattern="yyyy" />
</tstamp>
<!-- Maven time stamp -->
<tstamp>
<format property="maven-snapshot-timestamp" pattern="yyyyMMdd.HHmmss" />
</tstamp>
<tstamp>
<format property="build.date" pattern="yyyyMMdd-HHmm" />
</tstamp>
<!-- Location properties -->
<property name="dist" location="dist" />
<property name="temp" location="temp" />
<property name="tmpl" location="tmpl" />
<property name="modules" location="../modules" />
<property name="libs" location="../libraries" />
<property name="parent-maven-groupId" value="org.restlet" />
<property name="parent-maven-artifactId" value="org.restlet.parent" />
<property name="parent-maven-version" value="${version-maven}" />
<property name="eclipse-version-suffix" value="v${build.date}" />
<property name="eclipse-version-full" value="${version-manifest-prefix}${eclipse-version-suffix}" />
<!-- Set the property that will enable the generation of eclipse project -->
<condition property="do-eclipsegeneration">
<istrue value="${eclipsegeneration}" />
</condition>
<!-- Set the property that will enable the generation of manifests files -->
<condition property="do-manifestsgeneration">
<istrue value="${manifestsgeneration}" />
</condition>
<!-- Set the property that will enable the generation of miscellaneous files -->
<condition property="do-miscgeneration">
<istrue value="${miscgeneration}" />
</condition>
<!-- ======================= -->
<!-- === Paths setting === -->
<!-- ======================= -->
<path id="forge-path">
<fileset dir="tools/forge" includes="**/*.jar" />
</path>
<path id="fmpp-path">
<fileset dir="tools/fmpp" includes="**/*.jar" />
</path>
<path id="bnd-path">
<fileset dir="tools/bnd" includes="**/*.jar" />
</path>
<!-- =================== -->
<!-- === Ant Tasks === -->
<!-- =================== -->
<!-- Ant Contrib -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<fileset dir="tools/ant-contrib" includes="**/*.jar" />
</classpath>
</taskdef>
<!-- FMPP (FreeMarker-based text file PreProcessor) -->
<taskdef name="fmpp" classname="fmpp.tools.AntTask">
<classpath>
<path refid="fmpp-path" />
<path refid="forge-path" />
</classpath>
</taskdef>
<!-- BND (handling of OSGI bundles) -->
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="bnd-path" />
<!-- = = = = = = = = = = = = = = = = =
macrodef: generate-edition
= = = = = = = = = = = = = = = = = -->
<macrodef name="generate-edition" description="Generate the source code for a target edition.">
<attribute name="edition" />
<sequential>
<!-- Generate the properties files -->
<fmpp sourceroot="${tmpl}/editions" outputroot="${temp}/@{edition}" dataroot="${basedir}" includes="*.properties">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
editions: get(values, "editions")
editionKey: @{edition}
edition: get(editions, @{edition})
currentYear: ${current-year}
</data>
</fmpp>
<!-- Generate the dependencies.txt file -->
<fmpp sourceroot="${tmpl}/text" outputroot="${temp}/@{edition}" dataroot="${basedir}" includes="dependencies.txt">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
editions: get(values, "editions")
editionKey: @{edition}
edition: get(editions, @{edition})
currentYear: ${current-year}
</data>
</fmpp>
<!-- Generate the POM files. -->
<echo message="Generate the POM files" />
<fmpp sourceroot="${tmpl}/editions" outputroot="${temp}/@{edition}/poms" dataroot="${basedir}" includes="*pom.tmpl">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
editions: get(values, "editions")
editionKey: @{edition}
edition: get(editions, @{edition})
currentYear: ${current-year}
ant: antProperties()
</data>
</fmpp>
<!-- Generate the feature.xml file -->
<echo message="Generate the feature.xml file" />
<fmpp sourceroot="${tmpl}/eclipse" outputroot="${temp}/@{edition}" dataroot="${basedir}" includes="feature.xml">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
editions: get(values, "editions")
editionKey: @{edition}
edition: get(editions, @{edition})
currentYear: ${current-year}
ant: antProperties()
</data>
</fmpp>
<move file="${temp}/@{edition}/poms/org.restlet.parent.pom.tmpl" tofile="${temp}/@{edition}/poms/org.restlet.parent.pom" />
<!-- Process the build.xml file. -->
<loadfile property="paths" srcFile="${tmpl}/editions/paths.tmpl" />
<loadfile property="generate-sources" srcFile="${tmpl}/editions/generate-sources.tmpl" />
<loadfile property="generate-javadocs" srcFile="${tmpl}/editions/javadocs.tmpl" />
<loadfile property="stage-modules" srcFile="${tmpl}/editions/stage-modules.tmpl" />
<loadfile property="stage-extras" srcFile="${tmpl}/editions/stage-extras.tmpl" />
<loadfile property="generate-classes-extras" srcFile="${tmpl}/editions/generate-classes-extras.tmpl" />
<!-- Pre-process the build file since ant and freemarker shares the same syntax. -->
<copy file="${tmpl}/editions/build.xml" tofile="${temp}/@{edition}/build.tmpl" overwrite="true">
<filterchain>
<replaceregex pattern="\$\{" replace="*DOLLAR*{" flags="g" />
<!-- nb: ant tokens can't contain "<" characters -->
<replacestring from="@paths@" to="${paths}" />
<replacestring from="@generate-sources@" to="${generate-sources}" />
<replacestring from="@generate-javadocs@" to="${generate-javadocs}" />
<replacestring from="@stage-modules@" to="${stage-modules}" />
<replacestring from="@stage-extras@" to="${stage-extras}" />
<replacestring from="@generate-classes-extras@" to="${generate-classes-extras}" />
</filterchain>
</copy>
<!-- Process it as a Freemarker template. -->
<fmpp sourcefile="${temp}/@{edition}/build.tmpl" outputfile="${temp}/@{edition}/build.xml" dataroot="${basedir}" expert="true">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
editions: get(values, "editions")
editionKey: @{edition}
edition: get(editions, @{edition})
currentYear: ${current-year}
</data>
</fmpp>
<delete file="${temp}/@{edition}/build.tmpl" />
<!-- Post-process the build file since ant and freemarker share the same syntax. -->
<replace file="${temp}/@{edition}/build.xml" token="*DOLLAR*" value="$" />
<!-- Generate the P2 feature files. -->
<echo message="Generate the P2 feature files" />
<fmpp sourceroot="${tmpl}/eclipse" outputroot="${temp}/@{edition}/p2" dataroot="${basedir}">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
editions: get(values, "editions")
editionKey: @{edition}
edition: get(editions, @{edition})
currentYear: ${current-year}
ant: antProperties()
</data>
<include name="feature.tmpl" />
</fmpp>
<copy file="build.properties" todir="${temp}/@{edition}" overwrite="true" />
<copy file="custom.properties" todir="${temp}/@{edition}" overwrite="true" failonerror="false" />
<ant antfile="build.xml" target="generate-sources" dir="${temp}/@{edition}/" inheritall="false" />
</sequential>
</macrodef>
<!-- = = = = = = = = = = = = = = = = =
macrodef: exec-edition
= = = = = = = = = = = = = = = = = -->
<macrodef name="exec-edition" description="Executes a task for a target edition">
<attribute name="edition" />
<attribute name="target" default="build" />
<sequential>
<for param="task" delimiter=" " list="@{target}">
<sequential>
<ant antfile="build.xml" target="@{task}" dir="${temp}/@{edition}/" inheritall="false">
<property name="build.number" value="${build.number}" />
<property name="eclipse-version-full" value="${eclipse-version-full}" />
</ant>
</sequential>
</for>
</sequential>
</macrodef>
<!-- = = = = = = = = = = = = = = = = =
Definition of targets
= = = = = = = = = = = = = = = = = -->
<target name="generate-libraries-manifests" description="Generates the manifest.mf files for the unique source code">
<!-- Generate eclipse .classpath, .project, .properties files -->
<fmpp sourceroot="${tmpl}/eclipse" outputroot="${temp}/p2" dataroot="${basedir}" expert="true">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
ant: antProperties()
</data>
<include name="classpath.tmpl" />
<include name="project.tmpl" />
<include name="build.properties.tmpl" />
</fmpp>
<delete file="${temp}/p2/classpath.tmpl" />
<delete file="${temp}/p2/project.tmpl" />
<delete file="${temp}/p2/build.properties.tmpl" />
<copy file="${tmpl}/bundles/bndbis.bnd" todir="${temp}/definitions/libs" />
<!-- Generate bnd definition files -->
<fmpp sourceroot="${tmpl}/bundles" outputroot="${temp}/definitions/libs" dataroot="${basedir}" expert="true">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
ant: antProperties()
</data>
<include name="bnd.tmpl" />
</fmpp>
<delete file="${temp}/definitions/libs/bnd.tmpl" />
<!-- Generate ant manifest generation script -->
<fmpp sourcefile="${tmpl}/bundles/extractmanifest.tmpl" outputfile="${temp}/p2/extractmanifest.xml" dataroot="${basedir}" expert="true">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
ant: antProperties()
</data>
</fmpp>
<ant antfile="${temp}/p2/extractmanifest.xml" dir="${temp}/p2" inheritAll="true" />
<delete file="${temp}/p2/extractmanifest.tmpl" />
</target>
<target name="generate-modules-manifests" description="Generates the manifest.mf files for the unique source code">
<!-- TODO
<bnd classpath="${modules}/org.restlet/src" eclipse="true" failok="false" exceptions="true" files="test.bnd" />
-->
</target>
<target name="copy-eclipse" depends="generate-manifests" if="do-eclipsegeneration" description="Copy the generated artifacts to the project">
<copy todir="${libs}">
<fileset dir="${temp}/libraries" excludes="**/*.jar" />
</copy>
</target>
<target name="generate-manifests" if="do-manifestsgeneration" description="Generates the manifest.mf files for the unique source code" >
<antcall target="generate-libraries-manifests" />
<antcall target="generate-modules-manifests" />
</target>
<target name="generate-misc" if="do-miscgeneration" description="Generates miscellaneous files." >
<delete dir="${temp}/misc" />
<!-- Generate editions matrix file -->
<fmpp sourceroot="${tmpl}/text" outputroot="${temp}/misc" dataroot="${basedir}" expert="true">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
editions: get(values, "editions")
ant: antProperties()
</data>
<include name="editionsMatrix.txt" />
</fmpp>
<!-- Generate modules/type file -->
<fmpp sourceroot="${tmpl}/text" outputroot="${temp}/misc" dataroot="${basedir}" expert="true">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
editions: get(values, "editions")
</data>
<include name="mcs.properties" />
</fmpp>
</target>
<target name="generate-poms" description="Generates the pom files for the unique source code">
<!-- Parent pom file -->
<fmpp sourcefile="${tmpl}/poms/org.restlet.parent.pom.tmpl" outputfile="${modules}/pom.xml" dataroot="${basedir}" expert="true">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
ant: antProperties()
</data>
</fmpp>
<!-- Modules pom files -->
<fmpp sourceroot="${tmpl}/poms" outputroot="${modules}" dataroot="${basedir}" expert="true">
<data expandproperties="true">
values: dataLoader.ForgeLoader("project.xml", "../modules", "../libraries")
project: get(values, "project")
ant: antProperties()
</data>
<include name="pom.tmpl" />
</fmpp>
<delete file="${modules}/pom.tmpl" />
</target>
<target name="generate-artifacts" depends="generate-misc, generate-poms, generate-manifests, copy-eclipse" description="Generates artifacts for the unique source code" />
<target name="prepare-stage-maven" if="do-prepare-stage-maven" description="Prepare the generation of the maven distributions.">
<!-- Revision number -->
<mkdir dir="${temp}" />
<!-- Snapshot? -->
<condition property="is.snapshot" else="false">
<contains string="${version-maven}" substring="-SNAPSHOT" />
</condition>
<echo message="maven-timestamp:${maven-snapshot-timestamp}${line.separator}" file="${temp}/snapshot.properties" append="false" />
<echo message="svn-revision:" file="${temp}/snapshot.properties" append="true" />
<exec executable="git" output="${temp}/snapshot.properties" append="true">
<arg line="rev-list --max-count=1 HEAD" />
</exec>
<echo message="${line.separator}" file="${temp}/snapshot.properties" append="true" />
</target>
<!-- CLEAN target -->
<target name="clean" depends="clean-temp, clean-dist" description="Clean the staging area." />
<!-- CLEAN-DIST target -->
<target name="clean-dist" description="Clean distributions files.">
<delete includeEmptyDirs="true" verbose="false" quiet="false" failonerror="false">
<fileset dir="${dist}" />
</delete>
</target>
<!-- CLEAN-TEMP target -->
<target name="clean-temp" description="Clean temporary build files.">
<delete includeEmptyDirs="true" verbose="false" quiet="false" failonerror="false">
<fileset dir="${temp}" />
</delete>
</target>
<target name="build-current" depends="generate-artifacts, prepare-stage-maven" description="Build the editions with the current source code.">
<for param="edition" delimiter="," list="${editions}">
<sequential>
<exec-edition edition="@{edition}" target="build" />
</sequential>
</for>
</target>
<target name="build" depends="generate-artifacts, prepare-stage-maven" description="Regenerate the source code and build the editions.">
<for param="edition" delimiter="," list="${editions}">
<sequential>
<generate-edition edition="@{edition}" />
<exec-edition edition="@{edition}" target="build" />
</sequential>
</for>
</target>
<target name="rebuild" depends="clean-temp, generate-artifacts, prepare-stage-maven" description="Clean the temp files, regenerate the source code and build the editions.">
<for param="edition" delimiter="," list="${editions}">
<sequential>
<generate-edition edition="@{edition}" />
<exec-edition edition="@{edition}" target="build" />
</sequential>
</for>
</target>
<target name="generate" depends="generate-artifacts" description="Regenerate the source code.">
<for param="edition" delimiter="," list="${editions}">
<sequential>
<generate-edition edition="@{edition}" />
</sequential>
</for>
</target>
<target name="regenerate" depends="clean-temp, generate" description="Clean and regenerate the source code." />
</project>
Jump to Line
Something went wrong with that request. Please try again.