Author: bodewig
Date: Tue Apr 11 11:19:57 2006
New Revision: 393282
URL: http://svn.apache.org/viewcvs?rev=393282&view=rev
Log:
provide magic properties to control javac
Added:
ant/core/trunk/docs/manual/javacprops.html (with props)
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/docs/manual/CoreTasks/javac.html
ant/core/trunk/docs/manual/CoreTasks/javadoc.html
ant/core/trunk/docs/manual/conceptstypeslist.html
ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/WHATSNEW?rev=393282&r1=393281&r2=393282&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Apr 11 11:19:57 2006
@@ -376,7 +376,11 @@
dare not change for fear of breaking complex SQL operations in
existing files.
-* <javadoc>'s packagenames attribute is now optional and default to "*".
+* <javadoc>'s packagenames attribute is now optional and defaults to "*".
+
+* <javac>'s source and target attributes as well as <javadoc>'s source
+ attribute will read default values from the properties
+ ant.build.javac.source and ant.build.javac.target.
Changes from Ant 1.6.4 to Ant 1.6.5
===================================
Modified: ant/core/trunk/docs/manual/CoreTasks/javac.html
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/docs/manual/CoreTasks/javac.html?rev=393282&r1=393281&r2=393282&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/javac.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/javac.html Tue Apr 11 11:19:57 2006
@@ -241,7 +241,12 @@
particular, if you use JDK 1.4+ the generated classes will not be
usable for a 1.1 Java VM unless you explicitly set this attribute
to the value 1.1 (which is the default value for JDK 1.1 to
- 1.3). We highly recommend to always specify this attribute.</b></td>
+ 1.3). We highly recommend to always specify this
+ attribute.</b><br>
+ A default value for this attribute can be provided using the magic
+ <a
+ href="../javacprops.html#target"><code>ant.build.javac.target</code></a>
+ property.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
@@ -322,7 +327,11 @@
at all.<br>
<b>Note that the default value depends on the JVM that is running
Ant. We highly recommend to always specify this
- attribute.</b></td>
+ attribute.</b><br>
+ A default value for this attribute can be provided using the magic
+ <a
+ href="../javacprops.html#source"><code>ant.build.javac.source</code></a>
+ property.</td>
<td align="center" valign="top">No</td>
</tr>
Modified: ant/core/trunk/docs/manual/CoreTasks/javadoc.html
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/docs/manual/CoreTasks/javadoc.html?rev=393282&r1=393281&r2=393282&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/javadoc.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/javadoc.html Tue Apr 11 11:19:57 2006
@@ -407,7 +407,11 @@
<td valign="top">Necessary to enable javadoc to handle assertions
present in J2SE v 1.4 source code. Set this to "1.4" to
documents code that compiles using <code>"javac -source
- 1.4"</code>.</td>
+ 1.4"</code>.<br>
+ A default value for this attribute can be provided using the magic
+ <a
+ href="../javacprops.html#source"><code>ant.build.javac.source</code></a>
+ property.</td>
<td align="center" valign="top">1.4+</td>
<td align="center" valign="top">No</td>
</tr>
Modified: ant/core/trunk/docs/manual/conceptstypeslist.html
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/docs/manual/conceptstypeslist.html?rev=393282&r1=393281&r2=393282&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/conceptstypeslist.html (original)
+++ ant/core/trunk/docs/manual/conceptstypeslist.html Tue Apr 11 11:19:57 2006
@@ -14,6 +14,7 @@
<h3>Concepts</h3>
<a href="clonevm.html">ant.build.clonevm</a><br>
<a href="sysclasspath.html">build.sysclasspath</a><br>
+<a href="javacprops.html">Ant properties controlling javac</a><br>
<a href="CoreTasks/common.html">Common Attributes</a><br>
<h3>Core Types</h3>
Added: ant/core/trunk/docs/manual/javacprops.html
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/docs/manual/javacprops.html?rev=393282&view=auto
==============================================================================
--- ant/core/trunk/docs/manual/javacprops.html (added)
+++ ant/core/trunk/docs/manual/javacprops.html Tue Apr 11 11:19:57 2006
@@ -0,0 +1,39 @@
+<html>
+
+<head>
+<meta http-equiv="Content-Language" content="en-us">
+<link rel="stylesheet" type="text/css" href="stylesheets/style.css">
+<title>Properties controlling javac</title>
+</head>
+
+<body>
+
+<p>The source and target attributes of <code><javac></code>
+don't have any default values for historical reasons. Since the
+underlying javac compiler's default depends on the JDK you use, you
+may encounter build files that don't explicitly set those attributes
+and that will no longer compile using a newer JDK. If you cannot
+change the build file, Ant provides two properties that help you
+setting default values for these attributes. If the attributes have
+been set explicitly, the properties listed here will be ignored.</p>
+
+<h2><a name="source">ant.build.javac.source</a></h2>
+
+<p><em>Since Ant 1.7</em></p>
+
+<p>Provides a default value for <code><javac></code>'s and
+<code><javadoc></code>'s source attribute.</p>
+
+<h2><a name="target">ant.build.javac.target</a></h2>
+
+<p><em>Since Ant 1.7</em></p>
+
+<p>Provides a default value for <code><javac></code>'s target
+attribute.</p>
+
+<hr>
+<p align="center">Copyright © 2006 The Apache Software Foundation. All
rights
+Reserved.</p>
+</body>
+</html>
+
Propchange: ant/core/trunk/docs/manual/javacprops.html
------------------------------------------------------------------------------
svn:eol-style = native
Modified: ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java?rev=393282&r1=393281&r2=393282&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/MagicNames.java Tue Apr 11
11:19:57 2006
@@ -128,5 +128,21 @@
*/
public static final String REGEXP_IMPL = "ant.regexp.regexpimpl";
+ /**
+ * property that provides the default value for javac's and
+ * javadoc's source attribute.
+ * @since Ant 1.7
+ * Value: [EMAIL PROTECTED]
+ */
+ public static final String BUILD_JAVAC_SOURCE = "ant.build.javac.source";
+
+ /**
+ * property that provides the default value for javac's target
+ * attribute.
+ * @since Ant 1.7
+ * Value: [EMAIL PROTECTED]
+ */
+ public static final String BUILD_JAVAC_TARGET = "ant.build.javac.target";
+
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java?rev=393282&r1=393281&r2=393282&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javac.java Tue Apr 11
11:19:57 2006
@@ -20,6 +20,7 @@
import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.MagicNames;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter;
import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory;
@@ -161,7 +162,8 @@
* @return value of source.
*/
public String getSource() {
- return source;
+ return source != null
+ ? source : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE);
}
/**
@@ -586,7 +588,9 @@
* @return the target VM
*/
public String getTarget() {
- return targetAttribute;
+ return targetAttribute != null
+ ? targetAttribute
+ : getProject().getProperty(MagicNames.BUILD_JAVAC_TARGET);
}
/**
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java?rev=393282&r1=393281&r2=393282&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Tue Apr
11 11:19:57 2006
@@ -33,6 +33,7 @@
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.MagicNames;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.Task;
@@ -1912,9 +1913,11 @@
}
}
- if (source != null) {
+ String sourceArg = source != null ? source
+ : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE);
+ if (sourceArg != null) {
toExecute.createArgument().setValue("-source");
- toExecute.createArgument().setValue(source);
+ toExecute.createArgument().setValue(sourceArg);
}
if (linksource && doclet == null) {
Modified:
ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java?rev=393282&r1=393281&r2=393282&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java
(original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java
Tue Apr 11 11:19:57 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2002,2004-2005 The Apache Software Foundation
+ * Copyright 2001-2002,2004-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.
@@ -212,4 +212,33 @@
assertTrue(adapter instanceof JavacExternal);
}
+ public void testSourceNoDefault() {
+ assertNull(javac.getSource());
+ }
+
+ public void testSourceWithDefault() {
+ project.setNewProperty("ant.build.javac.source", "1.4");
+ assertEquals("1.4", javac.getSource());
+ }
+
+ public void testSourceOverridesDefault() {
+ project.setNewProperty("ant.build.javac.source", "1.4");
+ javac.setSource("1.5");
+ assertEquals("1.5", javac.getSource());
+ }
+
+ public void testTargetNoDefault() {
+ assertNull(javac.getTarget());
+ }
+
+ public void testTargetWithDefault() {
+ project.setNewProperty("ant.build.javac.target", "1.4");
+ assertEquals("1.4", javac.getTarget());
+ }
+
+ public void testTargetOverridesDefault() {
+ project.setNewProperty("ant.build.javac.target", "1.4");
+ javac.setTarget("1.5");
+ assertEquals("1.5", javac.getTarget());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]