[ML] Include 3rd party C++ component notices (#30132)

The overall NOTICE file for the ML X-Pack module should
include the notices from the 3rd party C++ components as
well as the 3rd party Java components.
This commit is contained in:
David Roberts 2018-04-30 20:05:27 +01:00 committed by GitHub
parent 421bd9bd7a
commit 225f7093a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View File

@ -217,6 +217,24 @@ subprojects {
}
check.dependsOn checkNotice
if (project.name == 'zip' || project.name == 'tar') {
task checkMlCppNotice {
dependsOn buildDist, checkExtraction
onlyIf toolExists
doLast {
// this is just a small sample from the C++ notices, the idea being that if we've added these lines we've probably added all the required lines
final List<String> expectedLines = Arrays.asList("Apache log4cxx", "Boost Software License - Version 1.0 - August 17th, 2003")
final Path noticePath = archiveExtractionDir.toPath().resolve("elasticsearch-${VersionProperties.elasticsearch}/modules/x-pack/x-pack-ml/NOTICE.txt")
final List<String> actualLines = Files.readAllLines(noticePath)
for (final String expectedLine : expectedLines) {
if (actualLines.contains(expectedLine) == false) {
throw new GradleException("expected [${noticePath}] to contain [${expectedLine}] but it did not")
}
}
}
}
check.dependsOn checkMlCppNotice
}
}
/*****************************************************************************

View File

@ -64,6 +64,23 @@ artifacts {
testArtifacts testJar
}
task extractNativeLicenses(type: Copy) {
dependsOn configurations.nativeBundle
into "${buildDir}"
from {
project.zipTree(configurations.nativeBundle.singleFile)
}
include 'platform/licenses/**'
}
project.afterEvaluate {
// Add an extra licenses directory to the combined notices
project.tasks.findByName('generateNotice').dependsOn extractNativeLicenses
project.tasks.findByName('generateNotice').licensesDir new File("${project.buildDir}/platform/licenses")
project.tasks.findByName('generateNotice').outputs.upToDateWhen {
extractNativeLicenses.state.upToDate
}
}
run {
plugin xpackModule('core')
}