use of org.apache.tools.ant.types.Resource in project lucene-solr by apache.
the class LibVersionsCheckTask method execute.
/**
* 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.");
}
}
use of org.apache.tools.ant.types.Resource in project lucene-solr by apache.
the class LicenseCheckTask method processJars.
/**
* Process all JARs.
*/
private void processJars() {
log("Starting scan.", verboseLevel);
long start = System.currentTimeMillis();
@SuppressWarnings("unchecked") Iterator<Resource> iter = (Iterator<Resource>) jarResources.iterator();
int checked = 0;
int errors = 0;
while (iter.hasNext()) {
final Resource r = iter.next();
if (!r.isExists()) {
throw new BuildException("JAR resource does not exist: " + r.getName());
}
if (!(r instanceof FileResource)) {
throw new BuildException("Only filesystem resource are supported: " + r.getName() + ", was: " + r.getClass().getName());
}
File jarFile = ((FileResource) r).getFile();
if (!checkJarFile(jarFile)) {
errors++;
}
checked++;
}
log(String.format(Locale.ROOT, "Scanned %d JAR file(s) for licenses (in %.2fs.), %d error(s).", checked, (System.currentTimeMillis() - start) / 1000.0, errors), errors > 0 ? Project.MSG_ERR : Project.MSG_INFO);
}
use of org.apache.tools.ant.types.Resource in project jslint4java by happygiraffe.
the class JSLintTask method execute.
/**
* Scan the specified directories for JavaScript files and lint them.
*/
@Override
public void execute() throws BuildException {
if (resources.size() == 0) {
// issue 53: this isn't a fail, just a notice.
log(NO_FILES_TO_LINT);
}
JSLint lint = makeLint();
applyOptions(lint);
for (ResultFormatter rf : formatters) {
rf.begin();
}
int failedCount = 0;
int totalErrorCount = 0;
for (Resource resource : resources.listResources()) {
try {
int errorCount = lintStream(lint, resource);
if (errorCount > 0) {
totalErrorCount += errorCount;
failedCount++;
}
} catch (IOException e) {
throw new BuildException(e);
}
}
for (ResultFormatter rf : formatters) {
rf.end();
}
if (failedCount != 0) {
String msg = failureMessage(failedCount, totalErrorCount);
if (haltOnFailure) {
throw new BuildException(msg);
} else {
log(msg);
if (failureProperty != null) {
getProject().setProperty(failureProperty, msg);
}
}
}
}
use of org.apache.tools.ant.types.Resource in project xtext-xtend by eclipse.
the class XtendCompilerAntTask method validateArgs.
private void validateArgs() {
if (getDestdir() == null) {
throw new BuildException("Destination directory 'destdir' is required.");
}
Path srcDirs = getSrcdir();
if (srcDirs == null) {
throw new BuildException("Sources directory 'srcdir' is required.");
}
Iterator<?> pathIter = srcDirs.iterator();
while (pathIter.hasNext()) {
Object next = pathIter.next();
if (!(next instanceof Resource && ((Resource) next).isDirectory())) {
throw new BuildException("Source directory must be a directory. Check 'srcdir' entry: " + next);
}
}
}
Aggregations