use of org.apache.tools.ant.types.Path in project felix by apache.
the class SCRDescriptorTask method getClassLoader.
private ClassLoader getClassLoader(final ClassLoader parent) throws BuildException {
Path classPath = createClasspath();
log("Using classes from: " + classPath, Project.MSG_DEBUG);
return getProject().createClassLoader(parent, classpath);
}
use of org.apache.tools.ant.types.Path in project felix by apache.
the class SCRDescriptorTask method execute.
@Override
public void execute() throws BuildException {
// ensure we know the source
if (getImplicitFileSet().getDir() == null) {
throw new BuildException("srcdir attribute must be set!", getLocation());
}
// while debugging
final org.apache.felix.scrplugin.Log scrLog = new AntLog(this);
scrLog.debug("SCRDescriptorTask Configuration");
scrLog.debug(" implicitFileset: " + getImplicitFileSet());
scrLog.debug(" outputDirectory: " + destdir);
scrLog.debug(" classpath: " + classpath);
scrLog.debug(" generateAccessors: " + generateAccessors);
scrLog.debug(" strictMode: " + strictMode);
scrLog.debug(" specVersion: " + specVersion);
try {
final Path classPath = createClasspath();
final org.apache.felix.scrplugin.Project project = new org.apache.felix.scrplugin.Project();
project.setClassLoader(getClassLoader(this.getClass().getClassLoader()));
project.setDependencies(getDependencies(classPath));
project.setSources(getSourceFiles(getImplicitFileSet()));
project.setClassesDirectory(destdir.getAbsolutePath());
// create options
final Options options = new Options();
options.setOutputDirectory(destdir);
options.setGenerateAccessors(generateAccessors);
options.setStrictMode(strictMode);
options.setProperties(new HashMap<String, String>());
options.setSpecVersion(SpecVersion.fromName(specVersion));
if (specVersion != null && options.getSpecVersion() == null) {
throw new BuildException("Unknown spec version specified: " + specVersion);
}
final SCRDescriptorGenerator generator = new SCRDescriptorGenerator(scrLog);
// setup from plugin configuration
generator.setOptions(options);
generator.setProject(project);
generator.execute();
} catch (final SCRDescriptorException sde) {
if (sde.getSourceLocation() != null) {
final Location loc = new Location(sde.getSourceLocation(), -1, 0);
throw new BuildException(sde.getMessage(), sde.getCause(), loc);
}
throw new BuildException(sde.getMessage(), sde.getCause());
} catch (SCRDescriptorFailureException sdfe) {
throw new BuildException(sdfe.getMessage(), sdfe.getCause());
}
}
use of org.apache.tools.ant.types.Path in project cuke4duke by cucumber.
the class AbstractJRubyMojo method append.
protected void append(Path classPath, List<?> artifacts) throws DependencyResolutionRequiredException {
List<String> list = new ArrayList<String>(artifacts.size());
for (Object elem : artifacts) {
String path;
if (elem instanceof Artifact) {
Artifact a = (Artifact) elem;
File file = a.getFile();
if (file == null) {
throw new DependencyResolutionRequiredException(a);
}
path = file.getPath();
} else {
path = elem.toString();
}
list.add(path);
}
Path p = new Path(classPath.getProject());
p.setPath(StringUtils.join(list.iterator(), File.pathSeparator));
classPath.append(p);
}
use of org.apache.tools.ant.types.Path in project bnd by bndtools.
the class BndTask method setClasspath.
public void setClasspath(String value) {
Path p = (Path) getProject().getReference(value);
if (p == null)
addAll(classpath, value, File.pathSeparator + ",");
else {
String[] path = p.list();
for (int i = 0; i < path.length; i++) {
File f = new File(path[i]);
if (f.exists())
classpath.add(f);
else
messages.NoSuchFile_(f.getAbsoluteFile());
}
}
classpathDirectlySet = true;
}
use of org.apache.tools.ant.types.Path in project bnd by bndtools.
the class BndTask method createPath.
private Path createPath(Reference r) {
Path path = new Path(getProject()).createPath();
path.setRefid(r);
return path;
}
Aggregations