Browse Source

Optionally enable caching for <path>. Should help in situations like PR 45696

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@808421 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
abe9743630
3 changed files with 33 additions and 2 deletions
  1. +2
    -0
      WHATSNEW
  2. +13
    -1
      docs/manual/using.html
  3. +18
    -1
      src/main/org/apache/tools/ant/types/Path.java

+ 2
- 0
WHATSNEW View File

@@ -934,6 +934,8 @@ Other changes:
attribute different from the <classfileset>.
Bugzilla Report 37763.

* <path> can now optionally cache its contents.

Changes from Ant 1.7.0 TO Ant 1.7.1
=============================================



+ 13
- 1
docs/manual/using.html View File

@@ -551,6 +551,18 @@ you can define them with a <code>&lt;path&gt;</code> element at the
same level as <i>target</i>s, and reference them via their
<i>id</i> attribute--see <a href="#references">References</a> for an
example.</p>

<p>By default a path like structure will re-evaluate all nested
resource collections whenever it is used, which may lead to
unnecessary re-scanning of the filesystem. Since Ant 1.8.0 path has
an optional <i>cache</i> attribute, if it is set to true, the path
instance will only scan its nested resource collections once and
assume it doesn't change during the build anymore (the default
for <i>cache</i> still is <i>false</i>). Even if you are using the
path only in a single task it may improve overall performance to set
<i>cache</i> to <i>true</i> if you are using complex nested
constructs.</p>

<p>A path-like structure can include a reference to another path-like
structure (a path being itself a resource collection)
via nested <code>&lt;path&gt;</code> elements:</p>
@@ -563,7 +575,7 @@ via nested <code>&lt;path&gt;</code> elements:</p>
&lt;pathelement location=&quot;classes&quot;/&gt;
&lt;/path&gt;

&lt;path id=&quot;tests.path&quot;&gt;
&lt;path id=&quot;tests.path&quot; cache=&quot;true&quot;&gt;
&lt;path refid=&quot;base.path&quot;/&gt;
&lt;pathelement location=&quot;testclasses&quot;/&gt;
&lt;/path&gt;


+ 18
- 1
src/main/org/apache/tools/ant/types/Path.java View File

@@ -78,6 +78,11 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
public static Path systemBootClasspath =
new Path(null, System.getProperty("sun.boot.class.path"));

static {
systemClasspath.setCache(true);
systemBootClasspath.setCache(true);
}

private static final Iterator EMPTY_ITERATOR
= Collections.EMPTY_SET.iterator();

@@ -145,6 +150,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
private Boolean preserveBC;

private Union union = null;
private boolean cache = false;

/**
* Invoked by IntrospectionHelper for <code>setXXX(Path p)</code>
@@ -280,7 +286,7 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
if (union == null) {
union = new Union();
union.setProject(getProject());
union.setCache(false);
union.setCache(cache);
}
union.add(c);
setChecked(false);
@@ -348,6 +354,17 @@ public class Path extends DataType implements Cloneable, ResourceCollection {
}
}

/**
* Whether to cache the current path.
*/
public void setCache(boolean b) {
checkAttributesAllowed();
cache = b;
if (union != null) {
union.setCache(b);
}
}

/**
* Returns all path elements defined by this and nested path objects.
* @return list of path elements.


Loading…
Cancel
Save