maven-plugins/ant/plugin.jelly
ltheussl 48d2d7cf96 Trivial fixes
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@405476 13f79535-47bb-0310-9956-ffa450edef68
2006-05-09 17:20:36 +00:00

110 lines
5.3 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed 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.
*/
-->
<!-- Note the need to declare "test" as a namespace because it is used in the template -->
<project
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:test="test"
xmlns:j="jelly:core"
xmlns:i="jelly:interaction"
xmlns:u="jelly:util">
<!-- ================================================================== -->
<!-- A N T B U I L D G E N E R A T O R -->
<!-- ================================================================== -->
<!-- This plugin generates a stand alone ant build.xml file that can be -->
<!-- used without having Maven installed. The dependencies are -->
<!-- retrieved using the ant <get> task and then the standard <javac> -->
<!-- and <jar> tasks are used to produce a JAR. This is primarily for -->
<!-- people who want to build from sources but don't want to use Maven. -->
<!-- ================================================================== -->
<goal name="ant"
description="Generate an Ant build file"
prereqs="ant:generate-build"/>
<goal name="ant:generate-build"
description="Generate an Ant build file"
prereqs="ant:verify-script-exists,ant:generate-script"/>
<goal name="ant:verify-script-exists" description="Check if the script already exists.">
<u:file var="projectAsFile" name="${maven.ant.generate.dir}/${maven.ant.generate.script}"/>
<j:if test="${(projectAsFile.exists())}">
<ant:echo>The ant script [${maven.ant.generate.dir}/${maven.ant.generate.script}] already exists !!</ant:echo>
<j:choose>
<j:when test="${(maven.ant.generate.force == null) or not (maven.ant.generate.force == 'true')}">
<i:ask question="Would you like to override your current script (y/n)?" answer="ok" default="y"/>
<j:choose>
<j:when test="${ok == 'y'}">
<ant:echo>!! Your script will be replaced !!</ant:echo>
</j:when>
<j:otherwise>
<ant:echo>Script generation aborted.</ant:echo>
<j:set var="abortProcess" value="true"/>
</j:otherwise>
</j:choose>
</j:when>
<j:otherwise>
<ant:echo>The property "maven.ant.generate.force" is set to [${maven.ant.generate.force}].</ant:echo>
<ant:echo>!! Your current script will be replaced !!</ant:echo>
</j:otherwise>
</j:choose>
</j:if>
</goal>
<goal
name="ant:generate-script"
description="Generate an Ant build file">
<j:if test="${context.getVariable('abortProcess') == null or context.getVariable('abortProcess') != true}">
<j:if test="${context.getVariable('maven.ant.generatebuild.file') != null and !context.getVariable('maven.ant.generatebuild.file').equals('')}">
<ant:echo>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</ant:echo>
<ant:echo>The property "maven.ant.generatebuild.file" is no more used.</ant:echo>
<ant:echo>Use the properties "maven.ant.generate.dir" and "maven.ant.generate.script" instead</ant:echo>
<ant:echo>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</ant:echo>
</j:if>
<ant:echo>Generating ${maven.ant.generate.dir}/${maven.ant.generate.script} ...</ant:echo>
<ant:mkdir dir="${maven.ant.generate.dir}"/>
<j:file name="${maven.ant.generate.dir}/${maven.ant.generate.script}" prettyPrint="true">
<j:import file="${plugin.resources}/templates/build.jelly" inherit="true"/>
</j:file>
<ant:echo>${maven.ant.generate.dir}/${maven.ant.generate.script} generated.</ant:echo>
</j:if>
</goal>
<goal
name="ant:execute"
description="Execute an Ant build file">
<ant:echo>Executing ${maven.ant.execute.dir}/${maven.ant.execute.script} ...</ant:echo>
<ant:ant>
<j:if test="${context.getVariable('maven.ant.execute.script') != null and !context.getVariable('maven.ant.execute.script').equals('')}">
<ant:setProperty name="antfile" value="${context.getVariable('maven.ant.execute.script')}" />
</j:if>
<j:if test="${context.getVariable('maven.ant.execute.dir') != null and !context.getVariable('maven.ant.execute.dir').equals('')}">
<ant:setProperty name="dir" value="${context.getVariable('maven.ant.execute.dir')}" />
</j:if>
<j:if test="${context.getVariable('maven.ant.execute.target') != null and !context.getVariable('maven.ant.execute.target').equals('')}">
<ant:setProperty name="target" value="${context.getVariable('maven.ant.execute.target')}" />
</j:if>
</ant:ant>
<ant:echo>${maven.ant.execute.dir}/${maven.ant.execute.script} executed.</ant:echo>
</goal>
</project>