You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by vl...@apache.org on 2019/09/30 10:21:34 UTC

[jmeter] branch master updated: Fix license management: use Gradle configurations to pass artifacts across modules

This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git


The following commit(s) were added to refs/heads/master by this push:
     new 2459d6e  Fix license management: use Gradle configurations to pass artifacts across modules
2459d6e is described below

commit 2459d6e1be81eb4a65458ad3883d6858b75ee192
Author: Vladimir Sitnikov <si...@gmail.com>
AuthorDate: Mon Sep 30 13:14:19 2019 +0300

    Fix license management: use Gradle configurations to pass artifacts across modules
    
    Binary license generation was broken in 250ba4c04064f6fa200c4d0f962ad9d694bf38f4
    
    Gradle projects should not use tasks from other modules, however it is convenient to factor
    "license" to its own submodule.
    
    "license" submodule wants to have the list of "binary dependencies", and it provides
    the generated license.
    Both are implemented with Gradle configuration: "license" module consumes project(":src:dist", "runtimeElements")
    and it exposes binLicense and srcLicense configurations that include output files (+dependencies that build them)
---
 src/build.gradle.kts                               | 10 ++-
 src/config/build.gradle.kts                        | 22 ++----
 src/dist/build.gradle.kts                          | 29 +++----
 src/licenses/build.gradle.kts                      | 90 ++++++++++++++--------
 src/licenses/licenses/checker-qual/LICENSE         | 20 +++++
 .../licenses/{dnsjava-2.1.8 => dnsjava}/LICENSE    |  0
 src/licenses/licenses/hamcrest/LICENSE             | 27 +++++++
 src/licenses/licenses/rsyntaxtextarea/LICENSE      | 24 ------
 8 files changed, 124 insertions(+), 98 deletions(-)

diff --git a/src/build.gradle.kts b/src/build.gradle.kts
index 11662be..812e86f 100644
--- a/src/build.gradle.kts
+++ b/src/build.gradle.kts
@@ -41,7 +41,9 @@ subprojects {
     if (groovyUsed) {
         apply<GroovyPlugin>()
     }
-    apply<MavenPublishPlugin>()
+    if (project.path !in skipMavenPublication) {
+        apply<MavenPublishPlugin>()
+    }
     apply<JacocoPlugin>()
 
     dependencies {
@@ -121,13 +123,13 @@ subprojects {
     }
     setProperty("archivesBaseName", archivesBaseName)
 
+    if (project.path in skipMavenPublication) {
+        return@subprojects
+    }
     // See https://stackoverflow.com/a/53661897/1261287
     // Subprojects can't use "publishing" since that accessor is not available at parent project
     // evaluation time
     configure<PublishingExtension> {
-        if (project.path in skipMavenPublication) {
-            return@configure
-        }
         publications {
             create<MavenPublication>(project.name) {
                 artifactId = archivesBaseName
diff --git a/src/config/build.gradle.kts b/src/config/build.gradle.kts
index 845a2fc..5f50626 100644
--- a/src/config/build.gradle.kts
+++ b/src/config/build.gradle.kts
@@ -25,23 +25,11 @@ plugins {
     id("com.github.vlsi.crlf")
 }
 
-// Project :src:license-* might not be evaluated yet, so "renderLicenseFor..." task
-// might not exist yet
-// So we add "evaluationDependsOn"
-evaluationDependsOn(":src:licenses")
+val srcLicense by configurations.creating
 
-// This workarounds https://github.com/gradle/gradle/issues/10008
-// Gradle does not support CopySpec#with(Provider<CopySpec>) yet :(
-fun licenses(licenseType: String) =
-    project(":src:licenses").tasks.named("renderLicenseFor${licenseType.capitalize()}")
-        .let { task ->
-            licensesCopySpec(task) {
-                from(task)
-                from("$rootDir/NOTICE")
-            }
-        }
-
-val sourceLicense = licenses("source")
+dependencies {
+    srcLicense(project(":src:licenses", "srcLicense"))
+}
 
 tasks.named<Jar>(JavaPlugin.JAR_TASK_NAME) {
     into("META-INF") {
@@ -49,7 +37,7 @@ tasks.named<Jar>(JavaPlugin.JAR_TASK_NAME) {
         CrLfSpec(LineEndings.LF).run {
             // Note: license content is taken from "/build/..", so gitignore should not be used
             // Note: this is a "license + third-party licenses", not just Apache-2.0
-            dependencyLicenses(sourceLicense)
+            from(files(srcLicense))
         }
     }
     into("run") {
diff --git a/src/dist/build.gradle.kts b/src/dist/build.gradle.kts
index c9ba111..0502298 100644
--- a/src/dist/build.gradle.kts
+++ b/src/dist/build.gradle.kts
@@ -21,13 +21,12 @@ import com.github.vlsi.gradle.crlf.LineEndings
 import com.github.vlsi.gradle.git.FindGitAttributes
 import com.github.vlsi.gradle.git.dsl.gitignore
 import com.github.vlsi.gradle.release.ReleaseExtension
-import com.github.vlsi.gradle.release.dsl.dependencyLicenses
-import com.github.vlsi.gradle.release.dsl.licensesCopySpec
 import org.gradle.api.internal.TaskOutputsInternal
 
 plugins {
     id("com.github.vlsi.crlf")
     id("com.github.vlsi.stage-vote-release")
+    signing
 }
 
 var jars = arrayOf(
@@ -51,6 +50,8 @@ var jars = arrayOf(
         ":src:protocol:tcp")
 
 val buildDocs by configurations.creating
+val binLicense by configurations.creating
+val srcLicense by configurations.creating
 
 // Note: you can inspect final classpath (list of jars in the binary distribution)  via
 // gw dependencies --configuration runtimeClasspath
@@ -65,6 +66,9 @@ dependencies {
              so the dependency is added for distribution only""".trimIndent())
     }
 
+    binLicense(project(":src:licenses", "binLicense"))
+    srcLicense(project(":src:licenses", "srcLicense"))
+
     buildDocs(platform(project(":src:bom")))
     buildDocs("org.apache.velocity:velocity")
     buildDocs("commons-lang:commons-lang")
@@ -170,21 +174,6 @@ val createDist by tasks.registering {
 // source/binary artifacts with the appropriate eol/executable file flags
 val gitProps by rootProject.tasks.existing(FindGitAttributes::class)
 
-// Project :src:license-* might not be evaluated yet, so "renderLicenseFor..." task
-// might not exist yet
-// So we add "evaluationDependsOn"
-evaluationDependsOn(":src:licenses")
-
-// This workarounds https://github.com/gradle/gradle/issues/10008
-// Gradle does not support CopySpec#with(Provider<CopySpec>) yet :(
-fun licenses(licenseType: String) =
-    licensesCopySpec(
-        project(":src:licenses")
-            .tasks.named("renderLicenseFor${licenseType.capitalize()}"))
-
-val sourceLicense = licenses("source")
-val binaryLicense = licenses("binary")
-
 fun createAnakiaTask(taskName: String,
                      baseDir: String, extension: String = ".html", style: String,
                      velocityProperties: String, projectFile: String, excludes: Array<String>,
@@ -376,7 +365,8 @@ fun CrLfSpec.binaryLayout() = copySpec {
     into(baseFolder) {
         // Note: license content is taken from "/build/..", so gitignore should not be used
         // Note: this is a "license + third-party licenses", not just Apache-2.0
-        dependencyLicenses(binaryLicense)
+        // Note: files(...) adds both "files" and "dependency"
+        from(files(binLicense))
         from(rootDir) {
             gitignore(gitProps)
             exclude("bin/testfiles")
@@ -409,7 +399,8 @@ fun CrLfSpec.sourceLayout() = copySpec {
     into(baseFolder) {
         // Note: license content is taken from "/build/..", so gitignore should not be used
         // Note: this is a "license + third-party licenses", not just Apache-2.0
-        dependencyLicenses(sourceLicense)
+        // Note: files(...) adds both "files" and "dependency"
+        from(files(srcLicense))
         // Include all the source files
         from(rootDir) {
             gitignore(gitProps)
diff --git a/src/licenses/build.gradle.kts b/src/licenses/build.gradle.kts
index 027843d..26631bf 100644
--- a/src/licenses/build.gradle.kts
+++ b/src/licenses/build.gradle.kts
@@ -22,10 +22,8 @@ import com.github.vlsi.gradle.release.Apache2LicenseRenderer
 import com.github.vlsi.gradle.release.ArtifactType
 import com.github.vlsi.gradle.release.AsfLicenseCategory
 import com.github.vlsi.gradle.release.ExtraLicense
-
-plugins {
-    id("com.github.vlsi.stage-vote-release")
-}
+import com.github.vlsi.gradle.release.dsl.dependencyLicenses
+import com.github.vlsi.gradle.release.dsl.licensesCopySpec
 
 // See https://docs.gradle.org/current/userguide/troubleshooting_dependency_resolution.html#sub:configuration_resolution_constraints
 // Gradle forbids to resolve configurations from other projects, so
@@ -34,12 +32,25 @@ plugins {
 // In most cases, the deprecation warning can be fixed by defining a configuration in
 // the project where the resolution is occurring and setting it to extend from the configuration
 // in the other project.
-val binaryDependencies by configurations.creating() {
-    extendsFrom(project(":src:dist").configurations.runtimeClasspath.get())
+
+val binaryDependencies by configurations.creating
+val binLicense by configurations.creating
+val srcLicense by configurations.creating
+
+dependencies {
+    binaryDependencies(project(":src:dist", "runtimeElements"))
 }
 
+fun gradleWrapperVersion(wrapperProps: String) =
+    `java.util`.Properties().run {
+        file(wrapperProps).inputStream().buffered().use { load(it) }
+        getProperty("distributionUrl").replace(Regex(".*gradle-(\\d[^-]+)-.*"), "$1")
+    }
+
 val gatherSourceLicenses by tasks.registering(GatherLicenseTask::class) {
-    addDependency("org.gradle:gradle-wrapper:5.5.1", SpdxLicense.Apache_2_0)
+    val wrapperProps = "$rootDir/gradle/wrapper/gradle-wrapper.properties"
+    inputs.file(wrapperProps)
+    addDependency("org.gradle:gradle-wrapper:${gradleWrapperVersion(wrapperProps)}", SpdxLicense.Apache_2_0)
     addDependency(":bootstrap:3.3.4", SpdxLicense.MIT)
     addDependency(":bootstrap-social:4.8.0", SpdxLicense.MIT)
     addDependency(":datatables:1.10.9", SpdxLicense.MIT)
@@ -79,17 +90,7 @@ val gatherBinaryLicenses by tasks.registering(GatherLicenseTask::class) {
     overrideLicense("com.github.bulenkov.darcula:darcula:e208efb96f70e4be9dc362fbb46f6e181ef501dd", SpdxLicense.Apache_2_0)
 
     overrideLicense("dnsjava:dnsjava:2.1.9") {
-        expectedLicense = SimpleLicense("BSD", uri("https://github.com/dnsjava/dnsjava/blob/master/LICENSE"))
-        effectiveLicense = SpdxLicense.BSD_2_Clause
-    }
-
-    overrideLicense("com.fifesoft:rsyntaxtextarea:3.0.4") {
-        // https://github.com/bobbylight/RSyntaxTextArea/issues/299
-        expectedLicense = SimpleLicense(
-            "Modified BSD License",
-            uri("https://github.com/bobbylight/RSyntaxTextArea/blob/master/RSyntaxTextArea/src/main/resources/META-INF/LICENSE")
-        )
-        effectiveLicense = SpdxLicense.BSD_3_Clause
+        expectedLicense = SpdxLicense.BSD_2_Clause
     }
 
     overrideLicense("com.thoughtworks.xstream:xstream:1.4.11") {
@@ -126,29 +127,19 @@ val gatherBinaryLicenses by tasks.registering(GatherLicenseTask::class) {
         expectedLicense = SpdxLicense.MIT
     }
 
-    overrideLicense("org.jsoup:jsoup:1.12.1") {
-        expectedLicense = SimpleLicense("MIT", uri("https://github.com/jhy/jsoup/blob/master/LICENSE"))
-        effectiveLicense = SpdxLicense.MIT
-    }
-
     overrideLicense("org.slf4j:jcl-over-slf4j:1.7.28") {
         expectedLicense = SpdxLicense.MIT
         // See https://github.com/qos-ch/slf4j/blob/v_1.7.28/jcl-over-slf4j/LICENSE.txt
         effectiveLicense = SpdxLicense.Apache_2_0
     }
 
-    overrideLicense("org.slf4j:slf4j-api:1.7.25") {
+    overrideLicense("org.slf4j:slf4j-api:1.7.28") {
         expectedLicense = SpdxLicense.MIT
     }
 
     overrideLicense("net.sf.saxon:Saxon-HE:9.9.1-5") {
         expectedLicense = SpdxLicense.MPL_2_0
     }
-    
-    overrideLicense("org.mozilla:rhino:1.7.11") {
-        expectedLicense = SimpleLicense("MPL", uri("https://github.com/mozilla/rhino/blob/master/LICENSE.txt"))
-        effectiveLicense = SpdxLicense.MPL_2_0
-    }
 
     overrideLicense("com.sun.mail:all:1.5.0-b01") {
         // Multiple licenses, specify explicitly
@@ -164,11 +155,13 @@ val gatherBinaryLicenses by tasks.registering(GatherLicenseTask::class) {
         expectedLicense = SpdxLicense.Apache_2_0 and SpdxLicense.SAX_PD and SimpleLicense("The W3C License", uri("http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/java-binding.zip"))
         effectiveLicense = SpdxLicense.Apache_2_0
     }
-    overrideLicense("org.hamcrest:hamcrest-core:1.3") {
-        // https://github.com/hamcrest/JavaHamcrest/issues/264
-        // pom.xml lists "New BSD License", however it is BSD_3
-        expectedLicense = SimpleLicense("New BSD License", uri("http://www.opensource.org/licenses/bsd-license.php"))
-        effectiveLicense = SpdxLicense.BSD_3_Clause
+    for (lib in listOf("hamcrest-core", "hamcrest")) {
+        overrideLicense("org.hamcrest:$lib:2.1") {
+            // https://github.com/hamcrest/JavaHamcrest/issues/264
+            // pom.xml lists "New BSD License", however it is BSD_3
+            expectedLicense = SpdxLicense.BSD_3_Clause
+            licenseFiles = "hamcrest"
+        }
     }
     overrideLicense("org.exparity:hamcrest-date:2.0.4") {
         // https://github.com/eXparity/hamcrest-date/issues/26
@@ -180,6 +173,10 @@ val gatherBinaryLicenses by tasks.registering(GatherLicenseTask::class) {
         expectedLicense = SimpleLicense("Java HTML Tidy License", uri("http://jtidy.svn.sourceforge.net/viewvc/jtidy/trunk/jtidy/LICENSE.txt?revision=95"))
         effectiveLicense = SpdxLicense.BSD_3_Clause
     }
+    // https://github.com/typetools/checker-framework/issues/2798
+    overrideLicense("org.checkerframework:checker-qual:2.10.0") {
+        expectedLicense = SpdxLicense.MIT
+    }
 }
 
 val renderLicenseForSource by tasks.registering(Apache2LicenseRenderer::class) {
@@ -203,3 +200,28 @@ val renderLicenseForBinary by tasks.registering(Apache2LicenseRenderer::class) {
 tasks.build.configure {
   dependsOn(renderLicenseForSource, renderLicenseForBinary)
 }
+
+// Below is to populate configurations with licenses
+// Note: configuration artifacts consist of files and directories
+// Here directories are used because it simplifies the use (the use site does not have to unzip)
+val binLicenseSpec = licensesCopySpec(renderLicenseForBinary)
+val srcLicenseSpec = licensesCopySpec(renderLicenseForSource)
+
+val binLicenseDir by tasks.registering(Sync::class) {
+    into("$buildDir/$name")
+    dependencyLicenses(binLicenseSpec)
+}
+
+val srcLicenseDir by tasks.registering(Sync::class) {
+    into("$buildDir/$name")
+    dependencyLicenses(srcLicenseSpec)
+}
+
+artifacts {
+    add(binLicense.name, binLicenseDir.get().destinationDir) {
+        builtBy(binLicenseDir)
+    }
+    add(srcLicense.name, srcLicenseDir.get().destinationDir) {
+        builtBy(srcLicenseDir)
+    }
+}
diff --git a/src/licenses/licenses/checker-qual/LICENSE b/src/licenses/licenses/checker-qual/LICENSE
new file mode 100644
index 0000000..5a4b90e
--- /dev/null
+++ b/src/licenses/licenses/checker-qual/LICENSE
@@ -0,0 +1,20 @@
+The Checker Framework
+Copyright 2004-present by the Checker Framework developers
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/src/licenses/licenses/dnsjava-2.1.8/LICENSE b/src/licenses/licenses/dnsjava/LICENSE
similarity index 100%
rename from src/licenses/licenses/dnsjava-2.1.8/LICENSE
rename to src/licenses/licenses/dnsjava/LICENSE
diff --git a/src/licenses/licenses/hamcrest/LICENSE b/src/licenses/licenses/hamcrest/LICENSE
new file mode 100644
index 0000000..4933bda
--- /dev/null
+++ b/src/licenses/licenses/hamcrest/LICENSE
@@ -0,0 +1,27 @@
+BSD License
+
+Copyright (c) 2000-2015 www.hamcrest.org
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of
+conditions and the following disclaimer. Redistributions in binary form must reproduce
+the above copyright notice, this list of conditions and the following disclaimer in
+the documentation and/or other materials provided with the distribution.
+
+Neither the name of Hamcrest nor the names of its contributors may be used to endorse
+or promote products derived from this software without specific prior written
+permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
+WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGE.
diff --git a/src/licenses/licenses/rsyntaxtextarea/LICENSE b/src/licenses/licenses/rsyntaxtextarea/LICENSE
deleted file mode 100644
index 3a6e638..0000000
--- a/src/licenses/licenses/rsyntaxtextarea/LICENSE
+++ /dev/null
@@ -1,24 +0,0 @@
-Copyright (c) 2012, Robert Futrell
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-    * Neither the name of the author nor the names of its contributors may
-      be used to endorse or promote products derived from this software
-      without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.