Author: jhm
Date: Wed Jul 18 07:11:50 2007
New Revision: 557270
URL: http://svn.apache.org/viewvc?view=rev&rev=557270
Log:
Spec breaks now can 'fail' the build or just be reported on 'warn' or verbose
('ignore') level.
Modified:
ant/core/trunk/docs/manual/CoreTasks/jar.html
ant/core/trunk/src/etc/testcases/taskdefs/jar.xml
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java
Modified: ant/core/trunk/docs/manual/CoreTasks/jar.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/jar.html?view=diff&rev=557270&r1=557269&r2=557270
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/jar.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/jar.html Wed Jul 18 07:11:50 2007
@@ -230,11 +230,14 @@
</tr>
<tr>
<td valign="top">strict</td>
- <td valign="top">When this attribut is set to <tt>true</tt>, a
BuildException
- will be thrown if the packaging version specification was broken. If set
to
- <tt>false</tt> (default) only a message is logged (verbose).
- <br>Defaults to false. <em>Since Ant 1.7.1</em></td>
- <td valign="top" align="center">No</td>
+ <td valign="top">Configures how to handle breaks of the packaging version
+ specification: <ul>
+ <li><b>fail</b> = throws a BuildException</li>
+ <li><b>warn</b> = logs a message on warn level</li>
+ <li><b>ignore</b> = logs a message on verbose level (default)</li>
+ </ul>
+ <em>Since Ant 1.7.1</em></td>
+ <td valign="top" align="center">No, defaults to <tt>ignore</tt>. </td>
</tr>
</table>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/jar.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/jar.xml?view=diff&rev=557270&r1=557269&r2=557270
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/jar.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/jar.xml Wed Jul 18 07:11:50 2007
@@ -237,20 +237,30 @@
</jar>
</target>
- <target name="testNoVersionInfo">
+ <target name="testNoVersionInfoNoStrict">
<mkdir dir="${tmp.dir}"/>
- <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="true"/>
+ <jar destfile="${tmp.jar}" basedir="${tmp.dir}"/>
</target>
- <target name="testNoVersionInfoNoStrict">
+ <target name="testNoVersionInfoFail">
<mkdir dir="${tmp.dir}"/>
- <jar destfile="${tmp.jar}" basedir="${tmp.dir}"/>
+ <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="fail"/>
</target>
+ <target name="testNoVersionInfoIgnore">
+ <mkdir dir="${tmp.dir}"/>
+ <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="ignore"/>
+ </target>
+
+ <target name="testNoVersionInfoWarn">
+ <mkdir dir="${tmp.dir}"/>
+ <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="warn"/>
+ </target>
+
<!-- see
http://java.sun.com/j2se/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersioning
-->
<target name="testHasVersionInfo">
<mkdir dir="${tmp.dir}"/>
- <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="true">
+ <jar destfile="${tmp.jar}" basedir="${tmp.dir}" strict="fail">
<manifest>
<attribute name="Implementation-Title" value="Packaging Version
Test"/>
<attribute name="Implementation-Version" value="1.0"/>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java?view=diff&rev=557270&r1=557269&r2=557270
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Jar.java Wed Jul 18
07:11:50 2007
@@ -143,11 +143,13 @@
*/
private Path indexJars;
+ // CheckStyle:LineLength OFF - Link is too long.
/**
* Strict mode for checking rules of the JAR-Specification.
* @see
http://java.sun.com/j2se/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersioning
*/
- private boolean strict = false;
+ private StrictMode strict;
+ // CheckStyle:LineLength ON
/**
* Extra fields needed to make Solaris recognize the archive as a jar file.
@@ -165,6 +167,7 @@
emptyBehavior = "create";
setEncoding("UTF8");
rootEntries = new Vector();
+ strict = new StrictMode("ignore");
}
/**
@@ -196,8 +199,8 @@
* will be thrown if the Jar-Packaging specification was broken.
* @param strict New value of the strict mode.
*/
- public void setStrict(boolean strict) {
- this.strict = strict;
+ public void setStrict(String strict) {
+ this.strict = new StrictMode(strict);
}
/**
@@ -802,15 +805,17 @@
rootEntries.removeAllElements();
}
+ // CheckStyle:LineLength OFF - Link is too long.
/**
* Check against packaging spec
* @see
http://java.sun.com/j2se/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersioning
*/
+ // CheckStyle:LineLength ON
private void checkJarSpec() {
String br = System.getProperty("line.separator");
StringBuffer message = new StringBuffer();
Section mainSection = (configuredManifest == null)
- ? null
+ ? null
: configuredManifest.getMainSection();
if (mainSection == null) {
@@ -833,10 +838,10 @@
message.append(br);
message.append("Location: ").append(getLocation());
message.append(br);
- if (strict) {
+ if (strict.getValue().equalsIgnoreCase("fail")) {
throw new BuildException(message.toString(), getLocation());
} else {
- log(message.toString(), Project.MSG_VERBOSE);
+ log(message.toString(), strict.getLogLevel());
}
}
}
@@ -1025,4 +1030,25 @@
}
}
}
+
+ // CheckStyle:JavadocType OFF - simple enum
+ public class StrictMode extends EnumeratedAttribute {
+ // CheckStyle:JavadocMethod OFF - simple enum
+ public StrictMode() {
+ }
+ public StrictMode(String value) {
+ setValue(value);
+ }
+ public String[] getValues() {
+ return new String[]{"fail", "warn", "ignore"};
+ }
+ /**
+ * @return The log level according to the strict mode.
+ */
+ public int getLogLevel() {
+ return (getValue().equals("ignore")) ? Project.MSG_VERBOSE :
Project.MSG_WARN;
+ }
+ // CheckStyle:JavadocMethod ON
+ }
+ // CheckStyle:JavadocType ON
}
Modified:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java?view=diff&rev=557270&r1=557269&r2=557270
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java
(original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java
Wed Jul 18 07:11:50 2007
@@ -268,8 +268,22 @@
executeTarget("testIndexJarsPlusJarMarker");
}
- public void testNoVersionInfo() {
- expectBuildExceptionContaining("testNoVersionInfo", "Manifest
Implemention information missing.", "No Implementation-Title set.");
+ public void testNoVersionInfoFail() {
+ expectBuildExceptionContaining("testNoVersionInfoFail", "Manifest
Implemention information missing.", "No Implementation-Title set.");
+ }
+
+ public void testNoVersionInfoIgnore() {
+ executeTarget("testNoVersionInfoIgnore");
+ assertTrue( getFullLog().contains("No Implementation-Title set.") );
+ assertTrue( getFullLog().contains("No Implementation-Version set.") );
+ assertTrue( getFullLog().contains("No Implementation-Vendor set.") );
+ }
+
+ public void testNoVersionInfoWarn() {
+ executeTarget("testNoVersionInfoWarn");
+ assertTrue( getLog().contains("No Implementation-Title set.") );
+ assertTrue( getLog().contains("No Implementation-Version set.") );
+ assertTrue( getLog().contains("No Implementation-Vendor set.") );
}
public void testNoVersionInfoNoStrict() {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]