MPANT-19 : The plugin overwrote existing ant script files without warning. From now the plugin ask you if you want to replace it. You can also use the property maven.ant.generate.force to force the plugin to replace the current script.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@405247 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
aheritier
2006-05-09 00:50:00 +00:00
parent 9d26827b5d
commit 398eda2b7c
5 changed files with 62 additions and 15 deletions

View File

@@ -22,7 +22,9 @@
xmlns:ant="jelly:ant"
xmlns:maven="jelly:maven"
xmlns:test="test"
xmlns:j="jelly:core">
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 -->
<!-- ================================================================== -->
@@ -37,21 +39,52 @@
description="Generate an Ant build file"
prereqs="ant:generate-build"/>
<goal
name="ant:generate-build"
description="Generate an Ant build file">
<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>
<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 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 setted 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>
<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>
</goal>
<goal

View File

@@ -23,6 +23,7 @@
maven.ant.generate.script = build.xml
maven.ant.generate.dir = ${basedir}
maven.ant.generate.force = false
maven.ant.execute.script = ${maven.ant.generate.script}
maven.ant.execute.dir = ${maven.ant.generate.dir}

View File

@@ -90,6 +90,11 @@
<comment>This library is already loaded by maven's core. Be careful to use the same version number as in the core.</comment>
</properties>
</dependency>
<dependency>
<groupId>commons-jelly</groupId>
<artifactId>commons-jelly-tags-interaction</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<reports>
<report>maven-changes-plugin</report>

View File

@@ -26,6 +26,7 @@
</properties>
<body>
<release version="1.10-SNAPSHOT" date="In SVN">
<action dev="aheritier" type="add" issue="MPANT-19">The plugin overwrote existing ant script files without warning. From now the plugin ask you if you want to replace it. You can also use the property maven.ant.generate.force to force the plugin to replace the current script.</action>
<action dev="aheritier" type="update">The property maven.ant.generatebuild.file is replaced by properties maven.ant.generate.dir, maven.ant.generate.script. The generated script is ${maven.ant.generate.dir}/${maven.ant.generate.script}.</action>
<action dev="aheritier" type="del">The property maven.ant.generatebuild.file is removed.</action>
<action dev="aheritier" type="add" issue="MPANT-25">Add a new goal (ant:execute) to execute a build.xml file from maven.</action>

View File

@@ -47,6 +47,13 @@
<td>Yes</td>
<td>${basedir}</td>
</tr>
<tr>
<td>maven.ant.generate.force</td>
<td>If the ant script file already exists the plugin ask you if you want to replace it. Setting this property to true, will force the plugin to overwrite this file without to ask the question.</td>
<td>since 1.10</td>
<td>Yes</td>
<td>false</td>
</tr>
<tr>
<td>maven.ant.excludeTests</td>
<td>Holds a comma separated list of source file patterns that will be excluded in the generated Ant build, e.g.</td>