Browse Source

add uri attribute to typefound type

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278308 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
5a8d0dcb27
2 changed files with 22 additions and 3 deletions
  1. +8
    -1
      docs/manual/CoreTasks/conditions.html
  2. +14
    -2
      src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java

+ 8
- 1
docs/manual/CoreTasks/conditions.html View File

@@ -425,6 +425,13 @@ tasks, datatypes, scriptdefs, macrodefs and presetdefs.</p>
<td valign="top">name of the type</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">uri</td>
<td valign="top">
The uri that this type lives in.
</td>
<td valign="top" align="center">No</td>
</tr>
</table>

<p>
@@ -433,7 +440,7 @@ tasks, datatypes, scriptdefs, macrodefs and presetdefs.</p>
<blockquote>
<pre>
&lt;typefound name="junit"/&gt;
&lt;typefound name="antlib:org.apache.maven.artifact.ant:artifact"/&gt;
&lt;typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/&gt;
</pre></blockquote>

<h4>scriptcondition</h4>


+ 14
- 2
src/main/org/apache/tools/ant/taskdefs/condition/TypeFound.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2004 The Apache Software Foundation
* Copyright 2004-2005 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.
@@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs.condition;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ComponentHelper;
import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.AntTypeDefinition;

/**
@@ -30,6 +31,7 @@ import org.apache.tools.ant.AntTypeDefinition;
public class TypeFound extends ProjectComponent implements Condition {

private String name;
private String uri;

/**
* the task or other type to look for
@@ -39,6 +41,15 @@ public class TypeFound extends ProjectComponent implements Condition {
this.name = name;
}

/**
* The URI for this definition.
* @param uri the namespace URI. If this is not set, use the
* default namespace.
*/
public void setURI(String uri) {
this.uri = uri;
}

/**
* test for a task or other ant type existing in the current project
* @param typename the name of the type
@@ -48,7 +59,8 @@ public class TypeFound extends ProjectComponent implements Condition {

ComponentHelper helper =
ComponentHelper.getComponentHelper(getProject());
AntTypeDefinition def = helper.getDefinition(typename);
AntTypeDefinition def = helper.getDefinition(
ProjectHelper.genComponentName(uri, typename));
if (def == null) {
return false;
}


Loading…
Cancel
Save