use of org.apache.tools.ant.BuildException in project lucene-solr by apache.
the class LibVersionsCheckTask method collectVersionConflictsToIgnore.
/**
* Collects indirect dependency version conflicts to ignore
* in ivy-ignore-conflicts.properties, and also checks for orphans
* (coordinates not included in ivy-versions.properties).
*
* Returns true if no orphans are found.
*/
private boolean collectVersionConflictsToIgnore() {
log("Checking for orphans in " + ignoreConflictsFile.getName(), verboseLevel);
boolean orphansFound = false;
InterpolatedProperties properties = new InterpolatedProperties();
try (InputStream inputStream = new FileInputStream(ignoreConflictsFile);
Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
properties.load(reader);
} catch (IOException e) {
throw new BuildException("Exception reading " + ignoreConflictsFile + ": " + e.toString(), e);
}
for (Object obj : properties.keySet()) {
String coordinate = (String) obj;
if (COORDINATE_KEY_PATTERN.matcher(coordinate).matches()) {
if (!directDependencies.containsKey(coordinate)) {
orphansFound = true;
log("ORPHAN coordinate key '" + coordinate + "' in " + ignoreConflictsFile.getName() + " is not found in " + centralizedVersionsFile.getName(), Project.MSG_ERR);
} else {
String versionsToIgnore = properties.getProperty(coordinate);
List<String> ignore = Arrays.asList(versionsToIgnore.trim().split("\\s*,\\s*|\\s+"));
ignoreConflictVersions.put(coordinate, new HashSet<>(ignore));
}
}
}
return !orphansFound;
}
use of org.apache.tools.ant.BuildException in project lucene-solr by apache.
the class LibVersionsCheckTask method setupIvy.
private void setupIvy() {
IvySettings ivySettings = new IvySettings();
try {
ivySettings.setVariable("common.build.dir", commonBuildDir.getAbsolutePath());
ivySettings.setVariable("ivy.exclude.types", "source|javadoc");
ivySettings.setVariable("ivy.resolution-cache.dir", ivyResolutionCacheDir.getAbsolutePath());
ivySettings.setVariable("ivy.lock-strategy", ivyLockStrategy);
// nested settings file
ivySettings.setVariable("ivysettings.xml", getProject().getProperty("ivysettings.xml"));
ivySettings.setBaseDir(commonBuildDir);
ivySettings.setDefaultConflictManager(new NoConflictManager());
ivy = Ivy.newInstance(ivySettings);
ivy.configure(topLevelIvySettingsFile);
} catch (Exception e) {
throw new BuildException("Exception reading " + topLevelIvySettingsFile.getPath() + ": " + e.toString(), e);
}
}
use of org.apache.tools.ant.BuildException in project lucene-solr by apache.
the class LibVersionsCheckTask method xmlToString.
private String xmlToString(File ivyXmlFile) {
StringWriter writer = new StringWriter();
try {
StreamSource inputSource = new StreamSource(new FileInputStream(ivyXmlFile.getPath()));
Transformer serializer = TransformerFactory.newInstance().newTransformer();
serializer.transform(inputSource, new StreamResult(writer));
} catch (TransformerException | IOException e) {
throw new BuildException("Exception reading " + ivyXmlFile.getPath() + ": " + e.toString(), e);
}
return writer.toString();
}
use of org.apache.tools.ant.BuildException in project lucene-solr by apache.
the class LibVersionsCheckTask method collectDirectDependencies.
private void collectDirectDependencies() {
InterpolatedProperties properties = new InterpolatedProperties();
try (InputStream inputStream = new FileInputStream(centralizedVersionsFile);
Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
properties.load(reader);
} catch (IOException e) {
throw new BuildException("Exception reading " + centralizedVersionsFile + ": " + e.toString(), e);
}
for (Object obj : properties.keySet()) {
String coordinate = (String) obj;
Matcher matcher = COORDINATE_KEY_PATTERN.matcher(coordinate);
if (matcher.matches()) {
String org = matcher.group(2);
String name = matcher.group(3);
String directVersion = properties.getProperty(coordinate);
Dependency dependency = new Dependency(org, name, directVersion);
directDependencies.put(coordinate, dependency);
}
}
}
use of org.apache.tools.ant.BuildException in project gcontracts by andresteingress.
the class ContractGroovyDoc method execute.
public void execute() throws BuildException {
List<String> packagesToDoc = new ArrayList<String>();
Path sourceDirs = new Path(getProject());
Properties properties = new Properties();
properties.setProperty("windowTitle", windowTitle);
properties.setProperty("docTitle", docTitle);
properties.setProperty("footer", footer);
properties.setProperty("header", header);
checkScopeProperties(properties);
properties.setProperty("publicScope", publicScope.toString());
properties.setProperty("protectedScope", protectedScope.toString());
properties.setProperty("packageScope", packageScope.toString());
properties.setProperty("privateScope", privateScope.toString());
properties.setProperty("author", author.toString());
properties.setProperty("processScripts", processScripts.toString());
properties.setProperty("includeMainForScripts", includeMainForScripts.toString());
properties.setProperty("overviewFile", overviewFile != null ? overviewFile.getAbsolutePath() : "");
if (sourcePath != null) {
sourceDirs.addExisting(sourcePath);
}
parsePackages(packagesToDoc, sourceDirs);
if (classTemplates.size() == 0)
throw new BuildException("Method getClassTemplates() needs to return at least a single classTemplate String!");
GroovyDocTool htmlTool = new GroovyDocTool(createResourceManager(), sourcePath.list(), getDocTemplates(), getPackageTemplates(), getClassTemplates(), links, properties);
try {
htmlTool.add(sourceFilesToDoc);
FileOutputTool output = new FileOutputTool();
// TODO push destDir through APIs?
htmlTool.renderToOutput(output, destDir.getCanonicalPath());
} catch (Exception e) {
e.printStackTrace();
}
// try to override the default stylesheet with custom specified one if needed
if (styleSheetFile != null) {
try {
String css = DefaultGroovyMethods.getText(styleSheetFile);
File outfile = new File(destDir, "stylesheet.css");
DefaultGroovyMethods.setText(outfile, css);
} catch (IOException e) {
System.out.println("Warning: Unable to copy specified stylesheet '" + styleSheetFile.getAbsolutePath() + "'. Using default stylesheet instead. Due to: " + e.getMessage());
}
}
}
Aggregations