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

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

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

Project.init介绍

[英]Initialise the project. This involves setting the default task definitions and loading the system properties.
[中]初始化项目。这涉及到设置默认任务定义和加载系统属性。

代码示例

代码示例来源:origin: org.apache.ant/ant

private DeweyDecimal getVersion() {
  Project p = new Project();
  p.init();
  StringBuilder sb = new StringBuilder();
  boolean foundFirstDigit = false;
  for (char versionChar : p.getProperty("ant.version").toCharArray()) {
    if (Character.isDigit(versionChar)) {
      sb.append(versionChar);
      foundFirstDigit = true;
    }
    if (versionChar == '.' && foundFirstDigit) {
      sb.append(versionChar);
    }
    if (Character.isLetter(versionChar) && foundFirstDigit) {
      break;
    }
  }
  return new DeweyDecimal(sb.toString());
}

代码示例来源:origin: apache/activemq

public static void main(String[] args) {
  Project project = new Project();
  project.init();
  CSharpGeneratorTask generator = new CSharpGeneratorTask();
  generator.setProject(project);
  if (args.length > 0) {
    generator.version = Integer.parseInt(args[0]);
  }
  if (args.length > 1) {
    generator.source = new File(args[1]);
  }
  if (args.length > 2) {
    generator.target = new File(args[2]);
  }
  generator.execute();
}

代码示例来源:origin: apache/activemq

public static void main(String[] args) {
  Project project = new Project();
  project.init();
  JavaGeneratorTask generator = new JavaGeneratorTask();
  generator.setProject(project);
  if (args.length > 0) {
    generator.version = Integer.parseInt(args[0]);
  }
  if (args.length > 1) {
    generator.basedir = new File(args[1]);
  }
  generator.execute();
}

代码示例来源:origin: apache/activemq

public static void main(String[] args) {
  Project project = new Project();
  project.init();
  CppGeneratorTask generator = new CppGeneratorTask();
  generator.setProject(project);
  if (args.length > 0) {
    generator.version = Integer.parseInt(args[0]);
  }
  if (args.length > 1) {
    generator.source = new File(args[1]);
  }
  if (args.length > 2) {
    generator.target = new File(args[2]);
  }
  generator.execute();
}

代码示例来源:origin: apache/activemq

public static void main(String[] args) {
  Project project = new Project();
  project.init();
  CGeneratorTask generator = new CGeneratorTask();
  generator.setProject(project);
  if (args.length > 0) {
    generator.version = Integer.parseInt(args[0]);
  }
  if (args.length > 1) {
    generator.source = new File(args[1]);
  }
  if (args.length > 2) {
    generator.target = new File(args[2]);
  }
  generator.execute();
}

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

private void executeSql(String sqlFilePath) {
  final class SqlExecuter extends SQLExec {
    public SqlExecuter() {
      Project project = new Project();
      project.init();
      setProject(project);
      setTaskType("sql");
      setTaskName("sql");
    }
  }

  SqlExecuter executer = new SqlExecuter();
  executer.setSrc(new File(sqlFilePath));
  executer.setDriver(args.getDriver());
  executer.setPassword(args.getPwd());
  executer.setUserid(args.getUser());
  executer.setUrl(args.getUrl());
  executer.execute();
}

代码示例来源:origin: apache/activemq

protected void processClass(JClass jclass) {
  simpleName = jclass.getSimpleName();
  superclass = jclass.getSuperclass();
  System.out.println(getClass().getName() + " processing class: " + simpleName);
  className = getClassName(jclass);
  destFile = new File(destDir, className + filePostFix);
  baseClass = getBaseClassName(jclass);
  PrintWriter out = null;
  try {
    out = new PrintWriter(new FileWriter(destFile));
    generateFile(out);
  } catch (Exception e) {
    throw new RuntimeException(e);
  } finally {
    if (out != null) {
      out.close();
    }
  }
  // Use the FixCRLF Ant Task to make sure the file has consistent
  // newlines
  // so that SVN does not complain on checkin.
  Project project = new Project();
  project.init();
  FixCRLF fixCRLF = new FixCRLF();
  fixCRLF.setProject(project);
  fixCRLF.setSrcdir(destFile.getParentFile());
  fixCRLF.setIncludes(destFile.getName());
  fixCRLF.execute();
}

代码示例来源:origin: org.apache.ant/ant

private void setProperties(final Project project) {
  project.init();
  // resolve properties
  final PropertyHelper propertyHelper = PropertyHelper.getPropertyHelper(project);
  @SuppressWarnings({ "rawtypes", "unchecked" })
  final Map raw = new HashMap(definedProps);
  @SuppressWarnings("unchecked")
  final Map<String, Object> props = raw;
  final ResolvePropertyMap resolver = new ResolvePropertyMap(project,
      NOPROPERTIES, propertyHelper.getExpanders());
  resolver.resolveAllProperties(props, null, false);
  // set user-define properties
  props.forEach((arg, value) -> project.setUserProperty(arg, String.valueOf(value)));
  project.setUserProperty(MagicNames.ANT_FILE,
              buildFile.getAbsolutePath());
  project.setUserProperty(MagicNames.ANT_FILE_TYPE,
              MagicNames.ANT_FILE_TYPE_FILE);
  // this list doesn't contain the build files default target,
  // which may be added later unless targets have been specified
  // on the command line. Therefore the property gets set again
  // in Project#executeTargets when we can be sure the list is
  // complete.
  // Setting it here allows top-level tasks to access the
  // property.
  project.setUserProperty(MagicNames.PROJECT_INVOKED_TARGETS,
      targets.stream().collect(Collectors.joining(",")));
}

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

project.init();
FixCRLF fixCRLF = new FixCRLF();
fixCRLF.setProject(project);

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

protected void setUp() throws Exception {
  super.setUp(); //  Potentially throws Exception.
  project = new Project();
  project.init();
  ProjectHelper.getProjectHelper().parse(project, antFile);
  project.executeTarget("clean");
  String altJavaHome = System.getProperty("java.home");
  if (altJavaHome.lastIndexOf("jre") >= 0) {
    altJavaHome = altJavaHome.substring(0, altJavaHome.lastIndexOf("jre"));
  } else {
    altJavaHome = altJavaHome + File.separator + "jre";
  }
  try {
    File altFile = new File(altJavaHome);
    if (altFile.exists()) {
      project.setProperty("alt.java.home", altJavaHome);
    }
  } catch (Exception e) {
    // could be security, io, etc.  Ignore it.
    // End result is as if .exists() returned null
  }
}

代码示例来源:origin: apache/groovy

/**
 * @return Factory method to create new Project instances
 */
protected static Project createProject() {
  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 
  final BuildLogger logger = new NoBannerLogger();
  logger.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_INFO);
  logger.setOutputPrintStream(System.out);
  logger.setErrorPrintStream(System.err);
  project.addBuildListener(logger);
  project.init();
  project.getBaseDir();
  return project;
}

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

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

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

File buildFile = new File("build.xml");
 Project p = new Project();
 p.setUserProperty("ant.file", buildFile.getAbsolutePath());
 p.init();
 ProjectHelper helper = ProjectHelper.getProjectHelper();
 p.addReference("ant.projectHelper", helper);
 helper.parse(p, buildFile);
 p.executeTarget(p.getDefaultTarget());

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

File buildFile = new File("build.xml");
 Project p = new Project();
 p.setUserProperty("ant.file", buildFile.getAbsolutePath());
 p.init();
 ProjectHelper helper = ProjectHelper.getProjectHelper();
 p.addReference("ant.projectHelper", helper);
 helper.parse(p, buildFile);
 p.executeTarget(p.getDefaultTarget());

代码示例来源:origin: com.atlassian.maven.plugins/amps-maven-plugin

/**
 * @return a default empty Ant {@link org.apache.tools.ant.Project }
 */
public Project createProject()
{
  Project defaultProject = new Project();
  defaultProject.init();
  return defaultProject;
}

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

/**
 * This method will create an ant antProject object.
 *
 * @return The ant antProject for use by tasks.
 */
public static Project createProject() {
  Project project = new Project();
  project.init();
  project.getBaseDir();
  return project;
}

代码示例来源:origin: com.xpn.xwiki.platform.tools/xwiki-shared-tests

public XWikiTestSetup(Test test)
{
  super(test);
  this.project = new Project();
  this.project.init();
  this.project.addBuildListener(new AntBuildListener(DEBUG));
}

代码示例来源:origin: org.gosu-lang.aardvark/aardvark-core

public void printProjectHelp() {
 _project.init();
 _project.setBaseDir(_baseDir);
 _project.log(getHelp(_gosuProgram));
}

代码示例来源:origin: org.eclipse/org.eclipse.jst.ws.axis2.creation.core

public AARFileWriter() {
  this.setProject(new Project());
  this.getProject().init();
  this.setTaskType(Axis2Constants.JAR_TASK);
  this.setTaskName(Axis2Constants.JAR_TASK);
  this.setOwningTarget(new org.apache.tools.ant.Target());
}

相关文章