From c25fd92e4a8b329d6e917b252869dfc8666418a0 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Wed, 25 Apr 2018 14:18:46 +0100 Subject: [PATCH 1/4] [ML] Include 3rd party C++ component notices 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. --- x-pack/plugin/ml/build.gradle | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/ml/build.gradle b/x-pack/plugin/ml/build.gradle index af2122d43d9a7..75873cc1f855f 100644 --- a/x-pack/plugin/ml/build.gradle +++ b/x-pack/plugin/ml/build.gradle @@ -64,6 +64,20 @@ 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") +} + run { plugin xpackModule('core') } @@ -85,7 +99,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 From e6b73fddc948c64d542c4d554ecc3d20ec6f62c4 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Wed, 25 Apr 2018 16:35:39 +0100 Subject: [PATCH 2/4] Add a sanity check to the tests --- distribution/archives/build.gradle | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/distribution/archives/build.gradle b/distribution/archives/build.gradle index af9d5f362451f..5cfbaf95f09da 100644 --- a/distribution/archives/build.gradle +++ b/distribution/archives/build.gradle @@ -219,6 +219,24 @@ subprojects { } check.dependsOn checkNotice + task checkMlCppNotice { + dependsOn buildDist, checkExtraction + onlyIf toolExists + doLast { + if (project.name == 'zip' || project.name == 'tar') { + // 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 } /***************************************************************************** From 146b09cfb406e20d67793133e0039f7f619dbf53 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Thu, 26 Apr 2018 10:04:41 +0100 Subject: [PATCH 3/4] Avoid empty tasks for OSS and test projects --- distribution/archives/build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/distribution/archives/build.gradle b/distribution/archives/build.gradle index 5cfbaf95f09da..4a228ec61a926 100644 --- a/distribution/archives/build.gradle +++ b/distribution/archives/build.gradle @@ -219,11 +219,11 @@ subprojects { } check.dependsOn checkNotice - task checkMlCppNotice { - dependsOn buildDist, checkExtraction - onlyIf toolExists - doLast { - if (project.name == 'zip' || project.name == 'tar') { + 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") @@ -235,8 +235,8 @@ subprojects { } } } + check.dependsOn checkMlCppNotice } - check.dependsOn checkMlCppNotice } /***************************************************************************** From a2ef1cb28f0800db2c88d2d73f3366cf6952724e Mon Sep 17 00:00:00 2001 From: David Roberts Date: Mon, 30 Apr 2018 10:47:45 +0100 Subject: [PATCH 4/4] generateNotice should not be up-to-date if extractNativeLicenses isn't --- x-pack/plugin/ml/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugin/ml/build.gradle b/x-pack/plugin/ml/build.gradle index 75873cc1f855f..d9d4882b00e1c 100644 --- a/x-pack/plugin/ml/build.gradle +++ b/x-pack/plugin/ml/build.gradle @@ -76,6 +76,9 @@ 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 {