-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use maven-publish plugin for publishing
This commit changes the build's publishing from the old `maven` plugin to the new `maven-publish` plugin.
- Loading branch information
1 parent
f51c3ed
commit ee7058c
Showing
6 changed files
with
83 additions
and
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,90 @@ | ||
apply plugin: "maven" | ||
apply plugin: "maven-publish" | ||
apply plugin: "signing" | ||
|
||
def basePom = { | ||
project { | ||
name project.ext.displayName | ||
description project.description | ||
url "http://spockframework.org" | ||
|
||
licenses { | ||
license { | ||
name "The Apache Software License, Version 2.0" | ||
url "http://www.apache.org/licenses/LICENSE-2.0.txt" | ||
distribution "repo" | ||
} | ||
} | ||
def optionalDeps = [] | ||
def providedDeps = [] | ||
|
||
scm { | ||
connection "scm:git:git://github.com/spockframework/spock.git" | ||
developerConnection "scm:git:ssh://git@github.com/spockframework/spock.git" | ||
url "http://github.spockframework.org/spock" | ||
} | ||
ext { | ||
optional = { optionalDeps << it; it } | ||
provided = { providedDeps << it; it } | ||
} | ||
|
||
developers { | ||
developer { | ||
id "pniederw" | ||
name "Peter Niederwieser" | ||
email "peter@pniederw.com" | ||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
from(components.java) | ||
afterEvaluate { | ||
if (pom.packaging != "pom") { | ||
artifact(sourcesJar) | ||
artifact(javadocJar) | ||
} | ||
} | ||
|
||
developer { | ||
id "ldaley" | ||
name "Luke Daley" | ||
email "ld@ldaley.com" | ||
pom { | ||
name = provider { project.ext.displayName } | ||
description = provider { project.description } | ||
url = "http://spockframework.org" | ||
licenses { | ||
license { | ||
name = "The Apache Software License, Version 2.0" | ||
url = "http://www.apache.org/licenses/LICENSE-2.0.txt" | ||
distribution = "repo" | ||
} | ||
} | ||
scm { | ||
connection = "scm:git:git://github.com/spockframework/spock.git" | ||
developerConnection = "scm:git:ssh://git@github.com/spockframework/spock.git" | ||
url = "http://github.spockframework.org/spock" | ||
} | ||
developers { | ||
developer { | ||
id = "pniederw" | ||
name = "Peter Niederwieser" | ||
email = "peter@pniederw.com" | ||
} | ||
developer { | ||
id = "ldaley" | ||
name = "Luke Daley" | ||
email = "ld@ldaley.com" | ||
} | ||
} | ||
afterEvaluate { | ||
withXml { | ||
def dependencies = asNode().dependencies[0] | ||
optionalDeps.each { dep -> | ||
dependencies.find { it.artifactId.text() == dep.name }.appendNode("optional", true) | ||
} | ||
providedDeps.each { dep -> | ||
dependencies.find { it.artifactId.text() == dep.name }.scope[0].value = "provided" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
def deployers = [] | ||
|
||
project.afterEvaluate { | ||
configure(deployers) { | ||
pom basePom | ||
} | ||
} | ||
|
||
install { | ||
deployers << repositories.mavenInstaller | ||
} | ||
|
||
uploadArchives { | ||
deployers << repositories.mavenDeployer { | ||
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { | ||
authentication(userName: "pniederw", password: System.getenv("SONATYPE_OSS_PASSWORD")) | ||
} | ||
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { | ||
authentication(userName: "pniederw", password: System.getenv("SONATYPE_OSS_PASSWORD")) | ||
repositories { | ||
maven { | ||
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/" | ||
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" | ||
url = snapshotVersion ? snapshotsRepoUrl : releasesRepoUrl | ||
credentials { | ||
username = "pniederw" | ||
password = System.getenv("SONATYPE_OSS_PASSWORD") | ||
} | ||
} | ||
} | ||
} | ||
|
||
def poms = deployers*.pom | ||
def optionalDeps = [] | ||
def providedDeps = [] | ||
def internalDeps = [] | ||
|
||
ext { | ||
modifyPom = { Closure modification -> | ||
poms.each { | ||
it.whenConfigured(modification) | ||
} | ||
} | ||
optional = { optionalDeps << it; it } | ||
provided = { providedDeps << it; it } | ||
internal = { internalDeps << it; it } | ||
// ensure all checks pass before publishing | ||
tasks.withType(AbstractPublishToMaven) { | ||
dependsOn(check) | ||
} | ||
|
||
modifyPom { pom -> | ||
optionalDeps.each { dep -> | ||
pom.dependencies.find { it.artifactId == dep.name }.optional = true | ||
} | ||
providedDeps.each { dep -> | ||
pom.dependencies.find { it.artifactId == dep.name }.scope = "provided" | ||
} | ||
internalDeps.each { dep -> | ||
pom.dependencies.removeAll { it.artifactId == dep.name } | ||
signing { | ||
sign(publishing.publications).each { task -> | ||
task.onlyIf { gradle.taskGraph.hasTask(publish) } | ||
} | ||
// no need to publish test dependencies | ||
pom.dependencies.removeAll { it.scope == "test" } | ||
} | ||
|
||
deployers*.beforeDeployment { signing.signPom(it) } | ||
ext."signing.keyId" = "2EA0A67F" | ||
ext."signing.password" = System.getenv("SIGNING_PASSWORD") | ||
ext."signing.secretKeyRingFile" = "$rootDir/config/code-signing-secring.gpg" |
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