Skip to content

Commit 5232429

Browse files
committed
[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 60f6c20 commit 5232429

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

distribution/archives/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,24 @@ subprojects {
219219
}
220220
check.dependsOn checkNotice
221221

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

224242
/*****************************************************************************

x-pack/plugin/ml/build.gradle

Lines changed: 18 additions & 1 deletion
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)