org.apache.tools.ant.Project.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(203)

本文整理了Java中org.apache.tools.ant.Project.<init>()方法的一些代码示例,展示了Project.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.<init>()方法的具体详情如下:
包路径:org.apache.tools.ant.Project
类名称:Project
方法名:<init>

Project.<init>介绍

[英]Create a new Ant project.
[中]创建一个新的Ant项目。

代码示例

代码示例来源:origin: stackoverflow.com

var myProject = new Project();

myProject.$get({id: 123}).
  .$promise.then(
   //success
   function( value ){/*Do something with value*/},
   //error
   function( error ){/*Do something with error*/}
  )

代码示例来源:origin: stackoverflow.com

function Project(){}
function localTest() {
  new Project(1,2,3); // `Project` points to the local variable,
            // not the global constructor!

  //...some noise, causing you to forget that the `Project` constructor was used
  var Project = 1;    // Evaluated first
}

代码示例来源: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: 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: 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: jenkinsci/jenkins

/**
 * Explodes the plugin into a directory, if necessary.
 */
private static void explode(File archive, File destDir) throws IOException {
  destDir.mkdirs();
  // timestamp check
  File explodeTime = new File(destDir,".timestamp2");
  if(explodeTime.exists() && explodeTime.lastModified()==archive.lastModified())
    return; // no need to expand
  // delete the contents so that old files won't interfere with new files
  Util.deleteRecursive(destDir);
  try {
    Project prj = new Project();
    unzipExceptClasses(archive, destDir, prj);
    createClassJarFromWebInfClasses(archive, destDir, prj);
  } catch (BuildException x) {
    throw new IOException("Failed to expand " + archive,x);
  }
  try {
    new FilePath(explodeTime).touch(archive.lastModified());
  } catch (InterruptedException e) {
    throw new AssertionError(e); // impossible
  }
}

代码示例来源:origin: jenkinsci/jenkins

public void scan(File dir, FileVisitor visitor) throws IOException {
  if(fixEmpty(includes)==null && excludes==null) {
    // optimization
    new Full().scan(dir,visitor);
    return;
  }
  FileSet fs = Util.createFileSet(dir,includes,excludes);
  fs.setDefaultexcludes(useDefaultExcludes);
  if(dir.exists()) {
    DirectoryScanner ds = fs.getDirectoryScanner(new org.apache.tools.ant.Project());
    for( String f : ds.getIncludedFiles()) {
      File file = new File(dir, f);
      scanSingle(file, f, visitor);
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Copies a single file by using Ant.
 */
public static void copyFile(@Nonnull File src, @Nonnull File dst) throws BuildException {
  Copy cp = new Copy();
  cp.setProject(new org.apache.tools.ant.Project());
  cp.setTofile(dst);
  cp.setFile(src);
  cp.setOverwrite(true);
  cp.execute();
}

代码示例来源:origin: stackoverflow.com

Project p = new Project();
Application a = new Application();
a.setProject(p);
p.getApplications().add(a);
em.persist(p);

代码示例来源:origin: checkstyle/checkstyle

@Test
public void testSetClasspathRef() {
  final CheckstyleAntTask antTask = new CheckstyleAntTask();
  antTask.setClasspathRef(new Reference(new Project(), "id"));
  assertNotNull("Classpath should not be null",
    Whitebox.getInternalState(antTask, "classpath"));
}

代码示例来源:origin: checkstyle/checkstyle

private CheckstyleAntTask getCheckstyleAntTask(String configFile) throws IOException {
  final CheckstyleAntTask antTask = new CheckstyleAntTask();
  antTask.setConfig(getPath(configFile));
  antTask.setProject(new Project());
  return antTask;
}

代码示例来源:origin: checkstyle/checkstyle

@Test
public void testCreateClasspath() {
  final CheckstyleAntTask antTask = new CheckstyleAntTask();
  assertEquals("Invalid classpath", "", antTask.createClasspath().toString());
  antTask.setClasspath(new Path(new Project(), "/path"));
  assertEquals("Invalid classpath", "", antTask.createClasspath().toString());
}

代码示例来源:origin: groovy/groovy-core

protected void setUp() throws Exception {
  super.setUp();
  project = new Project();
  project.init();
  ProjectHelper.getProjectHelper().parse(project, antFile);
  FLAG = null;
}

代码示例来源:origin: checkstyle/checkstyle

@Test
public void testCheckerException() throws IOException {
  final CheckstyleAntTask antTask = new CheckstyleAntTaskStub();
  antTask.setConfig(getPath(CONFIG_FILE));
  antTask.setProject(new Project());
  antTask.setFile(new File(""));
  try {
    antTask.execute();
    fail("Exception is expected");
  }
  catch (BuildException ex) {
    assertTrue("Error message is unexpected",
        ex.getMessage().startsWith("Unable to process files:"));
  }
}

代码示例来源:origin: checkstyle/checkstyle

@Test
public final void testNonExistentConfig() throws IOException {
  final CheckstyleAntTask antTask = new CheckstyleAntTask();
  antTask.setConfig(getPath(NOT_EXISTING_FILE));
  antTask.setProject(new Project());
  antTask.setFile(new File(getPath(FLAWLESS_INPUT)));
  try {
    antTask.execute();
    fail("Exception is expected");
  }
  catch (BuildException ex) {
    assertTrue("Error message is unexpected",
        ex.getMessage().startsWith("Unable to create Root Module: config"));
  }
}

代码示例来源:origin: checkstyle/checkstyle

@Test
public final void testNoConfigFile() throws IOException {
  final CheckstyleAntTask antTask = new CheckstyleAntTask();
  antTask.setProject(new Project());
  antTask.setFile(new File(getPath(FLAWLESS_INPUT)));
  try {
    antTask.execute();
    fail("Exception is expected");
  }
  catch (BuildException ex) {
    assertEquals("Error message is unexpected",
        "Must specify 'config'.", ex.getMessage());
  }
}

代码示例来源:origin: checkstyle/checkstyle

@Test
public final void testEmptyConfigFile() throws IOException {
  final CheckstyleAntTask antTask = new CheckstyleAntTask();
  antTask.setConfig(getPath("InputCheckstyleAntTaskEmptyConfig.xml"));
  antTask.setProject(new Project());
  antTask.setFile(new File(getPath(FLAWLESS_INPUT)));
  try {
    antTask.execute();
    fail("Exception is expected");
  }
  catch (BuildException ex) {
    assertTrue("Error message is unexpected",
        ex.getMessage().startsWith("Unable to create Root Module: config"));
  }
}

代码示例来源:origin: checkstyle/checkstyle

@Test
public final void testConfigurationByResource() throws IOException {
  final CheckstyleAntTask antTask = new CheckstyleAntTask();
  antTask.setProject(new Project());
  antTask.setConfig(getPath(CONFIG_FILE));
  antTask.setFile(new File(getPath(FLAWLESS_INPUT)));
  final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter();
  final File outputFile = new File("target/ant_task_config_by_url.txt");
  formatter.setTofile(outputFile);
  final CheckstyleAntTask.FormatterType formatterType = new CheckstyleAntTask.FormatterType();
  formatterType.setValue("plain");
  formatter.setType(formatterType);
  formatter.createListener(null);
  antTask.addFormatter(formatter);
  antTask.execute();
  final List<String> output = FileUtils.readLines(outputFile, StandardCharsets.UTF_8);
  final int sizeOfOutputWithNoViolations = 2;
  assertEquals("No violations expected", sizeOfOutputWithNoViolations, output.size());
}

代码示例来源:origin: checkstyle/checkstyle

@Test
public void testSetClasspath() {
  final CheckstyleAntTask antTask = new CheckstyleAntTask();
  final Project project = new Project();
  final String path1 = "firstPath";
  final String path2 = "secondPath";
  antTask.setClasspath(new Path(project, path1));
  antTask.setClasspath(new Path(project, path2));
  assertNotNull("Classpath should not be null",
      Whitebox.getInternalState(antTask, "classpath"));
  final Path classpath = Whitebox.getInternalState(antTask, "classpath");
  assertTrue("Classpath contain provided path", classpath.toString().contains(path1));
  assertTrue("Classpath contain provided path", classpath.toString().contains(path2));
}

代码示例来源:origin: spring-io/initializr

private void untar(File archiveFile, File project) {
  Untar expand = new Untar();
  expand.setProject(new Project());
  expand.setDest(project);
  expand.setSrc(archiveFile);
  Untar.UntarCompressionMethod method = new Untar.UntarCompressionMethod();
  method.setValue("gzip");
  expand.setCompression(method);
  expand.execute();
}

相关文章