Java Code Examples for org.apache.tools.ant.Project#addBuildListener()
The following examples show how to use
org.apache.tools.ant.Project#addBuildListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AntHarnessTest.java From ExpectIt with Apache License 2.0 | 6 votes |
private static Project newProject() throws IOException { setupBuildFile(); Project project = new Project(); project.setUserProperty("ant.file", buildFile.getAbsolutePath()); project.init(); DefaultLogger listener = new DefaultLogger(); listener.setErrorPrintStream(System.err); listener.setOutputPrintStream(System.out); listener.setMessageOutputLevel(Project.MSG_INFO); ProjectHelper helper = ProjectHelper.getProjectHelper(); project.addReference("ant.projectHelper", helper); project.setProperty("ftp.port", String.valueOf(ftpPort)); project.setProperty("ssh.port", String.valueOf(sshPort)); helper.parse(project, buildFile); project.addBuildListener(listener); return project; }
Example 2
Source File: AntBuilder.java From groovy with Apache License 2.0 | 6 votes |
/** * @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; }
Example 3
Source File: ShuffleModel.java From Shuffle-Move with GNU General Public License v3.0 | 6 votes |
/** * Constructs the Project and returns it. * * @return The Project * @throws Exception * If anything goes wrong. */ private Project getErrorProject() throws Exception { Path buildFilePath = Paths.get(BUILD_REPORT_FILE); LOG.finer("Build file path set to " + String.valueOf(buildFilePath)); Project p = new Project(); p.setSystemProperties(); p.setUserProperty("ant.file", buildFilePath.toAbsolutePath().toString()); LOG.finer("Project ant.file property set."); p.init(); LOG.finer("Project.init() called."); ProjectHelper helper = ProjectHelper.getProjectHelper(); LOG.finer("ProjectHelper created."); p.addReference("ant.projectHelper", helper); LOG.finer("Project ant.projectHelper reference set."); p.addReference("user.dir", System.getProperty("user.dir")); LOG.finer("Project user.dir reference set."); helper.parse(p, buildFilePath.toAbsolutePath().toFile()); LOG.finer("PrjectHelper.parse() called."); errorProject = p; p.addBuildListener(getBuildListener()); LOG.finer("BuildListener added."); return errorProject; }
Example 4
Source File: AntUtil.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * @return Factory method to create new Project instances */ public 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 project.addBuildListener(new AntLoggingAdapter()); project.init(); project.getBaseDir(); return project; }
Example 5
Source File: FileSender.java From iaf with Apache License 2.0 | 5 votes |
private void runAntScript() { Project ant = new Project(); DefaultLogger consoleLogger = new DefaultLogger(); consoleLogger.setErrorPrintStream(System.err); consoleLogger.setOutputPrintStream(System.out); consoleLogger.setMessageOutputLevel(Project.MSG_INFO); ant.addBuildListener(consoleLogger); ant.init(); ProjectHelper helper = new ProjectHelperImpl(); helper.parse(ant, new File(filename)); ant.executeTarget(ant.getDefaultTarget()); }
Example 6
Source File: MyBuildFileRule.java From ph-schematron with Apache License 2.0 | 5 votes |
/** * Sets up to run the named project * * @param filename * name of project file to run * @param logLevel * Log level * @throws BuildException * on error */ public void configureProject (final String filename, final int logLevel) throws BuildException { logBuffer = new StringBuffer (); fullLogBuffer = new StringBuffer (); project = new Project (); project.init (); final File antFile = new File (System.getProperty ("root"), filename); project.setProperty ("ant.processid", ProcessUtil.getProcessId ("<Process>")); project.setProperty ("ant.threadname", Thread.currentThread ().getName ()); project.setUserProperty ("ant.file", antFile.getAbsolutePath ()); project.addBuildListener (new AntTestListener (logLevel)); ProjectHelper.configureProject (project, antFile); }
Example 7
Source File: AntTaskUtils.java From was-maven-plugin with Apache License 2.0 | 5 votes |
private static void addBuildListener(Log logger, Project antProject, DefaultLogger listener) { if (logger.isDebugEnabled()) { listener.setMessageOutputLevel(Project.MSG_DEBUG); } else if (logger.isInfoEnabled()) { listener.setMessageOutputLevel(Project.MSG_INFO); } else if (logger.isWarnEnabled()) { listener.setMessageOutputLevel(Project.MSG_WARN); } else if (logger.isErrorEnabled()) { listener.setMessageOutputLevel(Project.MSG_ERR); } else { listener.setMessageOutputLevel(Project.MSG_VERBOSE); } antProject.addBuildListener(listener); }
Example 8
Source File: TestHelper.java From ant-ivy with Apache License 2.0 | 5 votes |
public static Project newProject() { Project project = new Project(); DefaultLogger logger = new DefaultLogger(); logger.setMessageOutputLevel(Project.MSG_INFO); logger.setOutputPrintStream(System.out); logger.setErrorPrintStream(System.out); project.addBuildListener(logger); return project; }
Example 9
Source File: AntUtil.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
/** * @return Factory method to create new Project instances */ public 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 project.addBuildListener(new AntLoggingAdapter()); project.init(); project.getBaseDir(); return project; }
Example 10
Source File: AntUtil.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
/** * @return Factory method to create new Project instances */ public 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 project.addBuildListener(new AntLoggingAdapter()); project.init(); project.getBaseDir(); return project; }
Example 11
Source File: XtendCompilerAntTaskTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
/** * Sets up to run the named project * * @param filename * name of project file to run */ protected void configureProject(String filename) throws BuildException { project = new Project(); project.init(); File antFile = new File(System.getProperty("root"), filename); File depsFolder = new File(System.getProperty("root"), "target/antDeps"); project.setUserProperty("deps.dir", depsFolder.getAbsolutePath()); project.setUserProperty("ant.file", antFile.getAbsolutePath()); antTestListener = new AntTestListener(Project.MSG_ERR); project.addBuildListener(antTestListener); ProjectHelper.configureProject(project, antFile); }
Example 12
Source File: JdkIdeaAntLogger.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public JdkIdeaAntLogger(Project project) { for (Object o : project.getBuildListeners()) { if (o instanceof DefaultLogger) { this.logger = (DefaultLogger)o; project.removeBuildListener((BuildListener)o); project.addBuildListener(this); } } tasks.push(Task.ROOT); }
Example 13
Source File: LangtoolsIdeaAntLogger.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public LangtoolsIdeaAntLogger(Project project) { for (Object o : project.getBuildListeners()) { if (o instanceof DefaultLogger) { this.logger = (DefaultLogger)o; project.removeBuildListener((BuildListener)o); project.addBuildListener(this); } } logger.setMessageOutputLevel(3); tasks.push(Task.ROOT); }
Example 14
Source File: AntUtil.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * @return Factory method to create new Project instances */ public 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 project.addBuildListener(new AntLoggingAdapter()); project.init(); project.getBaseDir(); return project; }
Example 15
Source File: PackagerCacheEntry.java From ant-ivy with Apache License 2.0 | 4 votes |
/** * Attempt to build this entry. * * @param packagerResource * packager metadata resource * @param properties * a map of properties to pass to the child Ant build responsible for dependency * packaging * * @throws IOException * if this entry has already been built */ public synchronized void build(Resource packagerResource, Map<String, String> properties) throws IOException { // Sanity check if (this.built) { throw new IllegalStateException("build in directory `" + this.dir + "' already completed"); } // Remove work directory if it exists (e.g. left over from last time) if (this.dir.exists()) { if (!cleanup()) { throw new IOException("can't remove directory `" + this.dir + "'"); } } // Create work directory if (!this.dir.mkdirs()) { throw new IOException("can't create directory `" + this.dir + "'"); } // Write out packager XML InputStream packagerXML = packagerResource.openStream(); saveFile("packager.xml", packagerXML); // Write packager XSLT saveFile("packager.xsl"); // Write packager XSD saveFile("packager-1.0.xsd"); // Write master Ant build file saveFile("build.xml"); // Execute the Ant build file Project project = new Project(); project.init(); project.setUserProperty("ant.file", new File(dir, "build.xml").getAbsolutePath()); ProjectHelper.configureProject(project, new File(dir, "build.xml")); project.setBaseDir(dir); // Configure logging verbosity BuildLogger logger = new DefaultLogger(); logger.setMessageOutputLevel(this.verbose ? Project.MSG_VERBOSE : this.quiet ? Project.MSG_WARN : Project.MSG_INFO); logger.setOutputPrintStream(System.out); logger.setErrorPrintStream(System.err); project.addBuildListener(logger); // Set properties project.setUserProperty("ivy.packager.organisation", "" + this.mr.getModuleId().getOrganisation()); project.setUserProperty("ivy.packager.module", "" + this.mr.getModuleId().getName()); project.setUserProperty("ivy.packager.revision", "" + this.mr.getRevision()); project.setUserProperty("ivy.packager.branch", "" + this.mr.getBranch()); if (this.resourceCache != null) { project.setUserProperty("ivy.packager.resourceCache", "" + this.resourceCache.getCanonicalPath()); } if (this.resourceURL != null) { project.setUserProperty("ivy.packager.resourceURL", "" + getResourceURL()); } if (this.validate) { project.setUserProperty("ivy.packager.validate", "true"); } project.setUserProperty("ivy.packager.restricted", "" + this.restricted); project.setUserProperty("ivy.packager.quiet", String.valueOf(quiet)); if (properties != null) { for (Map.Entry<String, String> entry : properties.entrySet()) { project.setUserProperty(entry.getKey(), entry.getValue()); } } // Execute task Message.verbose("performing packager resolver build in " + this.dir); try { project.executeTarget("build"); this.built = true; } catch (BuildException e) { Message.verbose("packager resolver build failed: " + e); throw e; } }
Example 16
Source File: AntTaskTestCase.java From ant-ivy with Apache License 2.0 | 4 votes |
public Project configureProject() { Project project = TestHelper.newProject(); antTestListener = new AntTestListener(Project.MSG_INFO); project.addBuildListener(antTestListener); return project; }
Example 17
Source File: ProGuardMojo.java From code-hidding-plugin with GNU Lesser General Public License v2.1 | 4 votes |
private static void proguardMain(File proguardJar, ArrayList argsList, ProGuardMojo mojo) throws MojoExecutionException { Java java = new Java(); Project antProject = new Project(); antProject.setName(mojo.mavenProject.getName()); antProject.init(); DefaultLogger antLogger = new DefaultLogger(); antLogger.setOutputPrintStream(System.out); antLogger.setErrorPrintStream(System.err); antLogger.setMessageOutputLevel(mojo.log.isDebugEnabled() ? Project.MSG_DEBUG : Project.MSG_INFO); antProject.addBuildListener(antLogger); antProject.setBaseDir(mojo.mavenProject.getBasedir()); java.setProject(antProject); java.setTaskName("proguard"); mojo.getLog().info("proguard jar: " + proguardJar); java.createClasspath().setLocation(proguardJar); // java.createClasspath().setPath(System.getProperty("java.class.path")); java.setClassname(mojo.proguardMainClass); java.setFailonerror(true); java.setFork(true); // get the maxMemory setting if (mojo.maxMemory != null) { java.setMaxmemory(mojo.maxMemory); } for (Iterator i = argsList.iterator(); i.hasNext();) { java.createArg().setValue(i.next().toString()); } int result = java.executeJava(); if (result != 0) { throw new MojoExecutionException("Obfuscation failed (result=" + result + ")"); } }
Example 18
Source File: CCGBankConvert.java From openccg with GNU Lesser General Public License v2.1 | 4 votes |
public static void main(String[] args) { File baseDir = new File(System.getProperty("user.dir")); File buildFile = new File(baseDir, "build.xml"); Project project = new Project(); project.init(); project.setBaseDir(baseDir); ProjectHelper helper = ProjectHelper.getProjectHelper(); project.setProjectReference(helper); helper.parse(project, buildFile); DefaultLogger logger = new DefaultLogger(); logger.setErrorPrintStream(System.err); logger.setOutputPrintStream(System.out); project.addBuildListener(logger); project.executeTarget("convert-base"); }
Example 19
Source File: AntCallTriggerTest.java From ant-ivy with Apache License 2.0 | 1 votes |
/** * Adds the listeners specified in the command line arguments, along with the default listener, * to the specified project. * * @param project * The project to add listeners to. Must not be <code>null</code>. * @param level * log level */ private void addBuildListeners(Project project, int level) { // Add the default listener project.addBuildListener(createLogger(level)); }