You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/20 09:26:46 UTC
[maven-ant-plugin] 28/50: MANT-16: Create an clean goal
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to annotated tag maven-ant-plugin-2.0
in repository https://gitbox.apache.org/repos/asf/maven-ant-plugin.git
commit 9bb06a8d0258aeac94afa15b6967453e4075061a
Author: Vincent Siveton <vs...@apache.org>
AuthorDate: Sun Sep 24 15:03:16 2006 +0000
MANT-16: Create an clean goal
o Added cleanMojo
o updated documentation
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-ant-plugin@449410 13f79535-47bb-0310-9956-ffa450edef68
---
.../apache/maven/plugin/ant/AntBuildWriter.java | 2 +-
.../org/apache/maven/plugin/ant/AntCleanMojo.java | 71 ++++++++++++++++++++++
src/site/apt/index.apt | 4 +-
3 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
index f8273d3..bda1077 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
@@ -219,7 +219,7 @@ public class AntBuildWriter
// ----------------------------------------------------------------------
writer.startElement( "project" );
- writer.addAttribute( "name", project.getArtifactId() );
+ writer.addAttribute( "name", project.getArtifactId() + "-from-maven");
writer.addAttribute( "default", "jar" );
writer.addAttribute( "basedir", "." );
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntCleanMojo.java b/src/main/java/org/apache/maven/plugin/ant/AntCleanMojo.java
new file mode 100644
index 0000000..4fed078
--- /dev/null
+++ b/src/main/java/org/apache/maven/plugin/ant/AntCleanMojo.java
@@ -0,0 +1,71 @@
+package org.apache.maven.plugin.ant;
+
+/*
+ * Copyright 2006 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.
+ */
+
+import java.io.File;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Clean all Ant build files.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @goal clean
+ */
+public class AntCleanMojo
+ extends AbstractMojo
+{
+ /**
+ * The working project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ */
+ private MavenProject project;
+
+ /**
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute()
+ throws MojoExecutionException
+ {
+ File buildXml = new File( project.getBasedir(), AntBuildWriter.DEFAULT_BUILD_FILENAME );
+ if ( buildXml.exists() && !buildXml.delete() )
+ {
+ throw new MojoExecutionException( "Cannot delete " + buildXml.getAbsolutePath() );
+ }
+
+ File mavenBuildXml = new File( project.getBasedir(), AntBuildWriter.DEFAULT_MAVEN_BUILD_FILENAME );
+ if ( mavenBuildXml.exists() && !mavenBuildXml.delete() )
+ {
+ throw new MojoExecutionException( "Cannot delete " + mavenBuildXml.getAbsolutePath() );
+ }
+
+ File mavenBuildProperties = new File( project.getBasedir(), AntBuildWriter.DEFAULT_MAVEN_PROPERTIES_FILENAME );
+ if ( mavenBuildProperties.exists() && !mavenBuildProperties.delete() )
+ {
+ throw new MojoExecutionException( "Cannot delete " + mavenBuildProperties.getAbsolutePath() );
+ }
+
+ getLog().info(
+ "Deleted Ant project for " + project.getArtifactId() + " in "
+ + project.getBasedir().getAbsolutePath() );
+ }
+}
diff --git a/src/site/apt/index.apt b/src/site/apt/index.apt
index 9b882f7..865bb77 100644
--- a/src/site/apt/index.apt
+++ b/src/site/apt/index.apt
@@ -30,10 +30,12 @@ Maven 2 Ant Plugin
* Goals Overview
- The Ant Plugin has one goal:
+ The Ant Plugin has two goals:
* {{{ant-mojo.html}ant:ant}} Generate Ant build files.
+ * {{{clean-mojo.html}ant:clean}} Clean all Ant build files.
+
* Usage
Instructions on how to use the Ant Plugin can be found {{{usage.html}here}}.
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.