org.apache.tools.ant.DefaultLogger Java Examples
The following examples show how to use
org.apache.tools.ant.DefaultLogger.
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: 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 #3
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 #4
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 #5
Source File: AntTaskUtils.java From was-maven-plugin with Apache License 2.0 | 5 votes |
private static void setupLogger(File antBuildFile, Log logger, Project antProject) throws FileNotFoundException { DefaultLogger consoleLogger = new DefaultLogger(); consoleLogger.setOutputPrintStream(System.out); consoleLogger.setErrorPrintStream(System.err); addBuildListener(logger, antProject, consoleLogger); DefaultLogger fileLogger = new DefaultLogger(); PrintStream ps = new PrintStream(new FileOutputStream(new File(antBuildFile.getAbsolutePath() + ".log"))); fileLogger.setOutputPrintStream(ps); fileLogger.setErrorPrintStream(ps); addBuildListener(logger, antProject, fileLogger); }
Example #6
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 #7
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 #8
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 #9
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 #10
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"); }