Index: ant/project/apichanges.xml =================================================================== RCS file: /cvs/ant/project/apichanges.xml,v retrieving revision 1.2 diff -u -b -r1.2 apichanges.xml --- ant/project/apichanges.xml 23 Dec 2004 22:01:54 -0000 1.2 +++ ant/project/apichanges.xml 4 Jan 2005 09:27:43 -0000 @@ -96,6 +96,43 @@ + + + AntArtifact enhancements + + + + +

+ New schema was defined, but upgrade from old schema to new + one is realized only after some new features are used. If + project's artifact does not define any properties for + artifact nor produce multiple outputs and Ant script lies + under the project's directory then old schema is + always used. Once project start using some of these new + features the schema will be upgraded automatically to new + version. This affects any project type which is using + ant/project module. +

+
+ +

+ Several enhancements of AntArtifact were implemented: +

+
    +
  1. execution of artifact's target can be customized by properties
  2. +
  3. artifact can produce several build outputs
  4. +
  5. Ant script path is not persisted as URI, but string possibly containing Ant properties
  6. +
+

+ ReferenceHelper class was simplified as part of the implementation. +

+
+ + + +
+ Index: ant/project/src/org/netbeans/api/project/ant/AntArtifact.java =================================================================== RCS file: /cvs/ant/project/src/org/netbeans/api/project/ant/AntArtifact.java,v retrieving revision 1.9 diff -u -b -r1.9 AntArtifact.java --- ant/project/src/org/netbeans/api/project/ant/AntArtifact.java 18 Jun 2004 02:58:29 -0000 1.9 +++ ant/project/src/org/netbeans/api/project/ant/AntArtifact.java 4 Jan 2005 09:27:43 -0000 @@ -17,6 +17,8 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; +import java.util.ArrayList; +import java.util.Properties; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.openide.ErrorManager; @@ -38,6 +40,8 @@ */ public abstract class AntArtifact { + private final Properties PROPS = new Properties(); + /** * Empty constructor for use from subclasses. */ @@ -86,11 +90,32 @@ /** * Get the location of the build artifact relative to the Ant script. - * For example, dist/mylib.jar. + * See {@link #getArtifactLocations}. * @return a URI to the build artifact, resolved relative to {@link #getScriptLocation}; * may be either relative, or an absolute file-protocol URI + * @deprecated use {@link #getArtifactLocations} instead + */ + public URI getArtifactLocation() { + // XXX: diagnostic thread dump - this method should not be called anymore + Thread.dumpStack(); + return getArtifactLocations()[0]; + } + + /** + * Get the locations of the build artifacts relative to the Ant script. + * For example, dist/mylib.jar. The method is not defined + * as abstract only for backward compatibility reasons. It has to be + * always overriden. The order is important and should stay the same + * unless the artifact was changed. + * @return an array of URIs to the build artifacts, resolved relative to {@link #getScriptLocation}; + * may be either relative, or an absolute file-protocol URI + * @since X.XX */ - public abstract URI getArtifactLocation(); + public URI[] getArtifactLocations() { + // XXX: diagnostic thread dump - this method must be always overriden + Thread.dumpStack(); + return new URI[]{getArtifactLocation()}; + } /** * Returns identifier of the AntArtifact which must be unique within @@ -104,22 +129,29 @@ /** * Convenience method to find the actual artifact, if it currently exists. - * Uses {@link #getScriptFile} or {@link #getScriptLocation} and resolves {@link #getArtifactLocation} from it. - * Note that a project which has been cleaned more recently than it has been built - * will generally not have the build artifact on disk and so this call may easily - * return null. If you do not rely on the actual presence of the file but just need to - * refer to it abstractly, use {@link #getArtifactLocation} instead. + * See {@link #getArtifactFiles}. * @return the artifact file on disk, or null if it could not be found + * @deprecated use {@link #getArtifactFiles} instead */ public final FileObject getArtifactFile() { - URI artifactLocation = getArtifactLocation(); + // XXX: diagnostic thread dump - do not call this method + Thread.dumpStack(); + FileObject fos[] = getArtifactFiles(); + if (fos.length > 0) { + return fos[0]; + } else { + return null; + } + } + + private FileObject getArtifactFile(URI artifactLocation) { assert !artifactLocation.isAbsolute() || (!artifactLocation.isOpaque() && "file".equals(artifactLocation.getScheme())) // NOI18N : artifactLocation; URL artifact; try { // XXX this should probably use something in PropertyUtils? - artifact = getScriptLocation().toURI().resolve(getArtifactLocation()).normalize().toURL(); + artifact = getScriptLocation().toURI().resolve(artifactLocation).normalize().toURL(); } catch (MalformedURLException e) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); return null; @@ -134,6 +166,28 @@ } /** + * Convenience method to find the actual artifacts, if they currently exist. + * Uses {@link #getScriptFile} or {@link #getScriptLocation} and resolves {@link #getArtifactLocations} from it. + * Note that a project which has been cleaned more recently than it has been built + * will generally not have the build artifacts on disk and so this call may easily + * return empty array. If you do not rely on the actual presence of the file but just need to + * refer to it abstractly, use {@link #getArtifactLocations} instead. + * @return the artifact files which exist on disk, or empty array if none could be found + * @since X.XX + */ + public final FileObject[] getArtifactFiles() { + URI artifactLocations[] = getArtifactLocations(); + ArrayList l = new ArrayList(); + for (int i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: ant/project/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java =================================================================== RCS file: /cvs/ant/project/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java,v retrieving revision 1.20 diff -u -b -r1.20 ReferenceHelper.java --- ant/project/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java 26 Oct 2004 18:44:30 -0000 1.20 +++ ant/project/src/org/netbeans/spi/project/support/ant/ReferenceHelper.java 4 Jan 2005 09:27:43 -0000 @@ -19,9 +19,11 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.netbeans.api.project.Project; @@ -84,6 +86,11 @@ */ static final String REFS_NS = "http://www.netbeans.org/ns/ant-project-references/1"; // NOI18N + /** + * Newer version of {@link #REFS_NS} supporting Properties and with changed semantics of