Browse Source

Issue a warning in case neither includeantruntime nor build.sysclasspath were set,

since the default gives scripts an implicit environmental dependency which is often unwanted.
See also: http://www.netbeans.org/nonav/issues/show_bug.cgi?id=158958


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@789479 13f79535-47bb-0310-9956-ffa450edef68
master
Jesse N. Glick 16 years ago
parent
commit
82ae2eb245
3 changed files with 22 additions and 15 deletions
  1. +4
    -1
      docs/manual/CoreTasks/javac.html
  2. +10
    -11
      docs/manual/sysclasspath.html
  3. +8
    -3
      src/main/org/apache/tools/ant/taskdefs/Javac.java

+ 4
- 1
docs/manual/CoreTasks/javac.html View File

@@ -290,7 +290,10 @@ invoking the compiler.</p>
<tr>
<td valign="top">includeAntRuntime</td>
<td valign="top">Whether to include the Ant run-time libraries in the
classpath; defaults to <code>yes</code>.</td>
classpath; defaults to <code>yes</code>, unless
<a href="../sysclasspath.html"><code>build.sysclasspath</code></a> is set.
<em>It is usually best to set this to false</em> so the script's behavior is not
sensitive to the environment in which it is run.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>


+ 10
- 11
docs/manual/sysclasspath.html View File

@@ -26,33 +26,34 @@

<h2><a name="sysclasspath">build.sysclasspath</a></h2>
<p>The value of the build.sysclasspath property
control how the system classpath, ie. the classpath in effect when
Ant is run, affects the behaviour of classpaths in Ant.
The default behavior varies from Ant to Ant task.</p>
controls how the system classpath, i.e. the classpath in effect when
Ant is run, affects the behavior of classpaths in Ant.
The default behavior varies from task to task.</p>

The values and their meanings are:

<table cellspacing="20">
<tr><th>value</th><th>meaning</th></tr>
<tr>
<th align="left" valign="top">only</th>
<td align="left" valign="top">only</td>
<td>Only the system classpath is used and classpaths specified in build files,
etc are ignored. This situation could be considered as the person running
the build file knows more about the environment than the person writing the
build file
build file.
</td>
</tr>

<tr>
<th align="left" valign="top">ignore</th>
<td align="left" valign="top">ignore</td>
<td>
The system classpath is ignored. This situation is the reverse of the
above. The person running the build trusts the build file writer to get the
build file right
build file right. This mode is recommended for portable scripts.
</td>
</tr>

<tr>
<th align="left" valign="top">last</th>
<td align="left" valign="top">last</td>
<td>
The classpath is concatenated to any specified classpaths at the end. This
is a compromise, where the build file writer has priority.
@@ -60,7 +61,7 @@ is a compromise, where the build file writer has priority.
</tr>

<tr>
<th align="left" valign="top">first</th>
<td align="left" valign="top">first</td>
<td>
Any specified classpaths are concatenated to the system classpath. This is
the other form of compromise where the build runner has priority.
@@ -74,7 +75,5 @@ specified for a task with the bootclasspath of the Java VM running
Ant. If the property has not been set, it defaults to "ignore" in
this case.</p>


</body>
</html>


+ 8
- 3
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -104,7 +104,7 @@ public class Javac extends MatchingTask {
private String targetAttribute;
private Path bootclasspath;
private Path extdirs;
private boolean includeAntRuntime = true;
private Boolean includeAntRuntime;
private boolean includeJavaRuntime = false;
private boolean fork = false;
private String forkedExecutable = null;
@@ -619,7 +619,7 @@ public class Javac extends MatchingTask {
* @param include if true, includes Ant's own classpath in the classpath
*/
public void setIncludeantruntime(boolean include) {
includeAntRuntime = include;
includeAntRuntime = Boolean.valueOf(include);
}

/**
@@ -627,7 +627,7 @@ public class Javac extends MatchingTask {
* @return whether or not the ant classpath is to be included in the classpath
*/
public boolean getIncludeantruntime() {
return includeAntRuntime;
return includeAntRuntime != null ? includeAntRuntime.booleanValue() : true;
}

/**
@@ -1039,6 +1039,11 @@ public class Javac extends MatchingTask {
+ "\" does not exist "
+ "or is not a directory", getLocation());
}
if (includeAntRuntime == null && getProject().getProperty("build.sysclasspath") == null) {
log(getLocation() + "warning: 'includeantruntime' was not set, " +
"defaulting to build.sysclasspath=last; set to false for repeatable builds",
Project.MSG_WARN);
}
}

/**


Loading…
Cancel
Save