Skip to content

Commit cf50a71

Browse files
committed
Replace 'maven' plugin with recommended 'maven-publish' plugin
1 parent f7321d3 commit cf50a71

File tree

2 files changed

+49
-49
lines changed

2 files changed

+49
-49
lines changed

build.gradle

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import static org.gradle.api.JavaVersion.VERSION_1_7
22

33
apply plugin: 'java'
4-
apply plugin: 'maven'
54
apply plugin: 'osgi'
65
apply plugin: 'signing'
76
apply plugin: 'maven-publish'
@@ -66,63 +65,63 @@ task javadocJar(type: Jar) {
6665
from javadoc
6766
}
6867

69-
artifacts {
70-
archives sourcesJar, javadocJar
71-
}
72-
73-
signing {
74-
required { gradle.taskGraph.hasTask("uploadArchives") }
75-
sign configurations.archives
76-
}
77-
78-
uploadArchives {
79-
if (hasProperty('ossrhUsername') && hasProperty('ossrhPassword')) {
80-
repositories {
81-
mavenDeployer {
82-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
83-
84-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
85-
authentication(userName: ossrhUsername, password: ossrhPassword)
68+
publishing {
69+
publications {
70+
mavenJava(MavenPublication) {
71+
artifactId = 'java-hamcrest'
72+
from components.java
73+
artifact sourcesJar
74+
artifact javadocJar
75+
pom {
76+
name = 'Java Hamcrest'
77+
description = 'Hamcrest matcher library for Java'
78+
url = 'http://hamcrest.org/JavaHamcrest/'
79+
80+
scm {
81+
connection = 'git@github.com:hamcrest/JavaHamcrest.git'
82+
url = 'https://github.com/hamcrest/JavaHamcrest'
8683
}
8784

88-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
89-
authentication(userName: ossrhUsername, password: ossrhPassword)
85+
licenses {
86+
license {
87+
name = 'BSD Licence 3'
88+
url = 'http://opensource.org/licenses/BSD-3-Clause'
89+
}
9090
}
9191

92-
pom.project {
93-
name 'Java Hamcrest'
94-
packaging 'jar'
95-
description 'Hamcrest matcher library for Java'
96-
url 'http://hamcrest.org/JavaHamcrest/'
97-
98-
scm {
99-
connection 'git@github.com:hamcrest/JavaHamcrest.git'
100-
url 'https://github.com/hamcrest/JavaHamcrest'
92+
developers {
93+
developer {
94+
id = 'joewalnes'
95+
name = 'Joe Walnes'
10196
}
102-
103-
licenses {
104-
license {
105-
name 'BSD Licence 3'
106-
url 'http://opensource.org/licenses/BSD-3-Clause'
107-
}
97+
developer {
98+
id = 'npryce'
99+
name = 'Nat Pryce'
108100
}
109-
110-
developers {
111-
developer {
112-
id 'joewalnes'
113-
name 'Joe Walnes'
114-
}
115-
developer {
116-
id 'npryce'
117-
name 'Nat Pryce'
118-
}
119-
developer {
120-
id 'sf105'
121-
name 'Steve Freeman'
122-
}
101+
developer {
102+
id = 'sf105'
103+
name = 'Steve Freeman'
123104
}
124105
}
125106
}
126107
}
127108
}
109+
repositories {
110+
if (hasProperty('ossrhUsername') && hasProperty('ossrhPassword')) {
111+
maven {
112+
def snapshotRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
113+
def stagingRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
114+
url = version.contains('SNAPSHOT') ? snapshotRepoUrl : stagingRepoUrl
115+
credentials {
116+
username = ossrhUsername
117+
password = ossrhPassword
118+
}
119+
}
120+
}
121+
}
122+
}
123+
124+
signing {
125+
required { hasProperty('ossrhUsername') && hasProperty('ossrhPassword') }
126+
sign publishing.publications.mavenJava
128127
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
enableFeaturePreview('STABLE_PUBLISHING')

0 commit comments

Comments
 (0)