-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize build for Maven Central upload
- Loading branch information
Showing
6 changed files
with
160 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,22 @@ allprojects { | |
} | ||
} | ||
|
||
// tag::mavenBuildRepo[] | ||
File baseBuildDir = file("${project.rootDir}/build") | ||
File mavenBuildRepo = new File(baseBuildDir, "maven-repo") | ||
// end::mavenBuildRepo[] | ||
|
||
// tag::artifactsZip[] | ||
String artifactsZip = 'publish-to-maven-central.zip' | ||
// end::artifactsZip[] | ||
|
||
task zipArtifacts(type: Zip) { | ||
from mavenBuildRepo | ||
exclude '**/maven-metadata.xml*' | ||
archiveFileName.set(artifactsZip) | ||
destinationDirectory.set(baseBuildDir) | ||
} | ||
|
||
configure(subprojects) { | ||
apply plugin: 'java' | ||
apply plugin: 'groovy' | ||
|
@@ -61,15 +77,56 @@ configure(subprojects) { | |
toolchain { | ||
languageVersion = JavaLanguageVersion.of(8) | ||
} | ||
withSourcesJar() | ||
} | ||
|
||
publishing { | ||
publications.all { publication -> | ||
if (publication instanceof MavenPublication) { | ||
publication.pom { | ||
name = project.name | ||
description = project.description | ||
url = "https://aim42.github.io/htmlSanityCheck/" | ||
licenses { | ||
license { | ||
name = 'The Apache License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'gstarke' | ||
name = 'Gernot Starke' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'ascheman' | ||
name = 'Gerd Aschemann' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'rdmueller' | ||
name = 'Ralf D. Müller' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'ruhrotht' | ||
name = 'Thomas Ruhroth' | ||
email = '[email protected]' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:git://github.com/aim42/htmlSanityCheck.git' | ||
developerConnection = 'scm:git:ssh://github.com/aim42/htmlSanityCheck.git' | ||
url = 'https://github.com/aim42/htmlSanityCheck' | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
name = 'myLocalRepositoryForFullIntegrationTests' | ||
//noinspection GrDeprecatedAPIUsage | ||
File baseDir = file(project.parent.buildDir) | ||
url = new File(baseDir, "maven-repo") | ||
url = mavenBuildRepo | ||
} | ||
mavenLocal() | ||
} | ||
|
@@ -91,7 +148,7 @@ configure(subprojects) { | |
} | ||
|
||
def groovyVersion = libs.groovy.bom.get().version | ||
def groovyVersionMajorMinor = groovyVersion.split('\\.')[0..1] .join('.') | ||
def groovyVersionMajorMinor = groovyVersion.split('\\.')[0..1].join('.') | ||
|
||
tasks.named("dependencyUpdates").configure { | ||
gradleReleaseChannel = 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
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 |
---|---|---|
@@ -1,39 +1,75 @@ | ||
:filename: development/publishing.adoc | ||
=== Publishing kbd:htmlSC Releases | ||
|
||
==== Automating the Upload of a Gradle Plugin | ||
Puh - handling Bintray or JCenter is | ||
https://java.dzone.com/articles/enjoy-bintray-and-use-it-pain[not funny]. | ||
|
||
==== Handling (Secret) Credentials | ||
We use Etienne Studers awesome | ||
https://github.com/etiennestuder/gradle-credentials-plugin[Gradle-Credentials plugin] | ||
to allow automatic deployment to public portals (like Bintray, JCenter and/or Gradle-Plugin-Portal) | ||
and keep the appropriate passwords/API-keys secret. | ||
|
||
Brief instructions below - for details see the | ||
https://github.com/etiennestuder/gradle-credentials-plugin[credentials plugin] | ||
|
||
. integrate the plugin in the buildfile | ||
. get the required credentials from the Bintray website (or wherever you want to publish artifacts) | ||
. add the required credentials: | ||
==== Background | ||
|
||
Our Gradle build stores all artifacts and their meta-data (POM + module files, | ||
as well as their respective hashes and signatures) in a local Maven repository. | ||
They are subject to integration tests. | ||
Finally, they can be uploaded to Maven Central (as ZIP file). | ||
|
||
* The build stores these files to the root build directory. | ||
+ | ||
[source] | ||
[source, groovy] | ||
---- | ||
include::../../../build.gradle[tag=mavenBuildRepo] | ||
---- | ||
> gradle addCredentials --key bintrayUserName --value <your-Bintray-username> | ||
:addCredentials | ||
|
||
BUILD SUCCESSFUL | ||
* And it stores the ZIP file there as well | ||
+ | ||
[source, groovy] | ||
---- | ||
include::../../../build.gradle[tag=artifactsZip] | ||
---- | ||
|
||
==== Publishing actions | ||
|
||
> gradle addCredentials --key bintrayApiKey --value <some-long-key> | ||
Adjust version number:: | ||
Set the version number in xref:../../../gradle.properties[] to the next value. | ||
|
||
Build / publish local:: | ||
Generate artifacts and publish them to the local Maven repository for integration tests | ||
+ | ||
[source,bash,subs="callouts+"] | ||
---- | ||
. Within the buildfile you can now access these credentials as follows: | ||
./gradlew clean integrationTests # <1> | ||
---- | ||
<1> This will implicitly call the task `publishAllPublicationsToMyLocalRepositoryForFullIntegrationTestsRepository` which pushes all required files for publication to the repository. | ||
|
||
Sign:: | ||
Sign artifacts, POMs, and modules with GPG. | ||
+ | ||
[source] | ||
[source,bash] | ||
---- | ||
// include these lines in your build.gradle: | ||
println "Username : " + credentials.bintrayUserName | ||
println "Bintray API Key : " + credentials.bintrayApiKey | ||
for i in $(find build -name "*.jar" -o -name "*.pom" -o -name "*.module"); do \ | ||
gpg --yes -ab ${i}; \ | ||
done | ||
---- | ||
|
||
+ | ||
[NOTE] | ||
.Setup PGP / GnuPG | ||
==== | ||
Setting up PGP (or GnuPG) is out of scope for this document. | ||
Please refer to the respective documentation. | ||
==== | ||
|
||
Build ZIP:: | ||
Create a ZIP-File from all artifacts, POMs, and modules, their hashes, and signatures. | ||
+ | ||
[source, bash] | ||
---- | ||
./gradlew zipArtifacts | ||
---- | ||
|
||
Upload ZIP to Maven Central:: | ||
Finally, upload the resulting ZIP file (manually) to Maven Central, | ||
i.e., https://central.sonatype.com/publishing[Sonatype Central]. | ||
+ | ||
[CAUTION] | ||
.Credentials needed | ||
==== | ||
You need respective credentials to upload files to Maven Central for the `org.aim42.htmlSanityCheck` namespace. | ||
Talk to Gernot Starke to get these permissions. | ||
==== |