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

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

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

Project.getBuildListeners介绍

[英]Return a copy of the list of build listeners for the project.
[中]返回项目的生成侦听器列表的副本。

代码示例

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

public Level getAntLogLevel() {
  for (final BuildListener l : project.getBuildListeners()) {
    Field declaredField = null;
    try {

代码示例来源:origin: micronaut-projects/micronaut-core

/**
 * @param project The Ant {@link Project}
 */
public static void addMicronautConsoleBuildListener(Project project) {
  final BuildLogger logger = new MicronautConsoleLogger();
  logger.setMessageOutputLevel(Project.MSG_INFO);
  logger.setOutputPrintStream(System.out);
  logger.setErrorPrintStream(System.err);
  project.addBuildListener(logger);
  MicronautConsole instance = MicronautConsole.getInstance();
  project.addBuildListener(new ConsoleBuildListener(instance));
  if (!instance.isVerbose()) {
    for (Object buildListener : project.getBuildListeners()) {
      if (buildListener instanceof BuildLogger) {
        ((BuildLogger) buildListener).setMessageOutputLevel(LogLevel.ERR.getLevel());
      }
    }
  }
}

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

newProject.setInputHandler(getProject().getInputHandler());
getProject().getBuildListeners().forEach(bl -> newProject.addBuildListener(bl));

代码示例来源:origin: org.codehaus.gant/gant_groovy2.1

/**
  *  Accessor for the logger associated with the {@code Project}.
  *
  *  @return The {@code BuildLogger}.
  */
 public BuildLogger getLogger() {
  @SuppressWarnings("unchecked") final List<? extends BuildListener> listeners = getProject().getBuildListeners();
  assert listeners.size() > 0;
  return (BuildLogger)listeners.get(0);
 }
}

代码示例来源:origin: org.codehaus.gant/gant_groovy1.8

/**
  *  Accessor for the logger associated with the {@code Project}.
  *
  *  @return The {@code BuildLogger}.
  */
 public BuildLogger getLogger() {
  @SuppressWarnings("unchecked") final List<? extends BuildListener> listeners = getProject().getBuildListeners();
  assert listeners.size() > 0;
  return (BuildLogger)listeners.get(0);
 }
}

代码示例来源:origin: org.codehaus.gant/gant_groovy2.0

/**
  *  Accessor for the logger associated with the {@code Project}.
  *
  *  @return The {@code BuildLogger}.
  */
 public BuildLogger getLogger() {
  @SuppressWarnings("unchecked") final List<? extends BuildListener> listeners = getProject().getBuildListeners();
  assert listeners.size() > 0;
  return (BuildLogger)listeners.get(0);
 }
}

代码示例来源:origin: org.codehaus.gmaven/gmaven-mojo

/**
 * Lazily initialize the AntBuilder, so we can pick up the log impl correctly.
 */
private AntBuilder getAnt() {
  if (this.ant == null) {
    AntBuilder ant = new AntBuilder();
    BuildLogger logger = (BuildLogger) ant.getAntProject().getBuildListeners().get(0);
    logger.setEmacsMode(true);
    this.ant = ant;
  }
  return this.ant;
}

代码示例来源:origin: org.codehaus.gmaven.runtime/gmaven-runtime-2.0

private AntBuilder createAntBuilder() {
  AntBuilder ant = new AntBuilder();
  Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
  if (obj instanceof BuildLogger) {
    BuildLogger logger = (BuildLogger)obj;
    logger.setEmacsMode(true);
  }
  return ant;
}

代码示例来源:origin: org.codehaus.mojo.groovy.runtime/groovy-runtime-1.1

private AntBuilder createAntBuilder() {
  AntBuilder ant = new AntBuilder();
  Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
  if (obj instanceof BuildLogger) {
    BuildLogger logger = (BuildLogger)obj;
    logger.setEmacsMode(true);
  }
  return ant;
}

代码示例来源:origin: org.codehaus.gmaven.runtime/gmaven-runtime-1.6

private AntBuilder createAntBuilder() {
  AntBuilder ant = new AntBuilder();
  Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
  if (obj instanceof BuildLogger) {
    BuildLogger logger = (BuildLogger)obj;
    logger.setEmacsMode(true);
  }
  return ant;
}

代码示例来源:origin: org.codehaus.gmaven.runtime/gmaven-runtime-1.7

private AntBuilder createAntBuilder() {
  AntBuilder ant = new AntBuilder();
  Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
  if (obj instanceof BuildLogger) {
    BuildLogger logger = (BuildLogger)obj;
    logger.setEmacsMode(true);
  }
  return ant;
}

代码示例来源:origin: org.codehaus.groovy.maven.runtime/gmaven-runtime-1.6

private AntBuilder createAntBuilder() {
  AntBuilder ant = new AntBuilder();
  Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
  if (obj instanceof BuildLogger) {
    BuildLogger logger = (BuildLogger)obj;
    logger.setEmacsMode(true);
  }
  return ant;
}

代码示例来源:origin: org.codehaus.gmaven.runtime/gmaven-runtime-1.5

private AntBuilder createAntBuilder() {
  AntBuilder ant = new AntBuilder();
  Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
  if (obj instanceof BuildLogger) {
    BuildLogger logger = (BuildLogger)obj;
    logger.setEmacsMode(true);
  }
  return ant;
}

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

/**
 * Create an object for a {@link MagicContext} entry.
 */
public Object createMagicContextValue(final MagicContext magic) {
 checkNotNull(magic);
 switch (magic) {
  // Create the AntBuilder instance, normalizing its output to match mavens
  case ANT_BUILDER: {
   AntBuilder ant = new AntBuilder();
   // TODO: Do we need to root the ant-project or otherwise augment the configuration?
   Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
   if (obj instanceof BuildLogger) {
    BuildLogger logger = (BuildLogger) obj;
    logger.setEmacsMode(true);
   }
   return ant;
  }
 }
 throw new Error("Unsupported magic context: " + magic);
}

代码示例来源:origin: org.codehaus.gmaven/gmaven-adapter-impl

/**
 * Create an object for a {@link MagicContext} entry.
 */
public Object createMagicContextValue(final MagicContext magic) {
 checkNotNull(magic);
 switch (magic) {
  // Create the AntBuilder instance, normalizing its output to match mavens
  case ANT_BUILDER: {
   AntBuilder ant = new AntBuilder();
   // TODO: Do we need to root the ant-project or otherwise augment the configuration?
   Object obj = ant.getAntProject().getBuildListeners().elementAt(0);
   if (obj instanceof BuildLogger) {
    BuildLogger logger = (BuildLogger) obj;
    logger.setEmacsMode(true);
   }
   return ant;
  }
 }
 throw new Error("Unsupported magic context: " + magic);
}

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

/**
 * This method is called by the Ant runtime by reflection. We use the project reference for
 * registration of this class as BuildListener.
 *
 * @param project
 *            project reference
 */
@Override
public void setProject(Project project) {
  // store project reference for logging
  super.setProject(project);
  // check if already registered
  // register if needed
  if (project.getBuildListeners().stream().noneMatch(FailureRecorder.class::isInstance)) {
    verbose("Register FailureRecorder (@" + this.hashCode() + ") as BuildListener");
    project.addBuildListener(this);
  }
}

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

private void addBuildListener(Java java)
{
  boolean foundBuildListener = false;
  for (Object listenerObject : java.getProject().getBuildListeners())
  {
    if (listenerObject instanceof AntBuildListener)
    {
      foundBuildListener = true;
      break;
    }
  }
  if (!foundBuildListener)
  {
    java.getProject().addBuildListener(new AntBuildListener(logger));
  }
}

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

private void addBuildListener(Java java)
{
  boolean foundBuildListener = false;
  for (Object listenerObject : java.getProject().getBuildListeners())
  {
    if (listenerObject instanceof AntBuildListener)
    {
      foundBuildListener = true;
      break;
    }
  }
  if (!foundBuildListener)
  {
    java.getProject().addBuildListener(new AntBuildListener(logger));
  }
}

代码示例来源:origin: org.gradle/gradle-core

public DefaultAntBuilder create() {
  AntLoggingAdapter loggingAdapter = loggingAdapterFactory.create();
  DefaultAntBuilder antBuilder = new DefaultAntBuilder(project, loggingAdapter);
  antBuilder.getProject().setBaseDir(project.getProjectDir());
  antBuilder.getProject().removeBuildListener(antBuilder.getProject().getBuildListeners().get(0));
  antBuilder.getProject().addBuildListener(loggingAdapter);
  stoppable.add(antBuilder);
  return antBuilder;
}

代码示例来源:origin: org.grails/grails-bootstrap

public static void addGrailsConsoleBuildListener(Project project) {
  final BuildLogger logger = new GrailsConsoleLogger();
  logger.setMessageOutputLevel(Project.MSG_INFO);
  logger.setOutputPrintStream(System.out);
  logger.setErrorPrintStream(System.err);
  project.addBuildListener(logger);
  GrailsConsole instance = GrailsConsole.getInstance();
  project.addBuildListener(new GrailsConsoleBuildListener(instance));
  if (!instance.isVerbose()) {
    for (Object buildListener : project.getBuildListeners()) {
      if (buildListener instanceof BuildLogger) {
        ((BuildLogger)buildListener).setMessageOutputLevel(LogLevel.ERR.getLevel());
      }
    }
  }
}

相关文章