Search in sources :

Example 6 with Path

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);
}
Also used : Path(org.apache.tools.ant.types.Path)

Example 7 with Path

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());
    }
}
Also used : Path(org.apache.tools.ant.types.Path) Options(org.apache.felix.scrplugin.Options) SCRDescriptorFailureException(org.apache.felix.scrplugin.SCRDescriptorFailureException) SCRDescriptorGenerator(org.apache.felix.scrplugin.SCRDescriptorGenerator) Project(org.apache.tools.ant.Project) BuildException(org.apache.tools.ant.BuildException) SCRDescriptorException(org.apache.felix.scrplugin.SCRDescriptorException) Location(org.apache.tools.ant.Location)

Example 8 with Path

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);
}
Also used : Path(org.apache.tools.ant.types.Path) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) ArrayList(java.util.ArrayList) File(java.io.File) Artifact(org.apache.maven.artifact.Artifact)

Example 9 with Path

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;
}
Also used : Path(org.apache.tools.ant.types.Path) File(java.io.File)

Example 10 with Path

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;
}
Also used : Path(org.apache.tools.ant.types.Path)

Aggregations

Path (org.apache.tools.ant.types.Path)174 File (java.io.File)78 BuildException (org.apache.tools.ant.BuildException)55 Test (org.junit.Test)49 Project (org.apache.tools.ant.Project)28 IOException (java.io.IOException)24 Commandline (org.apache.tools.ant.types.Commandline)21 ArrayList (java.util.ArrayList)12 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)10 URL (java.net.URL)8 AntClassLoader (org.apache.tools.ant.AntClassLoader)7 Java (org.apache.tools.ant.taskdefs.Java)7 StringTokenizer (java.util.StringTokenizer)6 FileSet (org.apache.tools.ant.types.FileSet)6 Reference (org.apache.tools.ant.types.Reference)6 Resource (org.apache.tools.ant.types.Resource)6 Test (org.junit.jupiter.api.Test)6 GroovyClassLoader (groovy.lang.GroovyClassLoader)5 Enumeration (java.util.Enumeration)5 Vector (java.util.Vector)5