Java Code Examples for org.apache.tools.ant.Project#MSG_INFO

The following examples show how to use org.apache.tools.ant.Project#MSG_INFO . 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: BundleLocator.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void setProperty(final String bn,
                         final String propName)
{
  log("Searching for a bundle with name '" +bn +"'.", Project.MSG_DEBUG);
  final BundleArchives.BundleArchive ba = getBundleArchive(bn);

  if (ba!=null) {
    getProject().setProperty(propName, ba.file.getAbsolutePath());
    log(propName +" = " +ba.file, Project.MSG_VERBOSE);
  } else {
    final int logLevel = failOnMissingBundles
      ? Project.MSG_ERR : Project.MSG_INFO;
    log("No bundle with name '" +bn +"' found.", logLevel);
    log("Known bundles names: " +bas.getKnownNames(), logLevel);

    if (failOnMissingBundles) {
      throw new BuildException("No bundle with name '" +bn+"' found.");
    }
  }
}
 
Example 2
Source File: AntSLF4JLogger.java    From spoofax with Apache License 2.0 6 votes vote down vote up
@Override public void messageLogged(BuildEvent event) {
    switch(event.getPriority()) {
        case Project.MSG_ERR:
            log.error(event.getMessage());
            break;
        case Project.MSG_WARN:
            log.warn(event.getMessage());
            break;
        case Project.MSG_INFO:
            log.info(event.getMessage());
            break;
        default:
            log.trace(event.getMessage());
            break;
    }
}
 
Example 3
Source File: TaskLogger.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected int getMessageLevel( LogRecord record )
{
	Level level = record.getLevel( );
	if ( level.equals( Level.SEVERE ) )
	{
		return Project.MSG_ERR;
	}
	if ( level.equals( Level.WARNING ) )
	{
		return Project.MSG_WARN;
	}
	if ( level.equals( Level.INFO ) )
	{
		return Project.MSG_INFO;
	}
	return Project.MSG_VERBOSE;
}
 
Example 4
Source File: LoggingBuildListener.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
public void messageLogged (@Nonnull final BuildEvent aEvent)
{
  if (aEvent.getPriority () <= Project.MSG_ERR)
    LOGGER.error (aEvent.getMessage (), aEvent.getException ());
  else
    if (aEvent.getPriority () <= Project.MSG_WARN)
      LOGGER.warn (aEvent.getMessage (), aEvent.getException ());
    else
      if (aEvent.getPriority () <= Project.MSG_INFO)
        LOGGER.info (aEvent.getMessage (), aEvent.getException ());
      else
      {
        // Switch this from "debug" to "info" to get more output
        if (m_bDebugMode)
          LOGGER.info (aEvent.getMessage (), aEvent.getException ());
        else
          LOGGER.debug (aEvent.getMessage (), aEvent.getException ());
      }
}
 
Example 5
Source File: MyBuildFileRule.java    From ph-schematron with Apache License 2.0 6 votes vote down vote up
/**
 * Fired whenever a message is logged.
 *
 * @see BuildEvent#getMessage()
 * @see BuildEvent#getPriority()
 */
public void messageLogged (final BuildEvent event)
{
  if (event.getPriority () > m_nLogLevel)
  {
    // ignore event
    return;
  }

  if (event.getPriority () == Project.MSG_INFO ||
      event.getPriority () == Project.MSG_WARN ||
      event.getPriority () == Project.MSG_ERR)
  {
    logBuffer.append (event.getMessage ()).append ('\n');
  }
  fullLogBuffer.append (event.getMessage ()).append ('\n');
}
 
Example 6
Source File: AntHandler.java    From scriptella-etl with Apache License 2.0 6 votes vote down vote up
/**
 * Converts JUL level to appropriate Ant message priority
 *
 * @param level JUL level
 * @return Ant message priority
 */
private int convert(Level level) {
    final int lev = level.intValue();
    if (lev >= Level.SEVERE.intValue()) {
        return Project.MSG_ERR;
    }
    if (lev >= Level.WARNING.intValue()) {
        return Project.MSG_WARN;
    }
    if (lev >= Level.INFO.intValue()) {
        return Project.MSG_INFO;
    }
    if (debug) {
        return Project.MSG_INFO;
    }
    if (lev >= Level.FINE.intValue()) {
        return Project.MSG_VERBOSE;
    }
    if (lev > Level.OFF.intValue()) {
        return Project.MSG_DEBUG;
    }
    return -1;
}
 
Example 7
Source File: XtendCompilerAntTaskTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Fired whenever a message is logged.
 * 
 * @see BuildEvent#getMessage()
 * @see BuildEvent#getPriority()
 */
@Override
public void messageLogged(BuildEvent event) {
	if (event.getPriority() > logLevel) {
		// ignore event
		return;
	}
	if (event.getPriority() == Project.MSG_INFO || event.getPriority() == Project.MSG_WARN
			|| event.getPriority() == Project.MSG_ERR) {
		logBuffer.append(event.getMessage());
	}
}
 
Example 8
Source File: ForkedJavaOverride.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setProcessOutputStream(InputStream inputStream) throws IOException {
    OutputStream os = getOutputStream();
    Integer logLevel = null;
    if (os == null || delegateOutputStream) {
        os = AntBridge.delegateOutputStream(false);
        logLevel = Project.MSG_INFO;
    }
    outTask = new Thread(Thread.currentThread().getThreadGroup(), outCopier = new Copier(inputStream, os, logLevel, outEncoding, foldingHelper),
            "Out Thread for " + getProject().getName()); // NOI18N
    outTask.setDaemon(true);
    outTask.start();
}
 
Example 9
Source File: AntErrorManager.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void printSummary() {
  String message =
      getErrorCount() + " error(s), " + getWarningCount() + " warning(s)";

  if (getTypedPercent() > 0.0) {
    message += ", " + getTypedPercent() + " typed";
  }

  int level = (getErrorCount() + getWarningCount() == 0) ?
      Project.MSG_INFO : Project.MSG_WARN;
  this.task.log(message, level);
}
 
Example 10
Source File: NameBearerHandle.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * This is called for every log message (of any priority). If the
 * current process has been interrupted (the user pressed the stop
 * button) then we throw an exception to interrupt the currently
 * executing Ant task. Other than that, we simply pass INFO and
 * higher messages to the GATE status listener.
 */
@Override
public void messageLogged(BuildEvent buildEvent) {
  // check for interruption
  if(interrupted) {
    interrupted = false;
    throw new BuildException("Export interrupted");
  }
  if(buildEvent.getPriority() <= Project.MSG_INFO) {
    statusChanged(buildEvent.getMessage());
  }
  // log the message to log4j for debugging purposes
  log.debug(buildEvent.getPriority() + ": " + buildEvent.getMessage());
}
 
Example 11
Source File: GetMavenDependenciesTask.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public void setVerbose(boolean verbose) {
  verboseLevel = (verbose ? Project.MSG_VERBOSE : Project.MSG_INFO);
}
 
Example 12
Source File: BundleLocator.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void transformPath()
{
  final Path newPath = new Path(getProject());
  log("Updating bundle paths in class path reference '"
      +classPathRef.getRefId() +"'.", Project.MSG_DEBUG);

  String[] pathElements = null;
  try {
    final Path path = (Path) classPathRef.getReferencedObject();
    pathElements = path.list();
  } catch (final BuildException e) {
    // Unsatisfied ref in the given path; can not expand.
    // Make the new path a reference to the old one.
    log("Unresolvable reference in '" +classPathRef.getRefId()
        +"' can not expand bundle names in it.", Project.MSG_WARN);
    newPath.setRefid(classPathRef);
  }

  if (null!=pathElements) {
    for (final String pathElement2 : pathElements) {
      final File pathElement = new File(pathElement2);
      boolean added = false;
      log("path element: "+pathElement, Project.MSG_DEBUG);
      if (!pathElement.exists()) {
        log("Found non existing path element: " +pathElement,
            Project.MSG_DEBUG);
        final String fileName = pathElement.getName();
        final BundleArchives.BundleArchive ba = getBundleArchive(fileName);
        if (ba!=null) {
          final String filePath = ba.file.getAbsolutePath();
          newPath.setPath(filePath);
          added = true;
          log(fileName +" => " +filePath, Project.MSG_VERBOSE);
        } else if (isBundleNameWithWildcardVersion(fileName)) {
          final int logLevel = failOnMissingBundles
            ? Project.MSG_ERR : Project.MSG_INFO;
          log("No match for '" +fileName +"' when expanding the path named '"
              +classPathRef.getRefId() +"'.", logLevel);
          log("Known bundles names: " +bas.getKnownNames(), logLevel);
          if (failOnMissingBundles) {
            throw new BuildException
              ("No bundle with name like '" +fileName+"' found.");
          }
        } else {
          log("No match for '" +fileName +"' when expanding the path named '"
              +classPathRef.getRefId() +"'.", Project.MSG_VERBOSE);
        }
      }
      if (!added) {
        newPath.setPath(pathElement.getAbsolutePath());
      }
    }
    log(newClassPathId +" = " +newPath, Project.MSG_VERBOSE);
  }
  getProject().addReference(newClassPathId, newPath);
}
 
Example 13
Source File: AntTaskTestCase.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public Project configureProject() {
    Project project = TestHelper.newProject();
    antTestListener = new AntTestListener(Project.MSG_INFO);
    project.addBuildListener(antTestListener);
    return project;
}
 
Example 14
Source File: LibVersionsCheckTask.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
/**
 * Execute the task.
 */
@Override
public void execute() throws BuildException {
  log("Starting scan.", verboseLevel);
  long start = System.currentTimeMillis();

  setupIvy();

  int numErrors = 0;
  if ( ! verifySortedCoordinatesPropertiesFile(centralizedVersionsFile)) {
    ++numErrors;
  }
  if ( ! verifySortedCoordinatesPropertiesFile(ignoreConflictsFile)) {
    ++numErrors;
  }
  collectDirectDependencies();
  if ( ! collectVersionConflictsToIgnore()) {
    ++numErrors;
  }

  int numChecked = 0;

  @SuppressWarnings("unchecked")
  Iterator<Resource> iter = (Iterator<Resource>)ivyXmlResources.iterator();
  while (iter.hasNext()) {
    final Resource resource = iter.next();
    if ( ! resource.isExists()) {
      throw new BuildException("Resource does not exist: " + resource.getName());
    }
    if ( ! (resource instanceof FileResource)) {
      throw new BuildException("Only filesystem resources are supported: " 
          + resource.getName() + ", was: " + resource.getClass().getName());
    }

    File ivyXmlFile = ((FileResource)resource).getFile();
    try {
      if ( ! checkIvyXmlFile(ivyXmlFile)) {
        ++numErrors;
      }
      if ( ! resolveTransitively(ivyXmlFile)) {
        ++numErrors;
      }
      if ( ! findLatestConflictVersions()) {
        ++numErrors;
      }
    } catch (Exception e) {
      throw new BuildException("Exception reading file " + ivyXmlFile.getPath() + " - " + e.toString(), e);
    }
    ++numChecked;
  }

  log("Checking for orphans in " + centralizedVersionsFile.getName(), verboseLevel);
  for (Map.Entry<String,Dependency> entry : directDependencies.entrySet()) {
    String coordinateKey = entry.getKey();
    if ( ! entry.getValue().directlyReferenced) {
      log("ORPHAN coordinate key '" + coordinateKey + "' in " + centralizedVersionsFile.getName()
          + " is not found in any " + IVY_XML_FILENAME + " file.",
          Project.MSG_ERR);
      ++numErrors;
    }
  }

  int numConflicts = emitConflicts();

  int messageLevel = numErrors > 0 ? Project.MSG_ERR : Project.MSG_INFO;
  log("Checked that " + centralizedVersionsFile.getName() + " and " + ignoreConflictsFile.getName()
      + " have lexically sorted '/org/name' keys and no duplicates or orphans.",
      messageLevel);
  log("Scanned " + numChecked + " " + IVY_XML_FILENAME + " files for rev=\"${/org/name}\" format.",
      messageLevel);
  log("Found " + numConflicts + " indirect dependency version conflicts.");
  log(String.format(Locale.ROOT, "Completed in %.2fs., %d error(s).",
                    (System.currentTimeMillis() - start) / 1000.0, numErrors),
      messageLevel);

  if (numConflicts > 0 || numErrors > 0) {
    throw new BuildException("Lib versions check failed. Check the logs.");
  }
}
 
Example 15
Source File: LibVersionsCheckTask.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public void setVerbose(boolean verbose) {
  verboseLevel = (verbose ? Project.MSG_INFO : Project.MSG_VERBOSE);
}
 
Example 16
Source File: LicenseCheckTask.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
public void setVerbose(boolean verbose) {
  verboseLevel = (verbose ? Project.MSG_INFO : Project.MSG_VERBOSE);
}
 
Example 17
Source File: ForkedJavaOverride.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void run() {
    /*
    StringBuilder content = new StringBuilder();
    long tick = System.currentTimeMillis();
    content.append(String.format("[init: %1.1fsec]", (tick - init) / 1000.0));
     */
    
    if (ow == null && logLevel != null) {
        Vector v = getProject().getBuildListeners();
        for (Object o : v) {
            if (o instanceof NbBuildLogger) {
                NbBuildLogger l = (NbBuildLogger) o;
                err = logLevel != Project.MSG_INFO;
                ow = err ? l.err : l.out;
                session = l.thisSession;
                break;
            }
        }
    }
    try {
        try {
            int c;
            while ((c = in.read()) != -1) {
                if (logLevel == null) {
                    // Input gets sent immediately.
                    out.write(c);
                    out.flush();
                } else {
                    synchronized (this) {
                        if (c == '\n') {                                    
                            String str = currentLine.toString(encoding);
                            int len = str.length();
                            if (len > 0 && str.charAt(len - 1) == '\r') {
                                str = str.substring(0, len - 1);
                            }

                            foldingHelper.checkFolds(str, err, session);
                            if (str.length() < LOGGER_MAX_LINE_LENGTH) { // not too long message, probably interesting
                                // skip stack traces (hyperlinks are created by JavaAntLogger), everything else write directly
                                if (!STACK_TRACE.matcher(str).find()) {
                                    StandardLogger.findHyperlink(str, session, null).println(session, err);
                                }
                            } else {
                                // do not match long strings, directly create a trivial hyperlink
                                StandardLogger.findHyperlink(str, session, null).println(session, err);
                            }
                            log(str, logLevel);
                            currentLine.reset();
                        } else {                                    
                            currentLine.write(c);
                            if(currentLine.size() > 8192) {
                                flusher.run();
                            } else {
                                flusher.schedule(250);
                            }
                        }
                    }    
                }
            }
        } finally {
            if (logLevel != null) {
                maybeFlush();
                if (err) {
                    foldingHelper.clearHandle();
                }
            }
        }
    } catch (IOException x) {
        // ignore IOException: Broken pipe from FileOutputStream.writeBytes in BufferedOutputStream.flush
    } catch (ThreadDeath d) {
        // OK, build just stopped.
        return;
    }
    //System.err.println("copied " + in + " to " + out + "; content='" + content + "'");
}