Created
August 20, 2014 22:15
-
-
Save cwc/3263c01ac4671ef4f0d0 to your computer and use it in GitHub Desktop.
Gradle skeleton for publishing to Maven Central
This file contains hidden or 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
apply plugin: 'java' | |
apply plugin: 'maven' | |
apply plugin: 'signing' | |
group = 'io.example' | |
archivesBaseName = 'example-artifact' | |
version = '1.0-SNAPSHOT' | |
ext.pomPackaging = 'jar' | |
ext.pomName = 'Example artifact' | |
ext.pomDescription = 'An example artifact' | |
ext.pomProjectUrl = 'https://example.github.io/example-artifact' | |
ext.pomScmWebUrl = 'https://github.com/example/example-artifact' | |
ext.pomLicenseName = 'MIT License' | |
ext.pomLicenseUrl = 'https://www.tldrlegal.com/l/mit' | |
ext.pomDeveloperId = 'exDev' | |
ext.pomDeveloperName = 'Example Developer' | |
ext.pomDeveloperEmail = '[email protected]' | |
// Generates a sources jar | |
task sourcesJar(type: Jar) { | |
from sourceSets.main.allJava | |
} | |
// Generates a Javadoc jar | |
task javadocJar(type: Jar, dependsOn: javadoc) { | |
from javadoc.destinationDir | |
} | |
// Maven Central publishing configuration (`gradlew uploadArchives`) | |
artifacts { | |
archives javadocJar, sourcesJar | |
} | |
signing { | |
sign configurations.archives | |
} | |
uploadArchives { | |
repositories { | |
mavenDeployer { | |
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } | |
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { | |
authentication(userName: mavenCentralUser, password: mavenCentralPassword) | |
} | |
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { | |
authentication(userName: mavenCentralUser, password: mavenCentralPassword) | |
} | |
pom.project { | |
name project.ext.pomName | |
description project.ext.pomDescription | |
packaging project.ext.pomPackaging | |
url project.ext.pomProjectUrl | |
scm { | |
url project.ext.pomScmWebUrl | |
} | |
licenses { | |
license { | |
name project.ext.pomLicenseName | |
url project.ext.pomLicenseUrl | |
} | |
} | |
developers { | |
developer { | |
id project.ext.pomDeveloperId | |
name project.ext.pomDeveloperName | |
email project.ext.pomDeveloperEmail | |
} | |
} | |
} | |
} | |
} | |
} |
This file contains hidden or 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
mavenCentralUser=example | |
mavenCentralPassword=examplePassword | |
signing.keyId=EXAM2383PLE | |
signing.password=examplePassword | |
signing.secretKeyRingFile=d:/cygwin/home/example/.gnupg/secring.gpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment