![JAR search and dependency download from the Maven repository](/logo.png)
aQute.bnd.ant.BaseTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biz.aQute.bnd Show documentation
Show all versions of biz.aQute.bnd Show documentation
This command line utility is the Swiss army knife of OSGi. It provides you with a breadth of tools to understand and manage OSGi based systems. This project basically uses bndlib.
package aQute.bnd.ant;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Property;
import aQute.bnd.build.Workspace;
import aQute.bnd.osgi.Constants;
import aQute.libg.reporter.ReporterAdapter;
import aQute.libg.reporter.ReporterMessages;
import aQute.service.reporter.Reporter;
public class BaseTask extends Task implements Reporter {
ReporterAdapter reporter = new ReporterAdapter();
List errors = new ArrayList();
List warnings = new ArrayList();
List progress = new ArrayList();
boolean pedantic;
boolean trace;
String onfail;
final List properties = new LinkedList();
final List workspaceProps = new LinkedList();
final AntMessages messages = ReporterMessages.base(this, AntMessages.class);
boolean exceptions;
static {
Workspace.setDriver(Constants.BNDDRIVER_ANT);
Workspace.addGestalt(Constants.GESTALT_BATCH, null);
}
protected boolean report() {
return report(this);
}
protected boolean report(Reporter reporter) {
int errCount = reporter.getErrors().size();
if (errCount > 0) {
System.err.printf("%d ERRORS%n", errCount);
for (String e : reporter.getErrors()) {
System.err.println(" " + e);
}
return true;
}
int warnCount = reporter.getWarnings().size();
if (warnCount > 0) {
System.err.printf("%d WARNINGS%n", warnCount);
for (String w : reporter.getWarnings()) {
System.err.println(" " + w);
}
}
return false;
}
public static File getFile(File base, String file) {
File f = new File(file);
if (!f.isAbsolute()) {
int n;
f = base.getAbsoluteFile();
while ((n = file.indexOf('/')) > 0) {
String first = file.substring(0, n);
file = file.substring(n + 1);
if (first.equals(".."))
f = f.getParentFile();
else
f = new File(f, first);
}
f = new File(f, file);
}
try {
return f.getCanonicalFile();
} catch (IOException e) {
return f.getAbsoluteFile();
}
}
protected List split(String dependsOn, String string) {
if (dependsOn == null)
return new ArrayList();
return Arrays.asList(string.split("\\s*" + string + "\\s*"));
}
protected String join(Collection< ? > classpath, String string) {
StringBuilder sb = new StringBuilder();
String del = "";
for (Object name : classpath) {
sb.append(del);
sb.append(name);
del = string;
}
return sb.toString();
}
public boolean isPedantic() {
return pedantic;
}
public void setPedantic(boolean pedantic) {
this.pedantic = pedantic;
}
public void setTrace(boolean trace) {
this.trace = trace;
}
public boolean isTrace() {
return trace;
}
public void trace(String s, Object... args) {
if (trace) {
System.err.printf("# " + s + "%n", args);
}
}
public void addProperty(Property property) {
properties.add(property);
}
public void addWsproperty(Property property) {
workspaceProps.add(property);
}
public boolean isExceptions() {
return exceptions;
}
public void setExceptions(boolean exceptions) {
this.exceptions = exceptions;
}
public Location getLocation(String msg) {
return reporter.getLocation(msg);
}
public boolean isOk() {
return reporter.isOk();
}
public SetLocation exception(Throwable t, String format, Object... args) {
return reporter.exception(t, format, args);
}
public SetLocation error(String s, Object... args) {
return reporter.error(s, args);
}
public List getErrors() {
return reporter.getErrors();
}
public List getWarnings() {
return reporter.getWarnings();
}
public void progress(float progress, String s, Object... args) {
reporter.progress(progress, s, args);
}
public SetLocation warning(String s, Object... args) {
return reporter.warning(s, args);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy