Search in sources :

Example 1 with InterpolatedProperties

use of org.apache.lucene.dependencies.InterpolatedProperties 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 2 with InterpolatedProperties

use of org.apache.lucene.dependencies.InterpolatedProperties 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)

Aggregations

BufferedReader (java.io.BufferedReader)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 InterpolatedProperties (org.apache.lucene.dependencies.InterpolatedProperties)2 BuildException (org.apache.tools.ant.BuildException)2 XMLReader (org.xml.sax.XMLReader)2 Matcher (java.util.regex.Matcher)1