Tabnine Logo
Project
Code IndexAdd Tabnine to your IDE (free)

How to use
Project
in
org.apache.tools.ant

Best Java code snippets using org.apache.tools.ant.Project (Showing top 20 results out of 3,096)

Refine searchRefine arrow

  • BuildException
  • Hashtable
  • Path
  • DirectoryScanner
  • FileUtils
  • Commandline
  • FileSet
  • Commandline.Argument
  • Execute
origin: jenkinsci/jenkins

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);
    }
  }
}
origin: org.testng/testng

/** 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();
  }
 }
}
origin: micronaut-projects/micronaut-core

/**
 * @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;
}
origin: org.apache.ant/ant

 /**
 * 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());
  }
}
origin: apache/groovy

public synchronized Object get(Object key) {
  return project.getProperties().get(key);
}
origin: org.apache.ant/ant

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());
origin: org.apache.ant/ant

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());
  }
}
origin: org.apache.ant/ant

/**
 * 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());
  }
}
origin: pmd/pmd

  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");
origin: apache/groovy

public synchronized boolean containsKey(Object key) {
  return project.getProperties().containsKey(key);
}
origin: org.apache.ant/ant

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());
    }
  }
}
origin: jenkinsci/jenkins

/**
 * 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;
}
origin: org.apache.ant/ant

      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");
origin: org.apache.ant/ant

  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);
origin: org.apache.ant/ant

  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);
origin: org.apache.ant/ant

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);
origin: jenkinsci/jenkins

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));
    }
  }
}
origin: org.apache.ant/ant

/**
 * @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;
}
origin: pmd/pmd

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);
  }
}
origin: jenkinsci/jenkins

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) {
org.apache.tools.antProject

Javadoc

Central representation of an Ant project. This class defines an Ant project with all of its targets, tasks and various other properties. It also provides the mechanism to kick off a build using a particular target name.

This class also encapsulates methods which allow files to be referred to using abstract path names which are translated to native system file paths at runtime.

Most used methods

  • <init>
    Create a new Ant project.
  • setProperty
    Set a property. Any existing property of the same name is overwritten, unless it is a user property.
  • getBaseDir
    Return the base directory of the project as a file object.
  • addBuildListener
    Add a build listener to the list. This listener will be notified of build events for this project.
  • init
    Initialise the project. This involves setting the default task definitions and loading the system pr
  • getProperty
    Return the value of a property, if it is set.
  • log
    Write a task level message to the log with the given log level.
  • getProperties
    Return a copy of the properties table.
  • resolveFile
    Return the canonical form of a filename. If the specified file name is relative it is resolved with
  • addReference
    Add a reference to the project.
  • createTask
    Create a new instance of a task, adding it to a list of created tasks for later invalidation. This c
  • setNewProperty
    Set a property if no value currently exists. If the property exists already, a message is logged and
  • createTask,
  • setNewProperty,
  • getReference,
  • setBaseDir,
  • replaceProperties,
  • executeTarget,
  • getBuildListeners,
  • setUserProperty,
  • fireBuildStarted,
  • fireBuildFinished

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (Timer)
  • getExternalFilesDir (Context)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now