Skip to content

Commit 7af6935

Browse files
committed
Upgrade to Gradle 7.6, switch to maven-publish plugin, upgrade credentials plugin
1 parent 08ff491 commit 7af6935

File tree

7 files changed

+274
-189
lines changed

7 files changed

+274
-189
lines changed

build.gradle

Lines changed: 86 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1+
/*
2+
Gradle build script for decimal-java.
3+
4+
Uploading archives:
5+
6+
publish -PcredentialsPassphrase=<credentials password>
7+
*/
8+
19
plugins {
210
id 'java-library'
3-
id 'nu.studer.credentials' version '1.0.7'
4-
id 'maven'
11+
id 'nu.studer.credentials' version '3.0'
12+
id 'maven-publish'
513
id 'signing'
614
}
715

816
group 'org.firebirdsql'
917
version '1.0.1-SNAPSHOT'
1018

11-
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
12-
ext."signing.password" = credentials."signing.password"
13-
ext.ossrhPassword = credentials.ossrhPassword
19+
ext.'signing.password' = credentials.forKey('signing.password')
20+
ext.ossrhPassword = credentials.forKey('ossrhPassword')
21+
22+
ext.isReleaseVersion = provider {
23+
!version.endsWith("SNAPSHOT")
24+
}
1425

1526
sourceCompatibility = JavaVersion.VERSION_1_7
1627
targetCompatibility = JavaVersion.VERSION_1_7
@@ -19,6 +30,11 @@ repositories {
1930
mavenCentral()
2031
}
2132

33+
java {
34+
withJavadocJar()
35+
withSourcesJar()
36+
}
37+
2238
dependencies {
2339
testImplementation 'junit:junit:4.13.1'
2440
}
@@ -47,66 +63,85 @@ jar {
4763
}
4864
}
4965

50-
task javadocJar(type: Jar) {
51-
archiveClassifier = 'javadoc'
52-
from javadoc
53-
}
54-
55-
task sourcesJar(type: Jar) {
56-
archiveClassifier = 'sources'
57-
from sourceSets.main.allSource
58-
}
59-
60-
artifacts {
61-
archives javadocJar, sourcesJar
62-
}
63-
64-
signing {
65-
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
66-
sign configurations.archives
66+
javadoc {
67+
options.author()
68+
options.windowTitle = "decimal-java API"
69+
options.docTitle = 'decimal-java'
70+
options.bottom = "Copyright &copy; 2017-${new Date().format("yyyy")} Jaybird (Firebird JDBC) team. All rights reserved."
71+
if(JavaVersion.current().isJava9Compatible()) {
72+
options.addBooleanOption('html5', true)
73+
options.addBooleanOption('Xdoclint:none', true)
74+
}
6775
}
6876

69-
uploadArchives {
70-
repositories {
71-
mavenDeployer {
72-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
73-
74-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
75-
authentication(userName: ossrhUsername, password: ossrhPassword)
76-
}
77-
78-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
79-
authentication(userName: ossrhUsername, password: ossrhPassword)
80-
}
81-
82-
pom.project {
83-
name 'decimal-java'
84-
packaging 'jar'
85-
description 'A library to convert java.math.BigDecimal to and from ' +
77+
publishing {
78+
publications {
79+
// Main maven artifact
80+
mavenJava(MavenPublication) {
81+
from components.java
82+
pom {
83+
name = 'decimal-java'
84+
packaging = 'jar'
85+
description = 'A library to convert java.math.BigDecimal to and from ' +
8686
'IEEE-754r (IEEE-754-2008) decimal byte representations.'
87-
url 'https://github.com/FirebirdSQL/decimal-java'
88-
89-
scm {
90-
connection 'scm:git:https://github.com/FirebirdSQL/decimal-java.git'
91-
developerConnection 'scm:git:git@github.com:FirebirdSQL/decimal-java.git'
92-
url 'https://github.com/FirebirdSQL/decimal-java'
93-
}
87+
url = 'https://github.com/FirebirdSQL/decimal-java'
88+
inceptionYear = '2017'
9489

9590
licenses {
9691
license {
97-
name 'The MIT License'
98-
url 'https://opensource.org/licenses/MIT'
92+
name = 'The MIT License'
93+
url = 'https://opensource.org/licenses/MIT'
9994
}
10095
}
10196

10297
developers {
10398
developer {
104-
id 'mrotteveel'
105-
name 'Mark Rotteveel'
106-
email 'mark@lawinegevaar.nl'
99+
id = 'mrotteveel'
100+
name = 'Mark Rotteveel'
101+
email = 'mark@lawinegevaar.nl'
102+
}
103+
}
104+
105+
scm {
106+
connection = 'scm:git:https://github.com/FirebirdSQL/decimal-java.git'
107+
developerConnection = 'scm:git:git@github.com:FirebirdSQL/decimal-java.git'
108+
url = 'https://github.com/FirebirdSQL/decimal-java'
109+
}
110+
111+
mailingLists {
112+
mailingList {
113+
name = 'firebird-java'
114+
subscribe = 'firebird-java+subscribe@googlegroups.com'
115+
unsubscribe = 'firebird-java+unsubscribe@googlegroups.com'
116+
post = 'firebird-java@googlegroups.com'
117+
archive = 'https://groups.google.com/g/firebird-java'
118+
otherArchives = ['http://fb-list-archive.s3-website-eu-west-1.amazonaws.com/firebird-java/index.html']
107119
}
108120
}
109121
}
110122
}
111123
}
124+
repositories {
125+
maven {
126+
url = project.isReleaseVersion.get() ? project.releaseRepository : project.snapshotRepository
127+
credentials {
128+
username = findProperty('ossrhUsername') ?: null
129+
password = findProperty('ossrhPassword') ?: null
130+
}
131+
}
132+
}
133+
}
134+
135+
tasks.withType(PublishToMavenRepository).each {
136+
it.doFirst {
137+
if (findProperty('ossrhUsername') == null || findProperty('ossrhPassword') == null) {
138+
throw new RuntimeException('No credentials for publishing, make sure to specify the properties ' +
139+
'credentialsPassphrase, or ossrhUsername and ossrhPassword. See devdoc/publish.md for details.')
140+
}
141+
}
142+
}
143+
144+
signing {
145+
required { isReleaseVersion && gradle.taskGraph.hasTask(':publish') }
146+
sign publishing.publications.mavenJava
112147
}

devdoc/deploy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Deploying
44
To deploy to Maven use
55

66
```
7-
gradlew clean uploadArchives -PcredentialsPassphrase=<credentials password>
7+
gradlew clean publish -PcredentialsPassphrase=<credentials password>
88
```
99

1010
Where `<credentials password>` is the password used to add the credentials (see

gradle.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# Default value so the build script doesn't break
2-
ossrhUsername=don't break the build
1+
# Publish properties
2+
releaseRepository=https\://oss.sonatype.org/service/local/staging/deploy/maven2/
3+
snapshotRepository=https\://oss.sonatype.org/content/repositories/snapshots/

gradle/wrapper/gradle-wrapper.jar

5.82 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4+
networkTimeout=10000
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)