Methods Summary |
---|
public void | addConfiguredExtension(ExtensionAdapter extension)Set the Extension looking for.
if (null != requiredExtension) {
final String message = "Can not specify extension to "
+ "search for multiple times.";
throw new BuildException(message);
}
requiredExtension = extension;
|
public void | addConfiguredExtensionSet(ExtensionSet extensionSet)Adds a set of extensions to search in.
extensionFileSets.addElement(extensionSet);
|
public void | execute()Execute the task.
validate();
final Extension test = requiredExtension.toExtension();
// Check if list of files to check has been specified
if (!extensionFileSets.isEmpty()) {
final Iterator iterator = extensionFileSets.iterator();
while (iterator.hasNext()) {
final ExtensionSet extensionSet
= (ExtensionSet) iterator.next();
final Extension[] extensions =
extensionSet.toExtensions(getProject());
for (int i = 0; i < extensions.length; i++) {
final Extension extension = extensions[ i ];
if (extension.isCompatibleWith(test)) {
getProject().setNewProperty(propertyName, "true");
}
}
}
} else {
final Manifest manifest = ExtensionUtil.getManifest(libraryFile);
final Extension[] extensions = Extension.getAvailable(manifest);
for (int i = 0; i < extensions.length; i++) {
final Extension extension = extensions[ i ];
if (extension.isCompatibleWith(test)) {
getProject().setNewProperty(propertyName, "true");
}
}
}
|
public void | setFile(java.io.File file)The JAR library to check.
this.libraryFile = file;
|
public void | setProperty(java.lang.String property)The name of property to set if extensions are available.
this.propertyName = property;
|
private void | validate()Validate the tasks parameters.
if (null == requiredExtension) {
final String message = "Extension element must be specified.";
throw new BuildException(message);
}
if (null == libraryFile && extensionFileSets.isEmpty()) {
final String message = "File attribute not specified.";
throw new BuildException(message);
}
if (null != libraryFile && !libraryFile.exists()) {
final String message = "File '" + libraryFile + "' does not exist.";
throw new BuildException(message);
}
if (null != libraryFile && !libraryFile.isFile()) {
final String message = "\'" + libraryFile + "\' is not a file.";
throw new BuildException(message);
}
|