diff --git a/.gitignore b/.gitignore index 32eef1a660..62e4b87407 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ out/ # gradle .gradle/ build/ +.kotlin # Ignore Gradle wrapper jar file gradle/wrapper/gradle-wrapper.jar diff --git a/LICENSE b/LICENSE index 31a06e822c..9fc02c6113 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ -LICENSE applicable to Nessie source ------------------------------------ +Nessie LICENSE +-------------- Apache License Version 2.0, January 2004 diff --git a/LICENSE-BINARY-DIST b/LICENSE-BINARY-DIST index 4db0384f43..99b15740da 100644 --- a/LICENSE-BINARY-DIST +++ b/LICENSE-BINARY-DIST @@ -1,5 +1,5 @@ -LICENSE applicable to Nessie binary distributions -------------------------------------------------- +LICENSE applicable to Nessie executables and containers +------------------------------------------------------- Apache License Version 2.0, January 2004 diff --git a/NOTICE b/NOTICE index 5cf45aac1b..37e3fa151c 100755 --- a/NOTICE +++ b/NOTICE @@ -1,5 +1,5 @@ -NOTICE applicable to Nessie source ----------------------------------- +Nessie NOTICE +------------- Dremio Copyright 2015-2025 Dremio Corporation @@ -34,15 +34,15 @@ Copyright The Apache Software Foundation Netty Copyright The Netty Project -This product includes additional software licensed under the terms -of the following licenses: +This product may include or have transitive dependencies to additional software +licensed under the terms of the following licenses: * Apache Software License, Version 2.0 * Creative Commons 1.0 Universal * Eclipse Distribution License, Version 1.0 * Eclipse Public License, Version 1.0 * Eclipse Public License, Version 2.0 -See also the LICENSE file for Nessie source. +See also the LICENSE file. The Nessie web site provides aggregated license reports for recent Nessie binary distributions, available at https://projectnessie.org/docs/ and diff --git a/NOTICE-BINARY-DIST b/NOTICE-BINARY-DIST index 0fab7f3d10..156070f021 100644 --- a/NOTICE-BINARY-DIST +++ b/NOTICE-BINARY-DIST @@ -1,5 +1,5 @@ -NOTICE applicable to Nessie binary distributions ------------------------------------------------- +NOTICE applicable to Nessie executables and containers +------------------------------------------------------ Dremio Copyright 2015-2025 Dremio Corporation diff --git a/build-logic/src/main/kotlin/Utilities.kt b/build-logic/src/main/kotlin/Utilities.kt index c775c40f21..53070aeef2 100644 --- a/build-logic/src/main/kotlin/Utilities.kt +++ b/build-logic/src/main/kotlin/Utilities.kt @@ -19,20 +19,18 @@ import java.io.File import java.lang.IllegalArgumentException import java.lang.IllegalStateException import java.util.Properties -import org.gradle.api.Action -import org.gradle.api.JavaVersion -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.UnknownProjectException +import org.gradle.api.* import org.gradle.api.artifacts.Dependency import org.gradle.api.artifacts.ExternalModuleDependency import org.gradle.api.artifacts.ModuleDependency import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.FileTree import org.gradle.api.invocation.Gradle import org.gradle.api.logging.LogLevel +import org.gradle.api.provider.ListProperty import org.gradle.api.resources.TextResource -import org.gradle.api.tasks.SourceSetContainer +import org.gradle.api.tasks.* import org.gradle.api.tasks.testing.Test import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.jvm.toolchain.JavaToolchainService @@ -385,3 +383,34 @@ class ReplaceInFiles(val files: FileTree, val replacements: Map) } } } + +@CacheableTask +abstract class GeneratePomProperties : DefaultTask() { + @Suppress("unused") @get:Input abstract val pomInputs: ListProperty + + @get:OutputDirectory abstract val destinationDir: DirectoryProperty + + init { + pomInputs.convention(listOf(project.group.toString(), project.name, project.version.toString())) + destinationDir.convention(project.layout.buildDirectory.dir("generated/pom-properties")) + } + + @TaskAction + fun generate() { + val buildDir = destinationDir.get().asFile + buildDir.deleteRecursively() + val targetDir = buildDir.resolve("META-INF/maven/${project.group}/${project.name}") + targetDir.mkdirs() + targetDir + .resolve("pom.properties") + .writeText( + """ + # Generated by the Nessie build. + groupId=${project.group} + artifactId=${project.name} + version=${project.version} + """ + .trimIndent() + ) + } +} diff --git a/build-logic/src/main/kotlin/nessie-common-java.gradle.kts b/build-logic/src/main/kotlin/nessie-common-java.gradle.kts index f4d76def5e..bda630ddfc 100644 --- a/build-logic/src/main/kotlin/nessie-common-java.gradle.kts +++ b/build-logic/src/main/kotlin/nessie-common-java.gradle.kts @@ -23,3 +23,45 @@ plugins { id("nessie-java") id("nessie-testing") } + +if (project.hasProperty("release") || project.hasProperty("jarWithGitInfo")) { + /** + * Adds convenient, but not strictly necessary information to each generated "main" jar. + * + * This includes `pom.properties` and `pom.xml` files where Maven places those, in + * `META-INF/maven/group-id/artifact-id/`. Also adds the `NOTICE` and `LICENSE` files in + * `META-INF`, which makes it easier for license scanners. + */ + plugins.withType(JavaLibraryPlugin::class.java) { + val generatePomProperties = + tasks.register("generatePomProperties", GeneratePomProperties::class.java) {} + + val additionalJarContent = + tasks.register("additionalJarContent", Sync::class.java) { + // Have to manually declare the inputs of this task here on top of the from/include below + inputs.files(rootProject.layout.files("LICENSE", "NOTICE")) + inputs.property("GAV", "${project.group}:${project.name}:${project.version}") + dependsOn("generatePomFileForMavenPublication") + from(rootProject.rootDir) { + include("LICENSE", "NOTICE") + eachFile { + this.path = + "META-INF/licenses/${project.group}/${project.name}-${project.version}/$sourceName" + } + } + from(tasks.named("generatePomFileForMavenPublication")) { + include("pom-default.xml") + eachFile { this.path = "META-INF/maven/${project.group}/${project.name}/pom.xml" } + } + into(layout.buildDirectory.dir("license-for-jar")) + } + + tasks.named("processResources") { dependsOn(additionalJarContent) } + + val sourceSets: SourceSetContainer by project + sourceSets.named("main") { + resources.srcDir(additionalJarContent) + resources.srcDir(generatePomProperties) + } + } +} diff --git a/build-logic/src/main/kotlin/nessie-common-src.gradle.kts b/build-logic/src/main/kotlin/nessie-common-src.gradle.kts index 2136665d1d..25686e235c 100644 --- a/build-logic/src/main/kotlin/nessie-common-src.gradle.kts +++ b/build-logic/src/main/kotlin/nessie-common-src.gradle.kts @@ -166,7 +166,7 @@ plugins.withType().configureEach { // Adds Git/Build/System related information to the generated jars, if the `release` project // property is present. Do not add that information in development builds, so that the // generated jars are still cachable for Gradle. -if (project.hasProperty("release")) { +if (project.hasProperty("release") || project.hasProperty("jarWithGitInfo")) { tasks.withType().configureEach { manifest { MemoizedGitInfo.gitInfo(rootProject, attributes) } } @@ -193,7 +193,7 @@ class MemoizedGitInfo { } fun gitInfo(rootProject: Project): Map { - if (!rootProject.hasProperty("release")) { + if (!rootProject.hasProperty("release") && !rootProject.hasProperty("jarWithGitInfo")) { return emptyMap() }