Search in sources :

Example 71 with Path

use of org.apache.tools.ant.types.Path in project maven-plugins by apache.

the class AntRunMojo method addAntProjectReferences.

private void addAntProjectReferences(MavenProject mavenProject, Project antProject) throws DependencyResolutionRequiredException {
    Path p = new Path(antProject);
    p.setPath(StringUtils.join(mavenProject.getCompileClasspathElements().iterator(), File.pathSeparator));
    /* maven.dependency.classpath it's deprecated as it's equal to maven.compile.classpath */
    antProject.addReference(MAVEN_REFID_PREFIX + "dependency.classpath", p);
    antProject.addReference(MAVEN_REFID_PREFIX + "compile.classpath", p);
    p = new Path(antProject);
    p.setPath(StringUtils.join(mavenProject.getRuntimeClasspathElements().iterator(), File.pathSeparator));
    antProject.addReference(MAVEN_REFID_PREFIX + "runtime.classpath", p);
    p = new Path(antProject);
    p.setPath(StringUtils.join(mavenProject.getTestClasspathElements().iterator(), File.pathSeparator));
    antProject.addReference(MAVEN_REFID_PREFIX + "test.classpath", p);
    /* set maven.plugin.classpath with plugin dependencies */
    antProject.addReference(MAVEN_REFID_PREFIX + "plugin.classpath", getPathFromArtifacts(pluginArtifacts, antProject));
    antProject.addReference(DEFAULT_MAVEN_PROJECT_REFID, mavenProject);
    antProject.addReference(DEFAULT_MAVEN_PROJECT_REF_REFID, new MavenAntRunProject(mavenProject));
    antProject.addReference(DEFAULT_MAVEN_PROJECT_HELPER_REFID, projectHelper);
    antProject.addReference(MAVEN_REFID_PREFIX + "local.repository", localRepository);
}
Also used : Path(org.apache.tools.ant.types.Path)

Example 72 with Path

use of org.apache.tools.ant.types.Path in project maven-plugins by apache.

the class AntRunMojo method getPathFromArtifacts.

/**
 * @param artifacts {@link Artifact} collection.
 * @param antProject {@link Project}
 * @return {@link Path}
 * @throws DependencyResolutionRequiredException In case of a failure.
 */
private Path getPathFromArtifacts(Collection<Artifact> artifacts, Project antProject) throws DependencyResolutionRequiredException {
    if (artifacts == null) {
        return new Path(antProject);
    }
    List<String> list = new ArrayList<String>(artifacts.size());
    for (Artifact a : artifacts) {
        File file = a.getFile();
        if (file == null) {
            throw new DependencyResolutionRequiredException(a);
        }
        list.add(file.getPath());
    }
    Path p = new Path(antProject);
    p.setPath(StringUtils.join(list.iterator(), File.pathSeparator));
    return 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 73 with Path

use of org.apache.tools.ant.types.Path in project groovy-core by groovy.

the class Groovyc method doForkCommandLineList.

private void doForkCommandLineList(List<String> commandLineList, Path classpath, String separator) {
    if (!fork)
        return;
    if (includeAntRuntime) {
        classpath.addExisting((new Path(getProject())).concatSystemClasspath("last"));
    }
    if (includeJavaRuntime) {
        classpath.addJavaRuntime();
    }
    if (forkedExecutable != null && !forkedExecutable.equals("")) {
        commandLineList.add(forkedExecutable);
    } else {
        String javaHome;
        if (forkJavaHome != null) {
            javaHome = forkJavaHome.getPath();
        } else {
            javaHome = System.getProperty("java.home");
        }
        commandLineList.add(javaHome + separator + "bin" + separator + "java");
    }
    commandLineList.add("-classpath");
    commandLineList.add(classpath.toString());
    final String fileEncodingProp = System.getProperty("file.encoding");
    if ((fileEncodingProp != null) && !fileEncodingProp.equals("")) {
        commandLineList.add("-Dfile.encoding=" + fileEncodingProp);
    }
    if (targetBytecode != null) {
        commandLineList.add("-Dgroovy.target.bytecode=" + targetBytecode);
    }
    if ((memoryInitialSize != null) && !memoryInitialSize.equals("")) {
        commandLineList.add("-Xms" + memoryInitialSize);
    }
    if ((memoryMaximumSize != null) && !memoryMaximumSize.equals("")) {
        commandLineList.add("-Xmx" + memoryMaximumSize);
    }
    if (!"*.groovy".equals(getScriptExtension())) {
        String tmpExtension = getScriptExtension();
        if (tmpExtension.startsWith("*."))
            tmpExtension = tmpExtension.substring(1);
        commandLineList.add("-Dgroovy.default.scriptExtension=" + tmpExtension);
    }
    commandLineList.add(FileSystemCompilerFacade.class.getName());
    if (forceLookupUnnamedFiles) {
        commandLineList.add("--forceLookupUnnamedFiles");
    }
}
Also used : Path(org.apache.tools.ant.types.Path)

Example 74 with Path

use of org.apache.tools.ant.types.Path in project liquibase by liquibase.

the class BaseLiquibaseTask method init.

@Override
public void init() throws BuildException {
    scopeValues.put(Scope.Attr.logService.name(), new AntTaskLogService(this));
    classpath = new Path(getProject());
}
Also used : Path(org.apache.tools.ant.types.Path)

Example 75 with Path

use of org.apache.tools.ant.types.Path in project groovy by apache.

the class Groovyc method compile.

protected void compile() {
    if (compileList.length == 0)
        return;
    try {
        log.info("Compiling " + compileList.length + " source file" + (compileList.length == 1 ? "" : "s") + (destDir != null ? " to " + destDir : ""));
        listFiles();
        Path classpath = Optional.ofNullable(getClasspath()).orElse(new Path(getProject()));
        List<String> jointOptions = extractJointOptions(classpath);
        List<String> commandLineList = new ArrayList<>();
        if (fork)
            doForkCommandLineList(commandLineList, classpath, File.separator);
        doNormalCommandLineList(commandLineList, jointOptions, classpath);
        addSourceFiles(commandLineList);
        String[] commandLine = makeCommandLine(commandLineList);
        if (fork) {
            runForked(commandLine);
        } else {
            runCompiler(commandLine);
        }
    } finally {
        for (File temporaryFile : temporaryFiles) {
            try {
                FileSystemCompiler.deleteRecursive(temporaryFile);
            } catch (Throwable t) {
                System.err.println("error: could not delete temp files - " + temporaryFile.getPath());
            }
        }
    }
}
Also used : Path(org.apache.tools.ant.types.Path) ArrayList(java.util.ArrayList) File(java.io.File)

Aggregations

Path (org.apache.tools.ant.types.Path)175 File (java.io.File)81 BuildException (org.apache.tools.ant.BuildException)57 Test (org.junit.Test)49 Project (org.apache.tools.ant.Project)28 IOException (java.io.IOException)27 Commandline (org.apache.tools.ant.types.Commandline)21 ArrayList (java.util.ArrayList)15 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)12 AntClassLoader (org.apache.tools.ant.AntClassLoader)9 GroovyClassLoader (groovy.lang.GroovyClassLoader)8 URL (java.net.URL)8 StringTokenizer (java.util.StringTokenizer)8 Reference (org.apache.tools.ant.types.Reference)8 Java (org.apache.tools.ant.taskdefs.Java)7 FileSet (org.apache.tools.ant.types.FileSet)7 Resource (org.apache.tools.ant.types.Resource)7 FileWriter (java.io.FileWriter)6 List (java.util.List)6 Execute (org.apache.tools.ant.taskdefs.Execute)6