I think that here should be a "whine" mode to activate these messages. They should not be done by default. Maybe a strict="yes" attribute.
Peter On 7/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Author: jhm Date: Fri Jul 6 05:19:28 2007 New Revision: 553857 URL: http://svn.apache.org/viewvc?view=rev&rev=553857 Log: Encourage people to follow the packaging spec. Modified: ant/core/trunk/build.xml 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/build.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/build.xml?view=diff&rev=553857&r1=553856&r2=553857 ============================================================================== --- ant/core/trunk/build.xml (original) +++ ant/core/trunk/build.xml Fri Jul 6 05:19:28 2007 @@ -1547,6 +1547,22 @@ <!-- Used by AntlibTest.testAntlibResource: --> <jar jarfile="${build.tests}/org/apache/tools/ant/taskdefs/test2-antlib.jar"> + <manifest> + <attribute name="Extension-name" + value="org.apache.tools.ant"/> + <attribute name="Specification-Title" + value="Apache Ant"/> + <attribute name="Specification-Version" + value="${manifest-version}"/> + <attribute name="Specification-Vendor" + value="Apache Software Foundation"/> + <attribute name="Implementation-Title" + value="org.apache.tools.ant"/> + <attribute name="Implementation-Version" + value="${manifest-version}"/> + <attribute name="Implementation-Vendor" + value="Apache Software Foundation"/> + </manifest> <zipfileset dir="${tests.etc.dir}" fullpath="taskdefs/test.antlib.xml"> <include name="taskdefs/test2.antlib.xml"/> </zipfileset> 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=553857&r1=553856&r2=553857 ============================================================================== --- ant/core/trunk/docs/manual/CoreTasks/jar.html (original) +++ ant/core/trunk/docs/manual/CoreTasks/jar.html Fri Jul 6 05:19:28 2007 @@ -73,14 +73,17 @@ include an empty one for you.)</p> <p>Manifests are processed by the Jar task according to the -<a href="http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html">Jar file specification.</a> +<a target="_blank" href="http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html">Jar file specification.</a> Note in particular that this may result in manifest lines greater than 72 bytes -being wrapped and continued on the next line. -</p> +being wrapped and continued on the next line.</p> + +<p>The Jar task checks whether you specified package information according to the +<a target="_blank" href="http://java.sun.com/j2se/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersioning"> +versioning specification</a>.</p> <p><b>Please note that the zip format allows multiple files of the same -fully-qualified name to exist within a single archive. This has been -documented as causing various problems for unsuspecting users. If you wish +fully-qualified name to exist within a single archive. This has been +documented as causing various problems for unsuspecting users. If you wish to avoid this behavior you must set the <code>duplicate</code> attribute to a value other than its default, <code>"add"</code>.</b></p> 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=553857&r1=553856&r2=553857 ============================================================================== --- ant/core/trunk/src/etc/testcases/taskdefs/jar.xml (original) +++ ant/core/trunk/src/etc/testcases/taskdefs/jar.xml Fri Jul 6 05:19:28 2007 @@ -236,5 +236,23 @@ </indexjars> </jar> </target> + + <target name="testNoVersionInfo"> + <mkdir dir="${tmp.dir}"/> + <jar destfile="${tmp.jar}" basedir="${tmp.dir}"/> + </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}"> + <manifest> + <attribute name="Implementation-Title" value="Packaging Version Test"/> + <attribute name="Implementation-Version" value="1.0"/> + <attribute name="Implementation-Vendor" value="Apache Software Foundation"/> + </manifest> + </jar> + </target> + + </project> 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=553857&r1=553856&r2=553857 ============================================================================== --- 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 Fri Jul 6 05:19:28 2007 @@ -45,6 +45,7 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.apache.tools.ant.taskdefs.Manifest.Section; import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.ResourceCollection; @@ -76,6 +77,7 @@ /** merged manifests added through addConfiguredManifest */ private Manifest configuredManifest; + /** shadow of the above if upToDate check alters the value */ private Manifest savedConfiguredManifest; @@ -158,7 +160,7 @@ setEncoding("UTF8"); rootEntries = new Vector(); } - + /** * Not used for jar files. * @param we not used @@ -773,6 +775,25 @@ */ protected void cleanUp() { super.cleanUp(); + + // check against packaging spec + // http://java.sun.com/j2se/1.3/docs/guide/versioning/spec/VersioningSpecification.html#PackageVersioning + Section mainSection = (configuredManifest==null) ? null : configuredManifest.getMainSection(); + if (mainSection==null) { + log("No Implementation-Title set. (" + getLocation() + ")"); + log("No Implementation-Version set. (" + getLocation() + ")"); + log("No Implementation-Vendor set. (" + getLocation() + ")"); + } else { + if (mainSection.getAttribute("Implementation-Title") == null) { + log("No Implementation-Title set. (" + getLocation() + ")"); + } + if (mainSection.getAttribute("Implementation-Version") == null) { + log("No Implementation-Version set. (" + getLocation() + ")"); + } + if (mainSection.getAttribute("Implementation-Vendor") == null) { + log("No Implementation-Vendor set. (" + getLocation() + ")"); + } + } // we want to save this info if we are going to make another pass if (!doubleFilePass || !skipWriting) { 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=553857&r1=553856&r2=553857 ============================================================================== --- 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 Fri Jul 6 05:19:28 2007 @@ -267,4 +267,19 @@ public void testIndexJarsPlusJarMarker() { executeTarget("testIndexJarsPlusJarMarker"); } + + public void testNoVersionInfo() { + executeTarget("testNoVersionInfo"); + assertLogContaining("No Implementation-Title set."); + assertLogContaining("No Implementation-Version set."); + assertLogContaining("No Implementation-Vendor set."); + } + + public void testHasVersionInfo() { + executeTarget("testHasVersionInfo"); + assertFalse( getLog().contains("No Implementation-Title set.") ); + assertFalse( getLog().contains("No Implementation-Version set.") ); + assertFalse( getLog().contains("No Implementation-Vendor set.") ); + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]