Skip to content

Commit 225f709

Browse files
authored
[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.
1 parent 421bd9b commit 225f709

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

distribution/archives/build.gradle

+18
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,24 @@ subprojects {
217217
}
218218
check.dependsOn checkNotice
219219

220+
if (project.name == 'zip' || project.name == 'tar') {
221+
task checkMlCppNotice {
222+
dependsOn buildDist, checkExtraction
223+
onlyIf toolExists
224+
doLast {
225+
// 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
226+
final List<String> expectedLines = Arrays.asList("Apache log4cxx", "Boost Software License - Version 1.0 - August 17th, 2003")
227+
final Path noticePath = archiveExtractionDir.toPath().resolve("elasticsearch-${VersionProperties.elasticsearch}/modules/x-pack/x-pack-ml/NOTICE.txt")
228+
final List<String> actualLines = Files.readAllLines(noticePath)
229+
for (final String expectedLine : expectedLines) {
230+
if (actualLines.contains(expectedLine) == false) {
231+
throw new GradleException("expected [${noticePath}] to contain [${expectedLine}] but it did not")
232+
}
233+
}
234+
}
235+
}
236+
check.dependsOn checkMlCppNotice
237+
}
220238
}
221239

222240
/*****************************************************************************

x-pack/plugin/ml/build.gradle

+18-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ artifacts {
6464
testArtifacts testJar
6565
}
6666

67+
task extractNativeLicenses(type: Copy) {
68+
dependsOn configurations.nativeBundle
69+
into "${buildDir}"
70+
from {
71+
project.zipTree(configurations.nativeBundle.singleFile)
72+
}
73+
include 'platform/licenses/**'
74+
}
75+
project.afterEvaluate {
76+
// Add an extra licenses directory to the combined notices
77+
project.tasks.findByName('generateNotice').dependsOn extractNativeLicenses
78+
project.tasks.findByName('generateNotice').licensesDir new File("${project.buildDir}/platform/licenses")
79+
project.tasks.findByName('generateNotice').outputs.upToDateWhen {
80+
extractNativeLicenses.state.upToDate
81+
}
82+
}
83+
6784
run {
6885
plugin xpackModule('core')
6986
}
@@ -85,7 +102,7 @@ task internalClusterTest(type: RandomizedTestingTask,
85102
include '**/*IT.class'
86103
systemProperty 'es.set.netty.runtime.available.processors', 'false'
87104
}
88-
check.dependsOn internalClusterTest
105+
check.dependsOn internalClusterTest
89106
internalClusterTest.mustRunAfter test
90107

91108
// also add an "alias" task to make typing on the command line easier

0 commit comments

Comments
 (0)