use of org.apache.tools.ant.types.resources.FileResource 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.resources.FileResource 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);
}
Aggregations