You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2008/03/22 18:22:23 UTC
svn commit: r640016 - in /maven/plugins/trunk/maven-ant-plugin/src:
main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
site/apt/examples/customize.apt site/apt/examples/fail-missing-junit.apt
site/apt/index.apt site/site.xml
Author: bentmann
Date: Sat Mar 22 10:22:21 2008
New Revision: 640016
URL: http://svn.apache.org/viewvc?rev=640016&view=rev
Log:
[MANT-6] "test" targets should fail if junit.jar not present
o Added example to show how to realize this by target overriding
Added:
maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/fail-missing-junit.apt (with props)
Modified:
maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/customize.apt
maven/plugins/trunk/maven-ant-plugin/src/site/apt/index.apt
maven/plugins/trunk/maven-ant-plugin/src/site/site.xml
Modified: maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java?rev=640016&r1=640015&r2=640016&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java (original)
+++ maven/plugins/trunk/maven-ant-plugin/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java Sat Mar 22 10:22:21 2008
@@ -25,7 +25,6 @@
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -43,8 +42,6 @@
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter;
-import sun.security.action.GetIntegerAction;
-
/**
* Write Ant build files from <code>Maven Project</code> for <a href="http://ant.apache.org">Ant</a> 1.6.2 or above:
* <ul>
@@ -863,7 +860,7 @@
writer.endElement(); // echo
writer.startElement( "echo" );
- writer.writeText( " Junit isn't present in your $ANT_HOME/lib directory. Tests not executed. " );
+ writer.writeText( " JUnit is not present in your $ANT_HOME/lib directory. Tests not executed." );
writer.endElement(); // echo
writer.startElement( "echo" );
Modified: maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/customize.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/customize.apt?rev=640016&r1=640015&r2=640016&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/customize.apt (original)
+++ maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/customize.apt Sat Mar 22 10:22:21 2008
@@ -38,7 +38,7 @@
<!-- Ant build file (http://ant.apache.org/) for Ant 1.6.2 or above. -->
<!-- ====================================================================== -->
-<project name="%PROJECT_ARTIFACTID%" default="jar" basedir=".">
+<project name="%PROJECT_ARTIFACT_ID%" default="package" basedir=".">
<!-- ====================================================================== -->
<!-- Import maven-build.xml into the current project -->
Added: maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/fail-missing-junit.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/fail-missing-junit.apt?rev=640016&view=auto
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/fail-missing-junit.apt (added)
+++ maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/fail-missing-junit.apt Sat Mar 22 10:22:21 2008
@@ -0,0 +1,61 @@
+ ------
+ Failing the Build if JUnit is Missing
+ ------
+ Benjamin Bentmann
+ ------
+ March 2008
+ ------
+
+ ~~ 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.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/guides/mini/guide-apt-format.html
+
+
+Failing the Build if JUnit is Missing
+
+ The build scripts generated by the Ant Plugin require JUnit to run the unit tests. By default, the <<<build.xml>>> will
+ only output a warning if JUnit was not found on the class path, i.e. the build simply continues without running the
+ unit tests. If you rather want the build to fail in this case, you can easily customize the <<<build.xml>>> by
+ overriding the target <<<junit-present>>>:
+
++-----+
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- Ant build file (http://ant.apache.org/) for Ant 1.6.2 or above. -->
+<!-- ====================================================================== -->
+
+<project name="%PROJECT_ARTIFACT_ID%" default="package" basedir=".">
+ ...
+
+ <!-- ====================================================================== -->
+ <!-- Unit testing, overridden to fail upon missing JUnit -->
+ <!-- ====================================================================== -->
+
+ <target name="junit-present"
+ depends="test-junit-present"
+ unless="junit.present">
+ <property name="ant.libdir" location="${ant.home}/lib" />
+ <echo level="error">==================================== ERROR ====================================</echo>
+ <echo level="error"> JUnit is not present in your $ANT_HOME/lib directory, aborting build. </echo>
+ <echo level="error"> Please copy "junit.jar" to "${ant.libdir}". </echo>
+ <echo level="error">===============================================================================</echo>
+ <fail>JUnit not found on class path, cannot run unit tests.</fail>
+ </target>
+
+ ...
+</project>
++-----+
Propchange: maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/fail-missing-junit.apt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ant-plugin/src/site/apt/examples/fail-missing-junit.apt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/plugins/trunk/maven-ant-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/site/apt/index.apt?rev=640016&r1=640015&r2=640016&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/site/apt/index.apt (original)
+++ maven/plugins/trunk/maven-ant-plugin/src/site/apt/index.apt Sat Mar 22 10:22:21 2008
@@ -47,3 +47,5 @@
* {{{examples/customize.html}Customizing Generated Ant Build Files}}
* {{{examples/run-single-test.html}Running Individual Unit Tests}}
+
+ * {{{examples/fail-missing-junit.html}Failing the Build if JUnit is Missing}}
Modified: maven/plugins/trunk/maven-ant-plugin/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ant-plugin/src/site/site.xml?rev=640016&r1=640015&r2=640016&view=diff
==============================================================================
--- maven/plugins/trunk/maven-ant-plugin/src/site/site.xml (original)
+++ maven/plugins/trunk/maven-ant-plugin/src/site/site.xml Sat Mar 22 10:22:21 2008
@@ -34,6 +34,7 @@
<menu name="Examples">
<item name="Customizing Ant Build Files" href="/examples/customize.html"/>
<item name="Running Individual Unit Tests" href="/examples/run-single-test.html"/>
+ <item name="Failing if JUnit is Missing" href="/examples/fail-missing-junit.html"/>
</menu>
</body>
</project>