Skip to content

Commit af9661a

Browse files
author
may
committed
Convert to new Maven publish plugin
1 parent c55e0d8 commit af9661a

File tree

1 file changed

+49
-91
lines changed

1 file changed

+49
-91
lines changed

build.gradle

Lines changed: 49 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
import com.vanniktech.maven.publish.JavaLibrary
2+
import com.vanniktech.maven.publish.JavadocJar
3+
import com.vanniktech.maven.publish.SonatypeHost
4+
15
plugins {
26
id 'java-library'
37
id 'checkstyle'
48
id 'jacoco'
5-
id "com.github.spotbugs" version "6.1.11"
6-
id 'maven-publish'
7-
id 'signing'
8-
id "io.codearte.nexus-staging" version "0.30.0" // logs into Sonotype OSS and does a "Close" and "Release"
9+
id "com.github.spotbugs" version '6.1.11'
910
id 'com.adarshr.test-logger' version '4.0.0'
10-
id "com.github.ben-manes.versions" version "0.52.0"
11+
id "com.github.ben-manes.versions" version '0.52.0'
1112
id 'org.sonatype.gradle.plugins.scan' version '3.1.1'
12-
id "org.sonarqube" version "6.1.0.5360"
13+
id "org.sonarqube" version '6.1.0.5360'
14+
id 'com.vanniktech.maven.publish' version '0.31.0'
1315
}
1416

1517
group = 'com.imsweb'
@@ -24,9 +26,6 @@ tasks.withType(JavaCompile).configureEach {
2426
java {
2527
sourceCompatibility = JavaVersion.VERSION_1_8
2628
targetCompatibility = JavaVersion.VERSION_1_8
27-
28-
withJavadocJar()
29-
withSourcesJar()
3029
}
3130

3231
repositories {
@@ -49,7 +48,8 @@ dependencies {
4948

5049
jar {
5150
manifest {
52-
attributes('Implementation-Title': project.name,
51+
attributes(
52+
'Implementation-Title': project.name,
5353
'Implementation-Version': archiveVersion,
5454
'Implementation-Vendor': group,
5555
'Created-By': System.properties['java.vm.version'] + ' (' + System.properties['java.vm.vendor'] + ')',
@@ -110,94 +110,52 @@ dependencyUpdates {
110110
}
111111
}
112112

113-
// don't try to release a snapshot to a non-snapshot repository, that won't work anyway
114-
if (version.endsWith('-SNAPSHOT')) {
115-
gradle.startParameter.excludedTaskNames += 'signMavenJavaPublication'
116-
gradle.startParameter.excludedTaskNames += 'closeAndReleaseRepository'
117-
}
118-
119-
publishing {
120-
publications {
121-
mavenJava(MavenPublication) {
122-
artifactId = 'x12-parser'
123-
from components.java
124-
versionMapping {
125-
usage('java-api') {
126-
fromResolutionOf('runtimeClasspath')
127-
}
128-
usage('java-runtime') {
129-
fromResolutionResult()
130-
}
131-
}
132-
pom {
133-
name = 'X12 Parser'
134-
description = 'A Java library for parsing X12 files, including ANSI 837'
135-
url = 'https://github.com/imsweb/x12-parser'
136-
inceptionYear = '2015'
137-
138-
licenses {
139-
license {
140-
name = 'A modified BSD License (BSD)'
141-
url = 'https://github.com/imsweb/x12-parser/blob/master/LICENSE'
142-
distribution = 'repo'
143-
}
144-
}
145-
146-
developers {
147-
developer {
148-
id = 'AngelaszekD'
149-
name = 'David Angelaszek'
150-
email = 'AngelaszekD@imsweb.com'
151-
}
152-
developer {
153-
id = 'ctmay4'
154-
name = 'Chuck May'
155-
email = 'mayc@imsweb.com'
156-
}
157-
}
158-
159-
scm {
160-
url = 'https://github.com/imsweb/x12-parser'
161-
connection = 'scm:https://github.com/imsweb/x12-parser.git'
162-
developerConnection = 'scm:git@github.com:imsweb/x12-parser.git'
163-
}
164-
}
165-
}
166-
}
167-
repositories {
168-
maven {
169-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
170-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
171-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
172-
173-
credentials {
174-
username = project.findProperty('nexusUsername') ?: ''
175-
password = project.findProperty('nexusPassword') ?: ''
176-
}
177-
}
178-
}
179-
}
180-
181-
signing {
182-
def signingKey = project.findProperty('signingKey') ?: ''
183-
def signingPassword = project.findProperty('signingPassword') ?: ''
184-
185-
useInMemoryPgpKeys(signingKey, signingPassword)
186-
187-
sign publishing.publications.mavenJava
188-
}
189-
190113
javadoc {
191114
if (JavaVersion.current().isJava9Compatible()) {
192115
options.addBooleanOption('html5', true)
193116
options.addStringOption('Xdoclint:none', '-quiet')
194117
}
195118
}
196119

197-
// configure nexus staging plugin
198-
nexusStaging {
199-
numberOfRetries = 50
200-
delayBetweenRetriesInMillis = 5000
120+
mavenPublishing {
121+
configure(new JavaLibrary(new JavadocJar.Javadoc(), true))
122+
123+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, true)
124+
signAllPublications()
125+
126+
pom {
127+
name = 'X12 Parser'
128+
description = 'A Java library for parsing X12 files, including ANSI 837'
129+
url = 'https://github.com/imsweb/x12-parser'
130+
inceptionYear = '2015'
131+
132+
licenses {
133+
license {
134+
name = 'A modified BSD License (BSD)'
135+
url = 'https://github.com/imsweb/x12-parser/blob/master/LICENSE'
136+
distribution = 'repo'
137+
}
138+
}
139+
140+
developers {
141+
developer {
142+
id = 'AngelaszekD'
143+
name = 'David Angelaszek'
144+
email = 'AngelaszekD@imsweb.com'
145+
}
146+
developer {
147+
id = 'ctmay4'
148+
name = 'Chuck May'
149+
email = 'mayc@imsweb.com'
150+
}
151+
}
152+
153+
scm {
154+
url = 'https://github.com/imsweb/x12-parser'
155+
connection = 'scm:https://github.com/imsweb/x12-parser.git'
156+
developerConnection = 'scm:git@github.com:imsweb/x12-parser.git'
157+
}
158+
}
201159
}
202160

203161
wrapper {

0 commit comments

Comments
 (0)