diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 03b8546a5..6111ec16e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -20,6 +20,9 @@ dependencies { implementation("com.gradle.develocity:com.gradle.develocity.gradle.plugin:4.2.2") implementation("me.champeau.gradle.japicmp:me.champeau.gradle.japicmp.gradle.plugin:0.4.6") implementation("com.google.auto.value:auto-value-annotations:1.11.1") + implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.2.2") + implementation("com.github.jk1.dependency-license-report:com.github.jk1.dependency-license-report.gradle.plugin:3.0.1") + implementation("org.cyclonedx.bom:org.cyclonedx.bom.gradle.plugin:3.1.0") } spotless { diff --git a/buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts b/buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts index abacafd36..8477f3825 100644 --- a/buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/otel.java-conventions.gradle.kts @@ -31,6 +31,12 @@ java { withSourcesJar() } +tasks.named("jar") { + from(rootProject.file("LICENSE")) { + into("META-INF") + } +} + tasks { withType().configureEach { with(options) { diff --git a/buildSrc/src/main/kotlin/otel.shadow-conventions.gradle.kts b/buildSrc/src/main/kotlin/otel.shadow-conventions.gradle.kts new file mode 100644 index 000000000..3b7153037 --- /dev/null +++ b/buildSrc/src/main/kotlin/otel.shadow-conventions.gradle.kts @@ -0,0 +1,97 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import com.github.jk1.license.filter.LicenseBundleNormalizer +import com.github.jk1.license.render.ReportRenderer +import com.github.jk1.license.render.TextReportRenderer +import com.github.jk1.license.task.CheckLicensePreparationTask +import com.github.jk1.license.task.CheckLicenseTask +import com.github.jk1.license.task.ReportTask + +plugins { + id("com.gradleup.shadow") + id("org.cyclonedx.bom") + id("com.github.jk1.dependency-license-report") +} + +// Temporary workaround until the license plugin supports configuration cache +tasks.withType().configureEach { + notCompatibleWithConfigurationCache("Unsupported") +} +tasks.withType().configureEach { + notCompatibleWithConfigurationCache("Unsupported") +} +tasks.withType().configureEach { + notCompatibleWithConfigurationCache("Unsupported") +} + +licenseReport { + allowedLicensesFile = file(rootProject.file("config/dependency-license/allowed-licenses.json")) + excludes = arrayOf("opentelemetry-java-contrib:dependencyManagement") + filters = arrayOf( + LicenseBundleNormalizer( + rootProject.file("config/dependency-license/license-normalizer-bundle.json").absolutePath, + false + ) + ) + renderers = arrayOf( + TextReportRenderer() + ) +} + +tasks.cyclonedxDirectBom { + xmlOutput.unsetConvention() +} + +val copyLegalDocs = tasks.register("copyLegalDocs") { + group = "documentation" + description = "Copies legal files and generated checkLicense/SBOM reports into resources." + + from(layout.buildDirectory.file("reports/dependency-license/THIRD-PARTY-NOTICES.txt")) + from(layout.buildDirectory.file("reports/cyclonedx-direct/bom.json")) + + into(layout.buildDirectory.dir("generated/legal-docs")) + + rename("bom.json", "SBOM.json") +} + +copyLegalDocs.configure { + tasks.findByName("cyclonedxDirectBom")?.let { dependsOn(it) } + tasks.findByName("checkLicense")?.let { dependsOn(it) } +} + +tasks.named("shadowJar") { + dependsOn(copyLegalDocs) + + transform() + + manifest { + attributes["Implementation-Version"] = project.version + } + + // Prevent dependency-provided LICENSE/NOTICE files from being copied into the + // distribution (they often duplicate or conflict). We still include the + // project"s own `LICENSE` explicitly below. + exclude( + "DISCLAIMER", + "license.header", + "licenses/**", + "META-INF/DEPENDENCIES", + "META-INF/NOTICE.md", + "META-INF/NOTICE", + "META-INF/NOTICE.md", + "META-INF/licenses/**", + "META-INF/LICENSE*", + "**/NOTICE*" + ) + + from(layout.buildDirectory.dir("generated/legal-docs")) { + into("META-INF/licenses") + } + + from(rootProject.file("LICENSE")) { + into("META-INF") + } +} + +tasks.named("assemble") { + dependsOn("shadowJar") +} diff --git a/cel-sampler/README.md b/cel-sampler/README.md index 62f1ed5b1..0db7571e6 100644 --- a/cel-sampler/README.md +++ b/cel-sampler/README.md @@ -6,7 +6,7 @@ The `CelBasedSampler` supports [declarative configuration](https://opentelemetry To use: -* Add a dependency on `io.opentelemetry.contrib:opentelemetry-cel-sampler:` +* Add a dependency on `io.opentelemetry.contrib:opentelemetry-cel-sampler-dist:` * See the [extension documentation](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/examples/extension/README.md#build-and-add-extensions) for how to add extensions when using the java agent. * Follow the [instructions](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/incubator/README.md#declarative-configuration) to configure OpenTelemetry with declarative configuration. * Configure the `.tracer_provider.sampler` to include the `cel_based` sampler. diff --git a/cel-sampler/build.gradle.kts b/cel-sampler/build.gradle.kts index bff7292da..3575eafcc 100644 --- a/cel-sampler/build.gradle.kts +++ b/cel-sampler/build.gradle.kts @@ -1,5 +1,8 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + plugins { id("otel.java-conventions") + id("otel.shadow-conventions") id("otel.publish-conventions") } @@ -18,3 +21,7 @@ dependencies { testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure") testImplementation("io.opentelemetry:opentelemetry-sdk-extension-incubator") } + +tasks.named("shadowJar") { + archiveClassifier.set("dist") +} diff --git a/config/dependency-license/allowed-licenses.json b/config/dependency-license/allowed-licenses.json new file mode 100644 index 000000000..e2f80d262 --- /dev/null +++ b/config/dependency-license/allowed-licenses.json @@ -0,0 +1,38 @@ +{ + "allowedLicenses": [ + { + "moduleLicense": "Apache License, Version 2.0" + }, + { + "moduleLicense": "Bouncy Castle Licence" + }, + { + "moduleLicense": "The 3-Clause BSD License" + }, + { + "moduleLicense": "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0" + }, + { + "moduleLicense": "GNU LESSER GENERAL PUBLIC LICENSE, Version 3" + }, + { + "moduleLicense": "GNU Lesser General Public License Version 3 or greater" + }, + { + "moduleLicense": "Go License" + }, + { + "moduleLicense": "MIT License" + }, + { + "moduleLicense": "PUBLIC DOMAIN" + }, + { + "moduleVersion": "1.0", + "moduleName": "net.jcip:jcip-annotations" + }, + { + "moduleName": "opentelemetry-java-contrib:dependencyManagement" + } + ] +} diff --git a/config/dependency-license/license-normalizer-bundle.json b/config/dependency-license/license-normalizer-bundle.json new file mode 100644 index 000000000..e9e75e2e8 --- /dev/null +++ b/config/dependency-license/license-normalizer-bundle.json @@ -0,0 +1,96 @@ +{ + "bundles" : [ + { "bundleName" : "Apache-1.1", "licenseName" : "Apache Software License, Version 1.1", "licenseUrl" : "https://www.apache.org/licenses/LICENSE-1.1" }, + { "bundleName" : "Apache-2.0", "licenseName" : "Apache License, Version 2.0", "licenseUrl" : "https://www.apache.org/licenses/LICENSE-2.0" }, + { "bundleName" : "0BSD", "licenseName" : "BSD Zero Clause License", "licenseUrl" : "https://opensource.org/licenses/0BSD" }, + { "bundleName" : "BSD-2-Clause", "licenseName" : "The 2-Clause BSD License", "licenseUrl" : "https://opensource.org/licenses/BSD-2-Clause" }, + { "bundleName" : "BSD-3-Clause", "licenseName" : "The 3-Clause BSD License", "licenseUrl" : "https://opensource.org/licenses/BSD-3-Clause" }, + { "bundleName" : "CC0-1.0", "licenseName" : "Creative Commons Legal Code", "licenseUrl" : "https://creativecommons.org/publicdomain/zero/1.0/legalcode" }, + { "bundleName" : "CC-BY-2.5", "licenseName": "Creative Commons Attribution Non Commercial 2.5 Generic", "licenseUrl": "https://creativecommons.org/licenses/by/2.5" }, + { "bundleName" : "CDDL-1.0", "licenseName" : "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0", "licenseUrl" : "https://oss.oracle.com/licenses/CDDL" }, + { "bundleName" : "CDDL-1.1", "licenseName" : "COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1", "licenseUrl" : "https://oss.oracle.com/licenses/CDDL-1.1" }, + { "bundleName" : "CPL-1.0", "licenseName" : "Common Public License - v 1.0", "licenseUrl" : "https://www.eclipse.org/legal/cpl-v10.html" }, + { "bundleName" : "EPL-1.0", "licenseName" : "Eclipse Public License - v 1.0", "licenseUrl" : "http://www.eclipse.org/legal/epl-v10.html" }, + { "bundleName" : "EPL-2.0", "licenseName" : "Eclipse Public License - v 2.0", "licenseUrl" : "https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt" }, + { "bundleName" : "EDL-1.0", "licenseName" : "Eclipse Distribution License - v 1.0", "licenseUrl" : "https://www.eclipse.org/org/documents/edl-v10.html" }, + { "bundleName" : "Go", "licenseName" : "Go License", "licenseUrl": "https://golang.org/LICENSE" }, + { "bundleName" : "GPL-1.0", "licenseName" : "GNU GENERAL PUBLIC LICENSE, Version 1", "licenseUrl" : "https://www.gnu.org/licenses/gpl-1.0" }, + { "bundleName" : "GPL-2.0-only", "licenseName" : "GNU GENERAL PUBLIC LICENSE, Version 2", "licenseUrl" : "https://www.gnu.org/licenses/gpl-2.0" }, + { "bundleName" : "GPL-3.0-only", "licenseName" : "GNU GENERAL PUBLIC LICENSE, Version 3", "licenseUrl" : "https://www.gnu.org/licenses/gpl-3.0" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseName" : "GNU GENERAL PUBLIC LICENSE, Version 2 + Classpath Exception", "licenseUrl" : "https://openjdk.java.net/legal/gplv2+ce.html" }, + { "bundleName" : "LGPL-2.1-only", "licenseName" : "GNU LESSER GENERAL PUBLIC LICENSE, Version 2.1", "licenseUrl" : "https://www.gnu.org/licenses/lgpl-2.1" }, + { "bundleName" : "LGPL-3.0-only", "licenseName" : "GNU LESSER GENERAL PUBLIC LICENSE, Version 3", "licenseUrl" : "https://www.gnu.org/licenses/lgpl-3.0" }, + { "bundleName" : "LGPL-3.0-or-greater", "licenseName" : "GNU Lesser General Public License Version 3 or greater", "licenseUrl": "http://www.gnu.org/licenses/lgpl.html" }, + { "bundleName" : "MIT", "licenseName" : "MIT License", "licenseUrl" : "https://opensource.org/licenses/MIT" }, + { "bundleName" : "MPL-1.1", "licenseName" : "Mozilla Public License Version 1.1", "licenseUrl" : "https://www.mozilla.org/en-US/MPL/1.1" }, + { "bundleName" : "MPL-2.0", "licenseName" : "Mozilla Public License, Version 2.0", "licenseUrl" : "https://www.mozilla.org/en-US/MPL/2.0" }, + { "bundleName" : "Public-Domain", "licenseName" : "PUBLIC DOMAIN", "licenseUrl" : "" } + ], + "transformationRules" : [ + { "bundleName" : "0BSD", "licenseNamePattern" : "BSD Zero Clause License" }, + { "bundleName" : "0BSD", "licenseNamePattern" : "BSD$" }, + { "bundleName" : "0BSD", "licenseNamePattern" : "BSD( |-)clause.*" }, + { "bundleName" : "0BSD", "licenseNamePattern" : "BSD( |-)license.*" }, + { "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*The Apache Software License, Version 2\\.0.*" }, + { "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*?Apache( |-|_)2.*" }, + { "bundleName" : "Apache-2.0", "licenseNamePattern" : "ASL 2\\.0" }, + { "bundleName" : "Apache-2.0", "licenseNamePattern" : ".*Apache License,?( Version)? 2.*" }, + { "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/Apache-2\\.0.*" }, + { "bundleName" : "Apache-2.0", "licenseUrlPattern" : ".*www\\.apache\\.org/licenses/LICENSE-2\\.0.*" }, + { "bundleName" : "Apache-2.0", "modulePattern": "opentelemetry-java-contrib:dependencyManagement" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*www\\.gnu\\.org/licenses/old-licenses/lgpl-2\\.1\\.html" }, + { "bundleName" : "Apache-2.0", "licenseFileContentPattern" : ".*Apache License,?( Version)? 2.*" }, + { "bundleName" : "Apache-1.1", "licenseFileContentPattern" : ".*Apache Software License, Version 1\\.1.*" }, + { "bundleName" : "CC0-1.0", "licenseNamePattern" : "CC0(( |-)1(\\.0)?)?" }, + { "bundleName" : "CC0-1.0", "licenseUrlPattern" : ".*(www\\.)?creativecommons\\.org/publicdomain/zero/1\\.0/" }, + { "bundleName" : "CDDL-1.0", "licenseFileContentPattern" : ".*CDDL.*1\\.0" }, + { "bundleName" : "CDDL-1.0", "licenseUrlPattern" : ".*CDDL.*.?1\\.0" }, + { "bundleName" : "CDDL-1.1", "licenseUrlPattern" : ".*CDDL.*.?1\\.1" }, + { "bundleName" : "CDDL-1.0", "licenseNamePattern" : "Common Development and Distribution License( \\(CDDL\\),?)? (version )?(.?\\s?)?1\\.0" }, + { "bundleName" : "CDDL-1.1", "licenseNamePattern" : "Common Development and Distribution License( \\(CDDL\\),?)? (version )?(.?\\s?)?1\\.1" }, + { "bundleName" : "BSD-3-Clause", "licenseNamePattern" : ".*BSD( |-)3-clause.*" }, + { "bundleName" : "BSD-3-Clause", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/BSD-3-Clause" }, + { "bundleName" : "BSD-3-Clause", "licenseNamePattern" : ".*?(The )New BSD License.*" }, + { "bundleName" : "BSD-3-Clause", "licenseNamePattern" : ".*?Modified BSD License.*" }, + { "bundleName" : "BSD-2-Clause", "licenseNamePattern" : "BSD( |-)2-clause.*" }, + { "bundleName" : "BSD-2-Clause", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/BSD-2-Clause" }, + { "bundleName" : "BSD-2-Clause", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/bsd-license(\\.php)?" }, + { "bundleName" : "CDDL-1.0", "licenseNamePattern" : "Common Development and Distribution( License)?" }, + { "bundleName" : "CDDL-1.0", "licenseNamePattern" : "CDDL 1(\\.0)" }, + { "bundleName" : "CDDL-1.1", "licenseNamePattern" : "CDDL 1\\.1" }, + { "bundleName" : "CDDL-1.1", "licenseUrlPattern" : ".*(www\\.).opensource\\.org/licenses/CDDL-1\\.0" }, + { "bundleName" : "EPL-1.0", "licenseNamePattern" : "Eclipse Publish License.*(v|version)\\.?\\s?1(\\.?0)?" }, + { "bundleName" : "EPL-1.0", "licenseNamePattern" : "Eclipse Public License.*(v|version)\\.?\\s?1(\\.?0)?" }, + { "bundleName" : "EPL-2.0", "licenseNamePattern" : "Eclipse Public License.*(v|version)\\.?\\s?2(\\.?0)?" }, + { "bundleName" : "EPL-2.0", "licenseUrlPattern" : ".*(www\\.).opensource\\.org/licenses/EPL-2\\.0" }, + { "bundleName" : "EPL-2.0", "licenseUrlPattern" : ".*http.?://www\\.eclipse\\.org/legal/epl-.?2\\.?0.*" }, + { "bundleName" : "EPL-2.0", "licenseUrlPattern" : ".*http.?://www\\.eclipse\\.org/org.*/epl-.?2\\.?0.*" }, + { "bundleName" : "EPL-2.0", "licenseUrlPattern" : ".*http.?://projects\\.eclipse\\.org/.*/epl-.?2\\.?0.*" }, + { "bundleName" : "EDL-1.0", "licenseNamePattern" : "Eclipse Distribution License.*(v|version)\\.?\\s?1(\\.0)?" }, + { "bundleName" : "EDL-1.0", "licenseUrlPattern" : ".*http.?://(www\\.)?eclipse\\.org/org.*/edl-.?1\\.?0.*" }, + { "bundleName" : "Go", "licenseUrlPattern" : "https?://golang.org/LICENSE" }, + { "bundleName" : "GPL-2.0-only", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/GPL-2\\.0" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseNamePattern" : "GNU General Public License, version 2.*classpath exception" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseNamePattern" : "GNU General Public License, version 2.*cp?e" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseNamePattern" : "GNU General Public License, version 2.*, with the classpath exception" }, + { "bundleName" : "GPL-2.0 WITH Classpath-exception-2.0", "licenseNamePattern" : "GPL2 w/ CPE" }, + { "bundleName" : "GPL-3.0-only", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/GPL-3\\.0" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/LGPL-2\\.1" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*(www\\.)?gnu\\.org/licenses(/old-licenses)?/lgpl-2\\.1(\\.(html|txt))?" }, + { "bundleName" : "LGPL-2.1-only", "licenseNamePattern" : "LGPL 2\\.1" }, + { "bundleName" : "LGPL-2.1-only", "licenseNamePattern" : "LGPL.*(v|version)\\.?\\s?2\\.1" }, + { "bundleName" : "LGPL-2.1-only", "licenseUrlPattern" : ".*(www\\.)?repository.jboss.org/licenses/lgpl-2.1\\.txt" }, + { "bundleName" : "LGPL-3.0-only", "licenseUrlPattern" : ".*(www\\.).opensource\\.org/licenses/LGPL-3\\.0" }, + { "bundleName" : "LGPL-3.0-only", "licenseNamePattern" : "lgplv?3" }, + { "bundleName" : "LGPL-3.0-only", "licenseUrlPattern" : ".*(www\\.)?gnu\\.org/licenses(/old-licenses)?/lgpl(-3)?(\\.(html|txt))?" }, + { "bundleName" : "MIT", "licenseNamePattern" : "Bouncy Castle Licence" }, + { "bundleName" : "MIT", "licenseNamePattern" : "(The\\s)?MIT(\\slicen(c|s)e)?(\\s\\(MIT\\))?" }, + { "bundleName" : "MIT", "licenseUrlPattern" : ".*(www\\.)?opensource\\.org/licenses/MIT(\\.php)?" }, + { "bundleName" : "MPL-1.1", "licenseNamePattern" : "MPL 1\\.1" }, + { "bundleName" : "MPL-2.0", "licenseUrlPattern" : ".*(www\\.).opensource\\.org/licenses/MPL-2\\.0" }, + { "bundleName" : "Public-Domain", "licenseNamePattern" : "((public)\\s(domain)).*", "transformUrl" : false }, + { "bundleName" : "Public-Domain", "licenseFileContentPattern" : ".*(Creative)\\s(Commons).*", "transformUrl" : false }, + { "bundleName" : "Public-Domain", "licenseFileContentPattern" : ".*((Public)\\s(Domain)).*", "transformUrl" : false }, + { "bundleName" : "CC-BY-2.5", "modulePattern": "net.jcip:jcip-annotations:1\\.0" } + ] +} diff --git a/gcp-auth-extension/build.gradle.kts b/gcp-auth-extension/build.gradle.kts index 60a4e9674..3e7cf42f4 100644 --- a/gcp-auth-extension/build.gradle.kts +++ b/gcp-auth-extension/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("otel.java-conventions") + id("otel.shadow-conventions") id("otel.publish-conventions") - id("com.gradleup.shadow") } description = "OpenTelemetry extension that provides GCP authentication support for OTLP exporters" diff --git a/ibm-mq-metrics/build.gradle.kts b/ibm-mq-metrics/build.gradle.kts index 7beadbc20..f083e70ac 100644 --- a/ibm-mq-metrics/build.gradle.kts +++ b/ibm-mq-metrics/build.gradle.kts @@ -1,7 +1,7 @@ plugins { application - id("com.gradleup.shadow") id("otel.java-conventions") + id("otel.shadow-conventions") id("otel.publish-conventions") } @@ -62,6 +62,10 @@ testing { } } +licenseReport { + excludes = arrayOf("com.ibm.mq:com.ibm.mq.allclient") +} + tasks.shadowJar { dependencies { exclude(dependency("com.ibm.mq:com.ibm.mq.allclient")) diff --git a/jmx-metrics/build.gradle.kts b/jmx-metrics/build.gradle.kts index c86103368..7b7eed8ff 100644 --- a/jmx-metrics/build.gradle.kts +++ b/jmx-metrics/build.gradle.kts @@ -1,7 +1,7 @@ plugins { id("otel.java-conventions") application - id("com.gradleup.shadow") + id("otel.shadow-conventions") id("otel.groovy-conventions") id("otel.publish-conventions") diff --git a/maven-extension/build.gradle.kts b/maven-extension/build.gradle.kts index a100335ee..ced743cdd 100644 --- a/maven-extension/build.gradle.kts +++ b/maven-extension/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("java") - id("com.gradleup.shadow") + id("otel.shadow-conventions") id("otel.java-conventions") id("otel.publish-conventions") }