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);
}
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;
}
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");
}
}
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());
}
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());
}
}
}
}
Aggregations