Skip to content

Commit d472c44

Browse files
committed
Update Gradle configs, fix Javadoc warnings, setup automatic deployment
1 parent 14f03f8 commit d472c44

File tree

8 files changed

+360
-223
lines changed

8 files changed

+360
-223
lines changed

.github/workflows/deploy.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Deploy
2+
on:
3+
push:
4+
tags: ['**']
5+
6+
jobs:
7+
deploy:
8+
name: Deploy
9+
runs-on: 'ubuntu-latest'
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-java@v3
13+
with:
14+
distribution: 'temurin'
15+
java-version: 17
16+
- uses: gradle/wrapper-validation-action@v1
17+
- uses: gradle/gradle-build-action@v2
18+
with:
19+
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository --stacktrace
20+
env:
21+
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
22+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
23+
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
24+
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
25+
- name: Create GitHub Release
26+
uses: softprops/action-gh-release@v1
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
with:
30+
tag_name: ${{ steps.get_tag.outputs.tag }}
31+
name: 'Release ${{ steps.get_tag.outputs.tag }}'
32+
prerelease: false
33+
draft: false
34+
files: build/libs/*.jar

build.gradle.kts

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
plugins {
22
`java-library`
3-
signing
43
`maven-publish`
5-
id("net.minecrell.licenser") version "0.4.1"
4+
signing
5+
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
6+
id("org.cadixdev.licenser") version "0.6.1"
67
}
78

89
group = "com.demonwav.mcdev"
910

1011
java {
11-
sourceCompatibility = JavaVersion.VERSION_1_8
12-
targetCompatibility = JavaVersion.VERSION_1_8
12+
toolchain {
13+
languageVersion = JavaLanguageVersion.of(17)
14+
}
1315
withSourcesJar()
1416
withJavadocJar()
1517
}
1618

19+
tasks.withType<JavaCompile>().configureEach {
20+
options.release = 8
21+
}
22+
1723
license {
18-
header = file("header.txt")
24+
header(file("header.txt"))
1925
}
2026

2127
val isSnapshot = version.toString().endsWith("-SNAPSHOT")
@@ -54,10 +60,10 @@ publishing {
5460

5561
developers {
5662
developer {
57-
id.set("DemonWav")
63+
id.set("DenWav")
5864
name.set("Kyle Wood")
59-
email.set("[email protected]")
60-
url.set("https://github.com/DemonWav")
65+
email.set("[email protected]")
66+
url.set("https://github.com/DenWav")
6167
}
6268
}
6369

@@ -68,26 +74,32 @@ publishing {
6874
}
6975
}
7076
}
71-
72-
repositories {
73-
val url = if (isSnapshot) {
74-
"https://oss.sonatype.org/content/repositories/snapshots/"
75-
} else {
76-
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
77-
}
78-
maven(url) {
79-
credentials(PasswordCredentials::class)
80-
name = "osshr"
81-
}
82-
}
8377
}
8478
}
8579

86-
signing {
87-
useGpgCmd()
88-
sign(publishing.publications["mavenJava"])
80+
nexusPublishing.repositories {
81+
sonatype()
8982
}
9083

91-
tasks.withType<Sign> {
92-
onlyIf { !isSnapshot }
84+
// Don't configure signing unless this is present
85+
val sonatypeUsername: Provider<String> = providers.gradleProperty("sonatypeUsername")
86+
val sonatypePassword: Provider<String> = providers.gradleProperty("sonatypePassword")
87+
88+
val gpgSigningKey: Provider<String> = providers.environmentVariable("GPG_SIGNING_KEY")
89+
val gpgPassphrase: Provider<String> = providers.environmentVariable("GPG_PASSPHRASE")
90+
91+
if (sonatypeUsername.isPresent && sonatypePassword.isPresent) {
92+
signing {
93+
setRequired {
94+
!isSnapshot && gradle.taskGraph.hasTask("publishToSonatype")
95+
}
96+
97+
if (gpgSigningKey.isPresent && gpgPassphrase.isPresent) {
98+
useInMemoryPgpKeys(gpgSigningKey.get(), gpgPassphrase.get())
99+
} else {
100+
useGpgCmd()
101+
}
102+
103+
sign(publishing.publications["mavenJava"])
104+
}
93105
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = 2.0
1+
version=2.0.0

gradle/wrapper/gradle-wrapper.jar

7.9 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
36
zipStoreBase=GRADLE_USER_HOME
47
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip

0 commit comments

Comments
 (0)