forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
785 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
isDistributedArtifact=false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
isDistributedArtifact=true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
isDistributedArtifact=false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
include ':logstash-core', 'logstash-core-benchmarks', 'ingest-converter', 'benchmark-cli', 'logstash-integration-tests' | ||
include ':logstash-core', 'logstash-core-benchmarks', 'ingest-converter', 'benchmark-cli', 'logstash-integration-tests', 'dependencies-report' | ||
project(':logstash-core').projectDir = new File('./logstash-core') | ||
project(':logstash-core-benchmarks').projectDir = new File('./logstash-core/benchmarks') | ||
project(':logstash-integration-tests').projectDir = new File('./qa/integration') | ||
project(':ingest-converter').projectDir = new File('./tools/ingest-converter') | ||
project(':benchmark-cli').projectDir = new File('./tools/benchmark-cli') | ||
project(':dependencies-report').projectDir = new File('./tools/dependencies-report') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
isDistributedArtifact=false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import org.yaml.snakeyaml.Yaml | ||
|
||
// fetch version from Logstash's master versions.yml file | ||
def versionMap = (Map) (new Yaml()).load(new File("$projectDir/../../versions.yml").text) | ||
|
||
description = """Logstash Dependency Reporting Utility""" | ||
version = versionMap['logstash-core'] | ||
String jacksonVersion = versionMap['jackson'] | ||
|
||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
} | ||
|
||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath 'org.yaml:snakeyaml:1.17' | ||
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4' | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'commons-io:commons-io:2.6' | ||
compile 'org.apache.commons:commons-csv:1.5' | ||
compile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}" | ||
compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" | ||
compile "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}" | ||
testCompile 'junit:junit:4.12' | ||
} | ||
|
||
javadoc { | ||
enabled = false | ||
} | ||
|
||
test { | ||
// We need to force IPV4 usage to make WireMock tests portable between *nix and Windows. | ||
// For details see: https://github.com/elastic/logstash/pull/8372 | ||
jvmArgs '-Djava.net.preferIPv4Stack=true' | ||
} | ||
|
||
apply plugin: 'com.github.johnrengelman.shadow' | ||
|
||
shadowJar { | ||
baseName = 'dependencies-report' | ||
classifier = null | ||
version = null | ||
} | ||
|
||
assemble.dependsOn shadowJar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
isDistributedArtifact=false | ||
|
81 changes: 81 additions & 0 deletions
81
tools/dependencies-report/src/main/java/org/logstash/dependencies/Dependency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package org.logstash.dependencies; | ||
|
||
import org.apache.commons.csv.CSVRecord; | ||
|
||
import java.util.Objects; | ||
|
||
class Dependency implements Comparable<Dependency> { | ||
public static final String RUBY_TYPE = "ruby"; | ||
public static final String JAVA_TYPE = "java"; | ||
|
||
String type; | ||
String name; | ||
String version; | ||
String license; | ||
String spdxLicense; | ||
|
||
// optional | ||
String licenseUrl; | ||
|
||
public static Dependency fromRubyCsvRecord(CSVRecord record) { | ||
Dependency d = new Dependency(); | ||
|
||
// name, version, url, license | ||
d.type = RUBY_TYPE; | ||
d.name = record.get(0); | ||
d.version = record.get(1); | ||
d.license = record.get(3); | ||
|
||
return d; | ||
} | ||
|
||
public static Dependency fromJavaCsvRecord(CSVRecord record) { | ||
Dependency d = new Dependency(); | ||
|
||
// artifact,moduleUrl,moduleLicense,moduleLicenseUrl | ||
d.type = JAVA_TYPE; | ||
|
||
String nameAndVersion = record.get(0); | ||
int colonIndex = nameAndVersion.indexOf(':'); | ||
if (colonIndex == -1) { | ||
String err = String.format("Could not parse java artifact name and version from '%s'", | ||
nameAndVersion); | ||
throw new IllegalStateException(err); | ||
} | ||
colonIndex = nameAndVersion.indexOf(':', colonIndex + 1); | ||
if (colonIndex == -1) { | ||
String err = String.format("Could not parse java artifact name and version from '%s'", | ||
nameAndVersion); | ||
throw new IllegalStateException(err); | ||
} | ||
d.name = nameAndVersion.substring(0, colonIndex); | ||
d.version = nameAndVersion.substring(colonIndex + 1); | ||
|
||
// We DON'T read the license info out of this CSV because it is not reliable, we want humans | ||
// to use the overrides to ensure our license info is accurate | ||
|
||
return d; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
Dependency d = (Dependency) o; | ||
return Objects.equals(name, d.name) && Objects.equals(version, d.version); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, version); | ||
} | ||
|
||
@Override | ||
public int compareTo(Dependency o) { | ||
return (name + version).compareTo(o.name + o.version); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
tools/dependencies-report/src/main/java/org/logstash/dependencies/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.logstash.dependencies; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
|
||
/** | ||
* Entry point for {@link ReportGenerator}. | ||
*/ | ||
public class Main { | ||
|
||
static final String LICENSE_MAPPING_PATH = "/licenseMapping.csv"; | ||
static final String ACCEPTABLE_LICENSES_PATH = "/acceptableLicenses.csv"; | ||
|
||
public static void main(String[] args) throws IOException { | ||
if (args.length < 3) { | ||
System.out.println("Usage: org.logstash.dependencies.Main <pathToRubyDependencies.csv> <pathToJavaLicenseReportFolders.txt> <output.csv>"); | ||
System.exit(1); | ||
} | ||
|
||
InputStream rubyDependenciesStream = new FileInputStream(args[0]); | ||
List<String> javaDependencyReports = Files.readAllLines(Paths.get(args[1])); | ||
InputStream[] javaDependenciesStreams = new InputStream[javaDependencyReports.size()]; | ||
for (int k = 0; k < javaDependencyReports.size(); k++) { | ||
javaDependenciesStreams[k] = new FileInputStream(javaDependencyReports.get(k) + "/licenses.csv"); | ||
} | ||
FileWriter outputWriter = new FileWriter(args[2]); | ||
|
||
boolean reportResult = new ReportGenerator().generateReport( | ||
getResourceAsStream(LICENSE_MAPPING_PATH), | ||
getResourceAsStream(ACCEPTABLE_LICENSES_PATH), | ||
rubyDependenciesStream, | ||
javaDependenciesStreams, | ||
outputWriter | ||
); | ||
|
||
// If there were unknown results in the report, exit with a non-zero status | ||
System.exit(reportResult ? 0 : 1); | ||
|
||
} | ||
|
||
static InputStream getResourceAsStream(String resourcePath) { | ||
return ReportGenerator.class.getResourceAsStream(resourcePath); | ||
} | ||
} |
Oops, something went wrong.