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

The following examples show how to use org.apache.tools.ant.Project#MSG_ERR . 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: 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 3
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 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: 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 6
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 7
Source File: BaseRedirectorHelperTask.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Handles output with ERR priority to error stream and all other priorities
 * to output stream.
 *
 * @param output The output to log. Should not be <code>null</code>.
 * @param priority The priority level that should be used
 */
protected void handleOutput(String output, int priority) {
    if (priority == Project.MSG_ERR) {
        handleErrorOutput(output);
    } else {
        handleOutput(output);
    }
}
 
Example 8
Source File: BaseRedirectorHelperTask.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Handles output with ERR priority to error stream and all other
 * priorities to output stream.
 *
 * @param output The output to log. Should not be <code>null</code>.
 */
protected void handleOutput(String output, int priority) {
    if (priority == Project.MSG_ERR) {
        handleErrorOutput(output);
    } else {
        handleOutput(output);
    }
}
 
Example 9
Source File: AbstractMithraGenerator.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void log(String s, int level)
{
    super.log(s, level);
    if (level == Project.MSG_ERR)
    {
        this.errorLogs.append(s).append("\n");
    }
}
 
Example 10
Source File: BaseRedirectorHelperTask.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Handles output with ERR priority to error stream and all other
 * priorities to output stream.
 *
 * @param output The output to log. Should not be <code>null</code>.
 */
protected void handleOutput(String output, int priority) {
    if (priority == Project.MSG_ERR) {
        handleErrorOutput(output);
    } else {
        handleOutput(output);
    }
}
 
Example 11
Source File: XtendCompilerAntTaskTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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: 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 13
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 14
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);
}