Search in sources :

Example 16 with BuildException

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;
}
Also used : InterpolatedProperties(org.apache.lucene.dependencies.InterpolatedProperties) InputStreamReader(java.io.InputStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Reader(java.io.Reader) XMLReader(org.xml.sax.XMLReader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) FileInputStream(java.io.FileInputStream)

Example 17 with BuildException

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);
    }
}
Also used : NoConflictManager(org.apache.ivy.plugins.conflict.NoConflictManager) IvySettings(org.apache.ivy.core.settings.IvySettings) BuildException(org.apache.tools.ant.BuildException) ParseException(java.text.ParseException) SAXException(org.xml.sax.SAXException) TransformerException(javax.xml.transform.TransformerException) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 18 with BuildException

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();
}
Also used : Transformer(javax.xml.transform.Transformer) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) StreamSource(javax.xml.transform.stream.StreamSource) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) FileInputStream(java.io.FileInputStream) TransformerException(javax.xml.transform.TransformerException)

Example 19 with BuildException

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);
        }
    }
}
Also used : InterpolatedProperties(org.apache.lucene.dependencies.InterpolatedProperties) InputStreamReader(java.io.InputStreamReader) Matcher(java.util.regex.Matcher) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Reader(java.io.Reader) XMLReader(org.xml.sax.XMLReader) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) FileInputStream(java.io.FileInputStream)

Example 20 with BuildException

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());
        }
    }
}
Also used : Path(org.apache.tools.ant.types.Path) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException) File(java.io.File) BuildException(org.apache.tools.ant.BuildException) IOException(java.io.IOException)

Aggregations

BuildException (org.apache.tools.ant.BuildException)930 IOException (java.io.IOException)390 File (java.io.File)365 DirectoryScanner (org.apache.tools.ant.DirectoryScanner)75 ArrayList (java.util.ArrayList)65 InputStream (java.io.InputStream)62 Project (org.apache.tools.ant.Project)61 Resource (org.apache.tools.ant.types.Resource)58 FileSet (org.apache.tools.ant.types.FileSet)52 Path (org.apache.tools.ant.types.Path)52 Commandline (org.apache.tools.ant.types.Commandline)51 Properties (java.util.Properties)50 OutputStream (java.io.OutputStream)44 FileOutputStream (java.io.FileOutputStream)42 FileResource (org.apache.tools.ant.types.resources.FileResource)42 FileInputStream (java.io.FileInputStream)41 URL (java.net.URL)40 BufferedReader (java.io.BufferedReader)37 Writer (java.io.Writer)37 MalformedURLException (java.net.MalformedURLException)37