jvanzyl 02/04/18 19:17:48
Added: src/templates/build build-init.xml
Log:
Fixing the build. This is a total work in progress.
Revision Changes Path
1.1 jakarta-turbine-maven/src/templates/build/build-init.xml
Index: build-init.xml
===================================================================
<?xml version="1.0"?>
<project name="$project.id" default="init" basedir="$antBasedir">
<!-- These are the bare minimum set of JARs that maven needs to operate.
We don't want to make a big JAR containing everything so we
are creating a special maven-classpath reference which is
used by the maven operations.
This can be cleaned up a bit, these lines can be generated instead
of being hardcoded but it gets us around the bootstrap problem
and keeps us away from a big fat JAR.
-->
<path id="maven-classpath">
#foreach ($jar in $jars)
<pathelement location="${lib.repo}/$jar"/>
#end
<pathelement location="${lib.repo}/maven.jar"/>
</path>
<!-- ================================================================== -->
<!-- I N I T I A L I Z E -->
<!-- ================================================================== -->
<!-- This deals with loading our path creation task that is used to: -->
<!-- -->
<!-- a) Construct a classpath from a descriptor file which allows us -->
<!-- to store our dependencies externally and makes a build -->
<!-- file reusable. -->
<!-- -->
<!-- b) Construct pattern sets that can be used for various task like -->
<!-- copying a set of resources into a JAR for deployment. -->
<!-- ================================================================== -->
<target
name="init"
depends="project-properties">
<!-- Set default values for the build -->
<property file="${maven.home}/default.properties" />
</target>
<!-- We can't do this until Ant 1.5 because references aren't forwarded
in <ant> calls until then.
<target
name="project-properties"
unless="pomLoaded">
-->
<target
name="project-properties"
depends="update-pom-check">
<taskdef
name="project-properties"
classname="org.apache.maven.ProjectProperties">
<classpath refid="maven-classpath"/>
</taskdef>
<!-- Here is where we need to add checks to see that the descriptor
is up-to-date. So we need to:
o Check for that the project.xml file is well-formed
o Get current version listed in the POM
o Get the version required by Maven
o If there is a mismatch then update the POM
-->
<project-properties projectDescriptor="project.xml"/>
</target>
<target
name="update-pom-check"
unless="pomChecked">
<taskdef
name="update-pom-check"
classname="org.apache.maven.UpdatePomCheck">
<classpath refid="maven-classpath"/>
</taskdef>
<!-- This task will place a property into the build called
'pomUpdateRequired' if the version of the POM is out of
sync with what Maven expects.
-->
<update-pom-check
projectDescriptor="project.xml"
/>
<echo>
pomUpdateRequired = ${pomUpdateRequired}
</echo>
<antcall target="callUpdateDescriptor"/>
</target>
<target
name="callUpdateDescriptor"
if="pomUpdateRequired">
<antcall target="update-descriptor"/>
<taskdef
name="format-pom"
classname="org.apache.maven.XmlPomFormatter">
<classpath refid="maven-classpath"/>
</taskdef>
<format-pom
input="project.xml"
output="project.xml.formatted"
/>
<copy
tofile="project.xml"
file="project.xml.formatted"
overwrite="true"
/>
<delete file="project.xml.formatted"/>
</target>
<!-- ================================================================== -->
<!-- U P D A T E D E S C R I P T O R -->
<!-- ================================================================== -->
<!-- Updates a project descriptor in XML form between different -->
<!-- versions of Maven. -->
<!-- -->
<!-- NOTE: -->
<!-- This only accounts for a transformation across single version. -->
<!-- -->
<!-- CONSTRAINTS: -->
<!-- We need to make sure both ${fromVersion} and ${toVersion} are -->
<!-- set and that we have a dvsl transformation to handle the -->
<!-- request. -->
<!-- ================================================================== -->
<target
name="updates-available">
<echo>
+------------------------------------------------------------------------------
|
| Updates available:
|
| v1 to v2 -> ant -DfromVersion=1 -DtoVersion=2 maven:update-descriptor
|
+------------------------------------------------------------------------------
</echo>
</target>
<target
name="updateDvslExists"
depends="fromVersion"
if="fromVersion">
<available
property="updateDvslExists"
value="true"
file="${maven.home}/update/v${fromVersion}-v${toVersion}/update-descriptor.dvsl"
/>
</target>
<target
name="checkUpdateDescriptor"
depends="updateDvslExists"
unless="updateDvslExists">
<echo>
+------------------------------------------------------------------------------
|
| ERROR: The specified update cannot be performed, please check your
| toVersion and fromVersion and try again. You can also use the
| 'maven:available-updates' target to see which migration paths
| are available.
|
+------------------------------------------------------------------------------
</echo>
</target>
<target
name="fromVersion"
depends="toVersion"
if="toVersion">
</target>
<target
name="toVersion"
if="toVersion">
</target>
<target
name="update-descriptor"
depends="checkUpdateDescriptor"
if="updateDvslExists"
description="o Update Maven project descriptor">
<echo>
+------------------------------------------------------------------------------
| N O T I C E
+------------------------------------------------------------------------------
|
| Updating project descriptor from version ${fromVersion} to version ${toVersion}
|
+------------------------------------------------------------------------------
</echo>
<taskdef
name="dvsl" classname="org.apache.tools.dvsl.DVSLTask">
<classpath>
<path refid="maven-classpath"/>
</classpath>
</taskdef>
<!-- Make a copy of the project descriptor before attempting
to move it forward to the next version.
-->
<copy
tofile="project.xml.v${fromVersion}"
file="project.xml"
/>
<dvsl
basedir="."
destdir="./"
extension=".xml"
style="${maven.home}/update/v${fromVersion}-v${toVersion}/update-descriptor.dvsl"
in="project.xml"
out="project.xml.${toVersion}"
toolboxfile="${maven.home}/stylesheets/toolbox.props"
/>
<!-- Give our new project descriptor its proper name -->
<copy
tofile="project.xml"
file="project.xml.${toVersion}"
overwrite="true"
/>
<!-- Get rid of the temporary copy -->
<delete file="project.xml.${toVersion}"/>
</target>
</project>