private static void parseClassPath(Manifest manifest, File archive, List<File> paths, String attributeName, String separator) throws IOException { String classPath = manifest.getMainAttributes().getValue(attributeName); if(classPath==null) return; // attribute not found for (String s : classPath.split(separator)) { File file = resolve(archive, s); if(file.getName().contains("*")) { // handle wildcard FileSet fs = new FileSet(); File dir = file.getParentFile(); fs.setDir(dir); fs.setIncludes(file.getName()); for( String included : fs.getDirectoryScanner(new Project()).getIncludedFiles() ) { paths.add(new File(dir,included)); } } else { if(!file.exists()) throw new IOException("No such file: "+file); paths.add(file); } } }
/** Executes the target, if any, that user designates executing before failing the test */ private void executeHaltTarget(int exitValue) { if(m_onHaltTarget != null) { if(m_outputDir != null) { getProject().setProperty("testng.outputdir", m_outputDir.getAbsolutePath()); } getProject().setProperty("testng.returncode", String.valueOf(exitValue)); Target t= getProject().getTargets().get(m_onHaltTarget); if(t != null) { t.execute(); } } }
/** * @return Factory method to create new Project instances */ @SuppressWarnings("unchecked") protected static Project createAntProject() { final Project project = new Project(); final ProjectHelper helper = ProjectHelper.getProjectHelper(); project.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper); helper.getImportStack().addElement("AntBuilder"); // import checks that stack is not empty addMicronautConsoleBuildListener(project); project.init(); project.getBaseDir(); return project; }
/** * Prints the description of a project (if there is one) to * <code>System.out</code>. * * @param project The project to display a description of. * Must not be <code>null</code>. */ private static void printDescription(final Project project) { if (project.getDescription() != null) { project.log(project.getDescription()); } }
public synchronized Object get(Object key) { return project.getProperties().get(key); }
Commandline commandLine = new Commandline(); Project aProj = getProject(); setViewPath(aProj.getBaseDir().getPath()); commandLine.setExecutable(getClearToolCommand()); commandLine.createArgument().setValue(COMMAND_UNCHECKOUT); getProject().log("Ignoring any errors that occur for: " + getViewPathBasename(), Project.MSG_VERBOSE); if (Execute.isFailure(result) && getFailOnErr()) { throw new BuildException("Failed executing: " + commandLine, getLocation());
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()); } }
/** * Run the command. * @param cmd the command line to use. * @param out the output stream handler to use. * @return the exit code of the command. */ protected int runCmd(Commandline cmd, ExecuteStreamHandler out) { try { Project aProj = getProject(); Execute exe = new Execute(out); exe.setAntRun(aProj); exe.setWorkingDirectory(aProj.getBaseDir()); exe.setCommandline(cmd.getCommandline()); return exe.execute(); } catch (IOException e) { String msg = "Failed executing: " + cmd.toString() + ". Exception: " + e.getMessage(); throw new BuildException(msg, getLocation()); } }
if (StringUtils.isNotBlank(ruleSets)) { configuration.setRuleSets(project.replaceProperties(ruleSets)); throw new BuildException(e.getMessage(), e); project.log("Setting suppress marker to be " + configuration.getSuppressMarker(), Project.MSG_VERBOSE); project.log("Sending a report to " + formatter, Project.MSG_VERBOSE); formatter.start(project.getBaseDir().toString()); DirectoryScanner ds = fs.getDirectoryScanner(project); String[] srcFiles = ds.getIncludedFiles(); for (String srcFile : srcFiles) { File file = new File(ds.getBasedir() + separator + srcFile); files.add(new FileDataSource(file)); final String inputPaths = ds.getBasedir().getPath(); configuration.setInputPaths(inputPaths); project.log(problemCount + " problems found", Project.MSG_VERBOSE); project.setProperty(failuresPropertyName, String.valueOf(problemCount)); project.log("Setting property " + failuresPropertyName + " to " + problemCount, Project.MSG_VERBOSE); throw new BuildException("Stopping build since PMD found " + problemCount + " rule violations in the code");
public synchronized boolean containsKey(Object key) { return project.getProperties().containsKey(key); }
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()); } } }
/** * Runs Ant glob expansion. * * @return * A set of relative file names from the base directory. */ @Nonnull private static String[] glob(File dir, String includes, String excludes, boolean defaultExcludes) throws IOException { if(isAbsolute(includes)) throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax"); FileSet fs = Util.createFileSet(dir,includes,excludes); fs.setDefaultexcludes(defaultExcludes); DirectoryScanner ds; try { ds = fs.getDirectoryScanner(new Project()); } catch (BuildException x) { throw new IOException(x.getMessage()); } String[] files = ds.getIncludedFiles(); return files; }
toExecute.createArgument().setValue("-tag"); toExecute.createArgument().setValue(ta.getParameter()); } else { for (String file : tagDefScanner.getIncludedFiles()) { final File tagDefFile = new File(tagDir, file); try (final BufferedReader in = new BufferedReader( new FileReader(tagDefFile))) { in.lines().forEach(line -> { toExecute.createArgument().setValue("-tag"); toExecute.createArgument().setValue(line); }); } catch (final IOException ioe) { throw new BuildException("Couldn't read tag file from " + tagDefFile.getAbsolutePath(), ioe); if (tagletInfo.getPath() != null) { final Path tagletPath = tagletInfo.getPath() .concatSystemClasspath("ignore"); if (!tagletPath.isEmpty()) { toExecute.createArgument() .setValue("-tagletpath"); : getProject().getProperty(MagicNames.BUILD_JAVAC_SOURCE); if (sourceArg != null) { toExecute.createArgument().setValue("-source");
BufferedWriter out = null; try { tmpFile = FileUtils.getFileUtils().createTempFile("jikes", "tmp", null, false, true); out = new BufferedWriter(new FileWriter(tmpFile)); "@" + tmpFile.getAbsolutePath()}; } catch (IOException e) { throw new BuildException("Error creating temporary file", e); } finally { FileUtils.close(out); Execute exe = new Execute(jop); exe.setAntRun(project); exe.setWorkingDirectory(project.getBaseDir()); exe.setCommandline(commandArray); exe.execute(); } catch (IOException e) { throw new BuildException("Error running Jikes compiler", e);
srcDir = getProject().resolveFile("."); throw new BuildException("The dest attribute must be set."); throw new BuildException( "The ext attribute or a mapper must be set if src and dest dirs are the same."); files = scanner.getIncludedFiles(); SourceFileScanner sfs = new SourceFileScanner(this); files = sfs.restrict(files, srcDir, destDir, m);
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"); getProject().setNewProperty(property, loc);
private void scan(String pattern) { LOGGER.fine("Scanning "+pattern+" for hs_err_pid files"); pattern = pattern.replace("%p","*").replace("%%","%"); File f = new File(pattern).getAbsoluteFile(); if (!pattern.contains("*")) scanFile(f); else {// GLOB File commonParent = f; while (commonParent!=null && commonParent.getPath().contains("*")) { commonParent = commonParent.getParentFile(); } if (commonParent==null) { LOGGER.warning("Failed to process "+f); return; // huh? } FileSet fs = Util.createFileSet(commonParent, f.getPath().substring(commonParent.getPath().length()+1), null); DirectoryScanner ds = fs.getDirectoryScanner(new Project()); for (String child : ds.getIncludedFiles()) { scanFile(new File(commonParent,child)); } } }
/** * @return true if the property exists * @exception BuildException if the property attribute is not set */ @Override public boolean eval() throws BuildException { if (property == null) { throw new BuildException( "No property specified for isset condition"); } return getProject().getProperty(property) != null; }
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); } }
fs.setCaseSensitive(caseSensitive); DirectoryScanner ds = fs.getDirectoryScanner(new Project()); if(ds.getIncludedFilesCount()!=0) { String[] names = ds.getIncludedFiles(); Arrays.sort(names,SHORTER_STRING_FIRST); for( String f : names) {