Skip to content

Commit 6d722c6

Browse files
authored
Merge pull request #225 from Smarteon/jimi/java
chore: publish to maven central
2 parents dbfb9c2 + b1d9744 commit 6d722c6

7 files changed

Lines changed: 118 additions & 126 deletions

File tree

.github/workflows/loxone-java-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v3
16-
- name: Set up JDK 11
16+
- name: Set up JDK 17
1717
uses: actions/setup-java@v3
1818
with:
19-
java-version: '11'
20-
distribution: 'adopt'
19+
java-version: '17'
20+
distribution: 'temurin'
2121
- name: Check with Gradle
2222
uses: gradle/gradle-build-action@v2
2323
with:

.github/workflows/loxone-java-release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
ref: master
2626
token: ${{ secrets.SMARTEON_GIT_TOKEN }}
2727

28-
- name: Setup JDK 11
28+
- name: Setup JDK 17
2929
uses: actions/setup-java@v3
3030
with:
31-
java-version: '11'
32-
distribution: 'adopt'
31+
java-version: '17'
32+
distribution: 'temurin'
3333

3434
- name: Set up git configuration
3535
run: |
@@ -50,9 +50,9 @@ jobs:
5050
- name: Publish to OSS Sonatype
5151
shell: bash
5252
env:
53-
OSS_USER: ${{ secrets.OSS_USER }}
54-
OSS_PASS: ${{ secrets.OSS_PASS }}
55-
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
56-
SIGNING_PASS: ${{ secrets.SIGNING_PASS }}
53+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSS_USER }}
54+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSS_PASS }}
55+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
56+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASS }}
5757
run: |
58-
./gradlew publishLibraryPublicationToProjectLocalRepository zipMavenCentralPortalPublication releaseMavenCentralPortalPublication
58+
./gradlew publishToMavenCentral

build.gradle.kts

Lines changed: 63 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import com.vanniktech.maven.publish.JavaLibrary
2+
import com.vanniktech.maven.publish.JavadocJar
3+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4+
15
group = "cz.smarteon"
26

37
scmVersion {
@@ -11,20 +15,20 @@ project.version = scmVersion.version
1115

1216
plugins {
1317
`java-library`
14-
signing
15-
`maven-publish`
1618
jacoco
1719
id("pl.allegro.tech.build.axion-release") version "1.18.18"
18-
id("org.danilopianini.publish-on-central") version "8.0.7"
20+
id("com.vanniktech.maven.publish") version "0.34.0"
1921
id("ru.vyarus.quality") version "6.0.1"
20-
kotlin("jvm") version "1.7.10"
22+
kotlin("jvm") version "2.2.20"
2123
}
2224

2325
java {
26+
toolchain {
27+
languageVersion.set(JavaLanguageVersion.of(17))
28+
}
2429
sourceCompatibility = JavaVersion.VERSION_11
2530
targetCompatibility = JavaVersion.VERSION_11
26-
withJavadocJar()
27-
withSourcesJar()
31+
// javadoc and sources configured in publishing plugin
2832
}
2933

3034
repositories {
@@ -58,6 +62,7 @@ dependencies {
5862
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
5963
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
6064
testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion")
65+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
6166

6267
val striktVersion = "0.34.1"
6368
testImplementation("io.strikt:strikt-core:$striktVersion")
@@ -88,88 +93,59 @@ dependencies {
8893
testImplementation("org.awaitility:awaitility-kotlin:4.1.1")
8994
}
9095

91-
val ossUser: String? = System.getenv("OSS_USER")
92-
val ossPass: String? = System.getenv("OSS_PASS")
93-
94-
publishing {
95-
publications {
96-
create<MavenPublication>("library") {
97-
from(components["java"])
98-
99-
pom {
100-
name.set(project.name)
101-
url.set("https://github.com/Smarteon/loxone-java")
102-
description.set("Java implementation of the Loxone&trade; communication protocol (Web Socket)")
103-
organization {
104-
name.set("Smarteon Systems s.r.o")
105-
url.set("https://smarteon.cz")
106-
}
107-
licenses {
108-
license {
109-
name.set("3-Clause BSD License")
110-
url.set("https://opensource.org/licenses/BSD-3-Clause")
111-
distribution.set("repo")
112-
}
113-
}
114-
developers {
115-
developer {
116-
name.set("Jiří Mikulášek")
117-
email.set("jiri.mikulasek@smarteon.cz")
118-
}
119-
developer {
120-
name.set("Vojtěch Zavřel")
121-
email.set("vojtech.zavrel@smarteon.cz")
122-
}
123-
developer {
124-
name.set("Tomáš Knotek")
125-
email.set("tomas.knotek@smarteon.cz")
126-
}
127-
}
128-
contributors {
129-
contributor {
130-
name.set("Petr Žufan")
131-
}
132-
}
133-
scm {
134-
url.set("git@github.com:Smarteon/loxone-java.git")
135-
connection.set("scm:git:git@github.com:Smarteon/loxone-java.git")
136-
tag.set(project.version.toString())
137-
}
138-
}
139-
}
140-
}
141-
}
96+
// see https://vanniktech.github.io/gradle-maven-publish-plugin/central/#secrets for how to set up credentials and signing
97+
mavenPublishing {
98+
publishToMavenCentral(automaticRelease = true)
99+
signAllPublications()
142100

143-
if (ossUser != null && ossPass != null) {
144-
publishOnCentral {
145-
repoOwner.set("Smarteon")
146-
projectDescription.set("Java implementation of the Loxone&trade; communication protocol (Web Socket)")
147-
licenseName.set("3-Clause BSD License")
148-
licenseUrl.set("https://opensource.org/licenses/BSD-3-Clause")
101+
configure(
102+
JavaLibrary(
103+
javadocJar = JavadocJar.Javadoc(),
104+
sourcesJar = true,
105+
)
106+
)
149107

150-
repositories {
151-
mavenCentral.user.set(ossUser)
152-
mavenCentral.password.set(ossPass)
153-
}
154-
}
155-
}
108+
coordinates(project.group.toString(), project.name, project.version.toString())
156109

157-
val signingKey: String? = System.getenv("SIGNING_KEY")
158-
val signingPassword: String? = System.getenv("SIGNING_PASS")
159-
if (signingKey != null && signingPassword != null) {
160-
signing {
161-
setRequired({
162-
!project.version.toString().endsWith("-SNAPSHOT")
163-
})
164-
useInMemoryPgpKeys(signingKey, signingPassword)
165-
sign(publishing.publications["library"])
166-
}
167-
} else if (hasProperty("signing.keyId")) {
168-
signing {
169-
setRequired({
170-
!project.version.toString().endsWith("-SNAPSHOT")
171-
})
172-
sign(publishing.publications["library"])
110+
pom {
111+
name = project.name
112+
url = "https://github.com/Smarteon/loxone-java"
113+
description = "Java implementation of the Loxone&trade; communication protocol (Web Socket)"
114+
organization {
115+
name = "Smarteon Systems s.r.o"
116+
url = "https://smarteon.cz"
117+
}
118+
licenses {
119+
license {
120+
name = "3-Clause BSD License"
121+
url = "https://opensource.org/licenses/BSD-3-Clause"
122+
distribution = "repo"
123+
}
124+
}
125+
developers {
126+
developer {
127+
name = "Jiří Mikulášek"
128+
email = "jiri.mikulasek@smarteon.cz"
129+
}
130+
developer {
131+
name = "Vojtěch Zavřel"
132+
email = "vojtech.zavrel@smarteon.cz"
133+
}
134+
developer {
135+
name = "Tomáš Knotek"
136+
email = "tomas.knotek@smarteon.cz"
137+
}
138+
}
139+
contributors {
140+
contributor {
141+
name = "Petr Žufan"
142+
}
143+
}
144+
scm {
145+
url = "git@github.com:Smarteon/loxone-java.git"
146+
connection = "scm:git:git@github.com:Smarteon/loxone-java.git"
147+
tag = project.version.toString()
148+
}
173149
}
174150
}
175151

@@ -195,8 +171,8 @@ tasks {
195171
}
196172

197173
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
198-
kotlinOptions {
199-
jvmTarget = "11"
174+
compilerOptions {
175+
jvmTarget.set(JvmTarget.JVM_11)
200176
}
201177
}
202178

gradle/wrapper/gradle-wrapper.jar

-16.6 KB
Binary file not shown.
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.14.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

Lines changed: 26 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)