diff --git a/distribution/archives/build.gradle b/distribution/archives/build.gradle index f2fc297a9e4c8..9fa06021236a2 100644 --- a/distribution/archives/build.gradle +++ b/distribution/archives/build.gradle @@ -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 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 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 + } } /***************************************************************************** diff --git a/x-pack/plugin/ml/build.gradle b/x-pack/plugin/ml/build.gradle index af2122d43d9a7..d9d4882b00e1c 100644 --- a/x-pack/plugin/ml/build.gradle +++ b/x-pack/plugin/ml/build.gradle @@ -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') } @@ -85,7 +102,7 @@ task internalClusterTest(type: RandomizedTestingTask, include '**/*IT.class' systemProperty 'es.set.netty.runtime.available.processors', 'false' } -check.dependsOn internalClusterTest +check.dependsOn internalClusterTest internalClusterTest.mustRunAfter test // also add an "alias" task to make typing on the command line easier