+ 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: +
++ ReferenceHelper class was simplified as part of the implementation. +
+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