-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds publishing for Maven artifacts, including signing. Includes all prerequisites to publish Maven artifacts to Maven Central. The build-code parts have been taken from Nessie, including the necessary special treatment of shadow-jars and support to publish a bom. `./gradlew publishToMavenLocal` works out of the box. On top of the Nessie parts, this change can also build a source tarball from using `git archive`. Fully signed invocation example, assuming GPG agent (there are alternative ways to provide the GPG key+passphrase): ```bash ./ gradlew \ publishToMavenLocal \ sourceTarball \ -Prelease \ -PuseGpgAgent ```
- Loading branch information
Showing
21 changed files
with
1,111 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
|
||
plugins { id("com.gradleup.shadow") } | ||
|
||
val shadowJar = tasks.named<ShadowJar>("shadowJar") | ||
|
||
shadowJar.configure { | ||
outputs.cacheIf { false } // do not cache uber/shaded jars | ||
archiveClassifier = "" | ||
mergeServiceFiles() | ||
} | ||
|
||
tasks.named<Jar>("jar").configure { | ||
dependsOn(shadowJar) | ||
archiveClassifier = "raw" | ||
} | ||
|
||
tasks.withType<ShadowJar>().configureEach { | ||
exclude("META-INF/jandex.idx") | ||
isZip64 = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package publishing | ||
|
||
import org.gradle.api.GradleException | ||
import org.gradle.api.Project | ||
import org.gradle.api.java.archives.Attributes | ||
import org.gradle.kotlin.dsl.extra | ||
import java.io.ByteArrayOutputStream | ||
import java.nio.charset.StandardCharsets | ||
|
||
class MemoizedGitInfo { | ||
companion object { | ||
private fun execProc(rootProject: Project, cmd: String, vararg args: Any): String { | ||
val buf = ByteArrayOutputStream() | ||
rootProject.exec { | ||
executable = cmd | ||
args(args.toList()) | ||
standardOutput = buf | ||
} | ||
return buf.toString(StandardCharsets.UTF_8).trim() | ||
} | ||
|
||
fun gitInfo(rootProject: Project, attribs: Attributes) { | ||
val props = gitInfo(rootProject) | ||
attribs.putAll(props) | ||
} | ||
|
||
fun gitInfo(rootProject: Project): Map<String, String> { | ||
return if (rootProject.extra.has("gitReleaseInfo")) { | ||
@Suppress("UNCHECKED_CAST") | ||
rootProject.extra["gitReleaseInfo"] as Map<String, String> | ||
} else { | ||
val isRelease = rootProject.hasProperty("release") | ||
val gitHead = execProc(rootProject, "git", "rev-parse", "HEAD") | ||
val gitDescribe = if (isRelease) { | ||
try { | ||
execProc(rootProject, "git", "describe", "--tags") | ||
} catch (e: Exception) { | ||
throw GradleException("'git describe --tags' failed - no Git tag?", e) | ||
} | ||
} else { | ||
execProc(rootProject, "git", "describe", "--always", "--dirty") | ||
} | ||
val timestamp = execProc(rootProject, "date", "+%Y-%m-%d-%H:%M:%S%:z") | ||
val system = execProc(rootProject, "uname", "-a") | ||
val javaVersion = System.getProperty("java.version") | ||
|
||
val info = | ||
mapOf( | ||
"Apache-Polaris-Version" to rootProject.version.toString(), | ||
"Apache-Polaris-Is-Release" to isRelease.toString(), | ||
"Apache-Polaris-Build-Git-Head" to gitHead, | ||
"Apache-Polaris-Build-Git-Describe" to gitDescribe, | ||
"Apache-Polaris-Build-Timestamp" to timestamp, | ||
"Apache-Polaris-Build-System" to system, | ||
"Apache-Polaris-Build-Java-Version" to javaVersion | ||
) | ||
rootProject.extra["gitReleaseInfo"] = info | ||
return info | ||
} | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
build-logic/src/main/kotlin/publishing/PublishingHelperExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package publishing | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.kotlin.dsl.listProperty | ||
import org.gradle.kotlin.dsl.property | ||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
abstract class PublishingHelperExtension | ||
@Inject | ||
constructor(objectFactory: ObjectFactory, project: Project) | ||
{ | ||
// optional customization of the pom.xml <name> element | ||
val mavenName = objectFactory.property<String>().convention(project.provider { project.name }) | ||
|
||
val licenseUrl = objectFactory.property<String>().convention("https://www.apache.org/licenses/LICENSE-2.0.txt") | ||
|
||
// the following are only relevant on the root project | ||
val asfProjectName = objectFactory.property<String>() | ||
val baseName = objectFactory.property<String>().convention(project.provider { "apache-${asfProjectName.get()}-${project.version}" }) | ||
val distributionDir = objectFactory.directoryProperty().convention(project.layout.buildDirectory.dir("distributions")) | ||
val sourceTarball = objectFactory.fileProperty().convention(project.provider { distributionDir.get().file("${baseName.get()}.tar.gz") }) | ||
val sourceTarballDigest = objectFactory.fileProperty().convention(project.provider { distributionDir.get().file("${baseName.get()}.sha512") }) | ||
|
||
val mailingLists = objectFactory.listProperty(String::class.java).convention(emptyList()) | ||
|
||
// override the list of developers (P)PMC members + committers, necessary for podlings | ||
val podlingPpmcAsfIds = objectFactory.setProperty(String::class.java).convention(emptySet()) | ||
val podlingCommitterAsfIds = objectFactory.setProperty(String::class.java).convention(emptySet()) | ||
|
||
fun distributionFile(ext: String): File = | ||
distributionDir.get().file("${baseName.get()}.$ext").asFile | ||
} |
Oops, something went wrong.