當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultLogger類代碼示例

本文整理匯總了Java中org.apache.tools.ant.DefaultLogger的典型用法代碼示例。如果您正苦於以下問題:Java DefaultLogger類的具體用法?Java DefaultLogger怎麽用?Java DefaultLogger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DefaultLogger類屬於org.apache.tools.ant包,在下文中一共展示了DefaultLogger類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: altCompile

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
/**
 * Description: compile method that does not maintains the i/o streams after the task is done.
 * This is an alternative for the current compile method for future uses.
 * @param file path of the build xml to be executed
 */
public static void altCompile( String file) {
    
    // File buildFile = new File("build.xml");
    File buildFile = new File(file);
    Project p = new Project();
    p.setUserProperty("ant.file", buildFile.getAbsolutePath());     
    DefaultLogger consoleLogger = new DefaultLogger();
    consoleLogger.setErrorPrintStream(System.err);
    consoleLogger.setOutputPrintStream(System.out);
    consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
    p.addBuildListener(consoleLogger);
    
    try {
        p.fireBuildStarted();
        p.init();
        ProjectHelper helper = ProjectHelper.getProjectHelper();
        p.addReference("ant.projectHelper", helper);
        helper.parse(p, buildFile);
        p.executeTarget(p.getDefaultTarget());
        p.fireBuildFinished(null);
      
    } catch (Exception e) {}
}
 
開發者ID:bufferhe4d,項目名稱:call-IDE,代碼行數:29,代碼來源:BuildSys.java

示例2: setLogFileAndListener

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
public void setLogFileAndListener(String filename) {
  File logFolder = new File(baseDir, "log");
  if (!logFolder.exists()) {
    logFolder.mkdir();
  }
  File file = new File(baseDir + "/log", filename + "-apply.log");
  final DefaultLogger logger1 = new DefaultLogger();
  try {
    logFile = new FileOutputStream(file);
    ps = new PrintStream(logFile);
    logger1.setOutputPrintStream(ps);
    logger1.setErrorPrintStream(ps);
    logger1.setMessageOutputLevel(Project.MSG_INFO);
    project.addBuildListener(logger1);

    Log4jListener listener = new Log4jListener();
    project.addBuildListener(listener);
  } catch (FileNotFoundException e) {
    logger.error("Error assigning rebuild log file.", e);
  }
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:22,代碼來源:AntExecutor.java

示例3: setOBPrintStreamLog

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
@Deprecated
public void setOBPrintStreamLog(PrintStream p) {
  final DefaultLogger logger1 = new DefaultLogger();
  final OBPrintStream ps1 = new OBPrintStream(p);
  final OBPrintStream ps2 = new OBPrintStream(p);
  logger1.setOutputPrintStream(ps1);
  logger1.setErrorPrintStream(ps2);
  logger1.setMessageOutputLevel(Project.MSG_INFO);
  project.addBuildListener(logger1);
  err = ps2;
  log = ps1;

  // force log4j to also print to this response
  // OBLogAppender.setOutputStream(ps1);
  org.openbravo.utils.OBLogAppender.setProject(project);
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:17,代碼來源:AntExecutor.java

示例4: init

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
public void init(String _buildFile, String _baseDir) throws Exception {
    project = new Project();
    project.init();
    DefaultLogger consoleLogger = new DefaultLogger();
    consoleLogger.setErrorPrintStream(System.err);
    consoleLogger.setOutputPrintStream(System.out);
    consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
    project.addBuildListener(consoleLogger);
    if (_baseDir == null)
        _baseDir = new String(".");
    project.setBasedir(_baseDir);
    if (_buildFile == null)
        _buildFile = new String(projectBasePath + File.separator
                + "build.xml");
    ProjectHelper.configureProject(project, new File(_buildFile));
}
 
開發者ID:HongQiQu,項目名稱:AndroidAntMakePackage,代碼行數:17,代碼來源:AntMakeAPK.java

示例5: getBuildListener

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
private BuildListener getBuildListener() {
   if (antListener == null) {
      DefaultLogger logger = new DefaultLogger();
      PrintStream ps = null;
      try {
         ps = new PrintStream(new File("log/bugReportLog.txt").getAbsolutePath());
         ps.print("");
      } catch (FileNotFoundException e) {
         StringWriter sw = new StringWriter();
         e.printStackTrace(new PrintWriter(sw));
         String exceptionDetails = sw.toString();
         LOG.warning(exceptionDetails);
      }
      if (ps == null) {
         logger.setErrorPrintStream(System.err);
         logger.setOutputPrintStream(System.out);
      } else {
         logger.setErrorPrintStream(ps);
         logger.setOutputPrintStream(ps);
      }
      logger.setMessageOutputLevel(Project.MSG_INFO);
      antListener = logger;
   }
   return antListener;
}
 
開發者ID:Loreinator,項目名稱:Shuffle-Move,代碼行數:26,代碼來源:ShuffleModel.java

示例6: messageLogged

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
/**
 * @see org.apache.tools.ant.BuildListener#messageLogged(BuildEvent)
 * {@inheritDoc}.
 */
public void messageLogged(BuildEvent event) {
    log("--- MESSAGE LOGGED", Project.MSG_DEBUG);

    StringBuffer buf = new StringBuffer();

    if (event.getTask() != null) {
        String name = event.getTask().getTaskName();

        if (!emacsMode) {
            String label = "[" + name + "] ";
            int size = DefaultLogger.LEFT_COLUMN_SIZE - label.length();

            for (int i = 0; i < size; i++) {
                buf.append(" ");
            }
            buf.append(label);
        }
    }
    buf.append(event.getMessage());

    log(buf.toString(), event.getPriority());
}
 
開發者ID:apache,項目名稱:ant,代碼行數:27,代碼來源:RecorderEntry.java

示例7: javaCompile

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
/**
 * Method to Java compilation of the files (needed for tests generation).
 * 
 * @param sourceFolder
 *            = the path to source files.
 * @param libFolder
 *            = the path to external libraries needed to Java compilation.
 * @throws Exception
 *             problem with ANT projects.
 */
public void javaCompile(String sourceFolder, String libFolder)
		throws Exception {
	final StringBuilder buff = new StringBuilder();
	contractLib = contractLib + libFolder;
	// Run ant file
	Project p = new Project();
	DefaultLogger consoleLogger = createLogger(buff);
	File buildFile = accessFile("javaCompile.xml");
	p.setUserProperty("source_folder", sourceFolder);
	p.setUserProperty("source_bin", Constants.JML_SOURCE_BIN);
	p.setUserProperty("lib", libFolder);
	p.setUserProperty("jmlLib", contractLib);
	runProject(buff, p, buildFile, "javaCompile.xml", "compile_project",
			consoleLogger);
}
 
開發者ID:alyssonfm,項目名稱:jmlok,代碼行數:26,代碼來源:Detect.java

示例8: generateTestsForJava

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
/**
 * Method used to generate the tests to conformance checking on Java
 * projects.
 * 
 * @param libFolder
 *            = the path to external libraries needed to tests generation
 *            and compilation.
 * @param timeout
 *            = the time to tests generation.
 * @throws Exception
 *             When the XML cannot be read.
 */
public void generateTestsForJava(String libFolder, String timeout)
		throws Exception {
	final StringBuilder buff = new StringBuilder();
	contractLib = contractLib + libFolder;
	// Run Randoop
	String pathToRandoop = getJARPath() + Constants.FILE_SEPARATOR + "lib"
			+ Constants.FILE_SEPARATOR + "randoop.jar";
	runRandoop(libFolder, timeout, pathToRandoop);
	// Run ant file
	Project p = new Project();
	DefaultLogger consoleLogger = createLogger(buff);
	File buildFile = accessFile("generateTests.xml");
	p.setUserProperty("classes", Constants.CLASSES);
	p.setUserProperty("source_bin", Constants.JML_SOURCE_BIN);
	p.setUserProperty("tests_src", Constants.TEST_DIR);
	p.setUserProperty("tests_bin", Constants.TEST_BIN);
	p.setUserProperty("tests_folder", Constants.TESTS);
	p.setUserProperty("lib", libFolder);
	p.setUserProperty("jmlLib", contractLib);
	p.setUserProperty("timeout", timeout);
	runProject(buff, p, buildFile, "generateTests.xml",
			"compile_tests", consoleLogger);
}
 
開發者ID:alyssonfm,項目名稱:jmlok,代碼行數:36,代碼來源:Detect.java

示例9: runTestsOnJava

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
/**
 * Method used to run the tests with the JML oracles.
 * 
 * @param libFolder
 *            = the path to external libraries needed to tests execution.
 * @throws Exception
 *             problems with ANT project.
 */
private void runTestsOnJava(String libFolder) throws Exception {
	final StringBuilder buff = new StringBuilder();
	// Run ant file
	Project p = new Project();
	DefaultLogger consoleLogger = createLogger(buff);
	File buildFile = accessFile("runTests.xml");
	p.setUserProperty("lib", libFolder);
	p.setUserProperty("jmlBin", Constants.JML_BIN);
	if (compiler == Constants.JMLC_COMPILER)
		p.setUserProperty("jmlCompiler", Constants.JMLC_SRC);
	p.setUserProperty("tests_src", Constants.TEST_DIR);
	p.setUserProperty("tests_bin", Constants.TEST_BIN);
	runProject(buff, p, buildFile, "runTests.xml", "run_tests",
			consoleLogger);
}
 
開發者ID:alyssonfm,項目名稱:jmlok,代碼行數:24,代碼來源:Detect.java

示例10: newProject

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
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;
}
 
開發者ID:Alexey1Gavrilov,項目名稱:ExpectIt,代碼行數:18,代碼來源:AntHarnessTest.java

示例11: main

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
public static void main(String[] args) {

    DefaultLogger consoleLogger = new DefaultLogger();
    consoleLogger.setErrorPrintStream(System.err);
    consoleLogger.setOutputPrintStream(System.out);
    consoleLogger.setMessageOutputLevel(Project.MSG_INFO);

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

  }
 
開發者ID:perdian,項目名稱:ant-webstart,代碼行數:19,代碼來源:TestAnt.java

示例12: compile

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
/**
 * Description: compile method that maintains the i/o streams after the task is done.
 * @param file path of the build xml to be executed
 * @param out current output stream
 * @param err current input stream
 */
public static void compile( String file, PrintStream out, PrintStream err) {
    
    // File buildFile = new File("build.xml");
    File buildFile = new File(file);
    Project p = new Project();
    p.setUserProperty("ant.file", buildFile.getAbsolutePath());     
    DefaultLogger consoleLogger = new DefaultLogger();
    consoleLogger.setErrorPrintStream(System.err);
    consoleLogger.setOutputPrintStream(System.out);
    consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
    
    p.addBuildListener(consoleLogger);
    
    try {
        p.fireBuildStarted();
        p.init();
        ProjectHelper helper = ProjectHelper.getProjectHelper();
        p.addReference("ant.projectHelper", helper);
        helper.parse(p, buildFile);
        p.executeTarget(p.getDefaultTarget());
        p.fireBuildFinished(null);
        System.setErr(err);
        System.setOut(out);
        
        
    } catch (Exception e) {}
}
 
開發者ID:bufferhe4d,項目名稱:call-IDE,代碼行數:34,代碼來源:BuildSys.java

示例13: LangtoolsIdeaAntLogger

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:LangtoolsIdeaAntLogger.java

示例14: JdkIdeaAntLogger

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:JdkIdeaAntLogger.java

示例15: LangtoolsIdeaAntLogger

import org.apache.tools.ant.DefaultLogger; //導入依賴的package包/類
public LangtoolsIdeaAntLogger(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);
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:11,代碼來源:LangtoolsIdeaAntLogger.java


注:本文中的org.apache.tools.ant.DefaultLogger類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。