public Path createClasspath() { if (classpath == null) { classpath = new Path(getProject()); } return classpath.createPath(); }
/** * Set the classpath to search for classes to load. This should not be * changed once the classloader starts to server classes * * @param classpath the search classpath consisting of directories and * jar/zip files. */ public void setClassPath(Path classpath) { pathComponents.removeAllElements(); if (classpath != null) { Path actualClasspath = classpath.concatSystemClasspath("ignore"); String[] pathElements = actualClasspath.list(); for (int i = 0; i < pathElements.length; ++i) { try { addPathElement(pathElements[i]); } catch (BuildException e) { // ignore path elements which are invalid // relative to the project } } } }
private void doBootPath(final Commandline toExecute) { Path bcp = new Path(getProject()); if (bootclasspath != null) { bcp.append(bootclasspath); } bcp = bcp.concatSystemBootClasspath("ignore"); if (bcp.size() > 0) { toExecute.createArgument().setValue("-bootclasspath"); toExecute.createArgument().setPath(bcp); } }
/** * Returns all path elements defined by this and nested path objects. * @return list of path elements. */ public String[] list() { if (isReference()) { return ((Path) getCheckedRef()).list(); } return assertFilesystemOnly(union) == null ? new String[0] : union.list(); }
/** * Set a single commandline argument from a reference to a * path--ensuring the right separator for the local platform * is used. * * @param value a single commandline argument. */ public void setPathref(Reference value) { Path p = new Path(getProject()); p.setRefid(value); parts = new String[] {p.toString()}; }
private void collectFileListFromSourcePath() { for (String filename : src.list()) { final File srcDir = getProject().resolveFile(filename); if (!srcDir.exists()) { throw new BuildException("srcdir \"" + srcDir.getPath() + "\" does not exist!", getLocation()); } final DirectoryScanner ds = this.getDirectoryScanner(srcDir); scanDir(srcDir, destDir != null ? destDir : srcDir, ds.getIncludedFiles()); } }
private void collectFileListFromModulePath() { final FileUtils fu = FileUtils.getFileUtils(); for (String pathElement : moduleSourcepath.list()) { boolean valid = false; for (Map.Entry<String, Collection<File>> modules : resolveModuleSourcePathElement( getProject().getBaseDir(), pathElement).entrySet()) { final String moduleName = modules.getKey(); for (File srcDir : modules.getValue()) { if (srcDir.exists()) { valid = true; final DirectoryScanner ds = getDirectoryScanner(srcDir); final String[] files = ds.getIncludedFiles(); scanDir(srcDir, fu.resolveFile(destDir, moduleName), files); } } } if (!valid) { throw new BuildException("modulesourcepath \"" + pathElement + "\" does not exist!", getLocation()); } } }
public void execute() throws BuildException { if (!destinationDirectory.isDirectory()) { throw new BuildException("destination directory %s is not valid", destinationDirectory.getPath()); throw new BuildException("src directory %s is not valid", sourceDirectory.getPath()); throw new BuildException("package attribute must be present.", getLocation()); compileClasspath = new Path(getProject()); compileClasspath = compileClasspath.concatSystemClasspath(); args[j++] = compileClasspath.toString(); this.scanDir(ds.getIncludedFiles()); log("Compiling " + filesToDo.size() + " JSP files"); helperTask.createArg().setValue(args[x]);
analyzer = analyzerClass.newInstance(); } catch (Exception e) { throw new BuildException("Unable to load dependency analyzer: " + analyzerClassName, e); analyzer.addClassPath(new Path(null, basedir.getPath())); additionalBaseDirs.stream().map(File::getPath) .map(p -> new Path(null, p)).forEach(analyzer::addClassPath); Set<String> parentSet = Stream.of(parentScanner.getIncludedFiles()) .collect(Collectors.toSet());
Java javaTask = new Java(getTask()); javaTask.createJvmarg().setValue("-Xms64m"); javaTask.createJvmarg().setValue("-Xmx128m"); javaTask.setClassname("com.ibm.etools.ejbdeploy.EJBDeploy"); javaTask.createArg().setValue(sourceJar.getPath()); javaTask.createArg().setValue(tempdir); javaTask.createArg().setValue(destJar.getPath()); javaTask.createArg().setLine(getOptions()); if (getCombinedClasspath() != null && !getCombinedClasspath().toString().isEmpty()) { javaTask.createArg().setValue("-cp"); javaTask.createArg().setValue(getCombinedClasspath().toString()); throw new BuildException( "Exception while calling ejbdeploy. Details: " + e.toString(), e);
static Commandline setupJavahCommand(Javah javah) { Commandline cmd = new Commandline(); cmd.createArgument().setValue("-d"); cmd.createArgument().setFile(javah.getDestdir()); cmd.createArgument().setValue("-o"); cmd.createArgument().setFile(javah.getOutputfile()); throw new BuildException( "stubs only available in old mode.", javah.getLocation()); cmd.createArgument().setValue("-stubs"); Path bcp = new Path(javah.getProject()); if (javah.getBootclasspath() != null) { bcp.append(javah.getBootclasspath()); bcp = bcp.concatSystemBootClasspath("ignore"); if (bcp.size() > 0) { cmd.createArgument().setValue("-bootclasspath"); cmd.createArgument().setPath(bcp);
validate(); if (classpath != null) { classpath = classpath.concatSystemClasspath("ignore"); getProject().log("using user supplied classpath: " + classpath, Project.MSG_DEBUG); } else { classpath = new Path(getProject()); classpath = classpath.concatSystemClasspath("only"); getProject().log("using system classpath: " + classpath, Project.MSG_DEBUG); AntClassLoader.newAntClassLoader(getProject().getCoreLoader(), getProject(), classpath, false)) { throw new BuildException("One of class or resource is required");
Commandline cmd = new Commandline(); Path classpath = new Path(project); if (!p.isEmpty()) { classpath.append(p); classpath.addExtdirs(extdirs); classpath.append(getCompileClasspath()); classpath.append(compileSourcepath); } else { classpath.append(src); cmd.setExecutable(exec == null ? "gcj" : exec); cmd.createArgument().setValue("-d"); cmd.createArgument().setFile(destDir); throw new BuildException( "Can't make output directories. Maybe permission is wrong."); cmd.createArgument().setValue("-classpath"); cmd.createArgument().setPath(classpath);
/** * Build a classloader using the additional elements specified in * <code>classpath</code> and <code>classpathRef</code>. * * @return a new classloader that includes the extra path elements found in * the <code>classpath</code> and <code>classpathRef</code> config * values */ private ClassLoader buildExtendedClassloader() { final List<URL> classpathUrls = new ArrayList<>(); for (String pathElement : getClasspath().list()) { try { classpathUrls.add(new File(pathElement).toURI().toURL()); } catch (MalformedURLException e) { throw new BuildException("Unable to use classpath entry as it could not be understood as a valid URL: " + pathElement, e); } } final ClassLoader parentClassloader = Thread.currentThread().getContextClassLoader(); return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { return new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()]), parentClassloader); } }); }
public void execute() { if (name == null) { throw new BuildException("Missing 'property' attribute!"); throw new BuildException("Missing 'jarfile' attribute!"); if (getProject().getProperty(name) != null) { throw new BuildException("Property '%s' already set!", name); for (String element : path.list()) { getProject().setNewProperty(name, buffer.toString().trim());
private void generalJavadocArguments(final Commandline toExecute) { if (doctitle != null) { toExecute.createArgument().setValue("-doctitle"); toExecute.createArgument().setValue(expand(doctitle.getText())); toExecute.createArgument().setValue("-header"); toExecute.createArgument().setValue(expand(header.getText())); classpath = new Path(getProject()).concatSystemClasspath("last"); } else { classpath = classpath.concatSystemClasspath("ignore"); if (classpath.size() > 0) { toExecute.createArgument().setValue("-classpath"); toExecute.createArgument().setPath(classpath); throw new BuildException("destdir attribute must be set!");
@Override public void execute() throws BuildException { findbugsEngine = (Java) getProject().createTask("java"); jvmargs = jvmargs + " -Dfindbugs.debug=true"; findbugsEngine.createJvmarg().setLine(jvmargs); findbugsEngine.setClasspath(new Path(getProject(), findbugsLibFindBugs.getPath())); } else if (findBugsFindBugs.exists()) { findbugsEngine.setClasspath(new Path(getProject(), findBugsFindBugs.getPath())); } else { throw new IllegalArgumentException("Can't find spotbugs.jar in " + homeDir); findbugsEngine.createJvmarg().setValue("-Dspotbugs.home=" + homeDir.getPath()); } else { addArg(pluginList.toString()); throw new BuildException("Execution of findbugs failed.");
private void setupClassLoader() { try { if (auxClasspath != null) { project.log("Using auxclasspath: " + auxClasspath, Project.MSG_VERBOSE); configuration.prependClasspath(auxClasspath.toString()); } } catch (IOException ioe) { throw new BuildException(ioe.getMessage(), ioe); } }
CommandlineJava cmdl = new CommandlineJava(); cmdl.setClassname(javaCommand.getExecutable()); for (String arg : javaCommand.getArguments()) { cmdl.createArgument().setValue(arg); cmdl.createClasspath(pc.getProject()).append(classpath); return rc; } catch (IOException e) { throw new BuildException(e); } finally { timedOut = exe.killedProcess();
final Path sourceDirs = new Path(getProject()); sourceDirs.addExisting(sourcePath); toExecute.createArgument().setValue("-breakiterator"); tmpList.delete(); throw new BuildException("Error creating temporary file", e, getLocation()); } finally { toExecute.createArgument().setValue("@" + packageList); log(toExecute.describeCommand(), Project.MSG_VERBOSE); final int ret = exe.execute(); if (ret != 0 && failOnError) { throw new BuildException("Javadoc returned " + ret, getLocation()); throw new BuildException("Javadoc issued warnings.", getLocation());