1+ import com.vanniktech.maven.publish.JavaLibrary
2+ import com.vanniktech.maven.publish.JavadocJar
3+ import com.vanniktech.maven.publish.SourcesJar
4+
15plugins {
26 // Support for IntelliJ IDEA
37 // https://docs.gradle.org/current/userguide/idea_plugin.html
@@ -14,9 +18,7 @@ plugins {
1418 id " org.checkerframework" version " 0.6.61"
1519
1620 // Plugin for publishing via the new Nexus API
17- id " io.github.gradle-nexus.publish-plugin" version " 2.0.0"
18-
19- id " signing"
21+ id " com.vanniktech.maven.publish" version " 0.36.0" apply false
2022}
2123
2224
@@ -41,13 +43,13 @@ version = "3.0.0$build"
4143subprojects {
4244 apply plugin : " java"
4345 apply plugin : " java-library"
44- apply plugin : " maven-publish"
45- apply plugin : " signing" // GPG signing of artifacts, required by maven central
4646 apply plugin : " idea"
4747 apply plugin : " eclipse"
4848
4949 apply plugin : " com.diffplug.spotless"
5050 apply plugin : " org.checkerframework"
51+ apply plugin : " com.vanniktech.maven.publish"
52+ // apply plugin: "maven-publish"
5153
5254 group = rootProject. group
5355 version = rootProject. version
@@ -81,13 +83,13 @@ subprojects {
8183 testImplementation(" ch.qos.logback:logback-classic:1.5.32" )
8284
8385 testImplementation(platform(" org.junit:junit-bom:6.0.3" ))
84- testImplementation (" org.junit.jupiter:junit-jupiter-api" )
85- testImplementation (" org.junit.jupiter:junit-jupiter-params" )
86- testRuntimeOnly (" org.junit.jupiter:junit-jupiter-engine" )
87- testRuntimeOnly (" org.junit.platform:junit-platform-launcher" )
88- testImplementation (" org.assertj:assertj-core:3.27.7" )
89- testImplementation (project(' :key.util' ))
90- testImplementation (testFixtures(project(" :key.util" )))
86+ testImplementation(" org.junit.jupiter:junit-jupiter-api" )
87+ testImplementation(" org.junit.jupiter:junit-jupiter-params" )
88+ testRuntimeOnly(" org.junit.jupiter:junit-jupiter-engine" )
89+ testRuntimeOnly(" org.junit.platform:junit-platform-launcher" )
90+ testImplementation(" org.assertj:assertj-core:3.27.7" )
91+ testImplementation(project(' :key.util' ))
92+ testImplementation(testFixtures(project(" :key.util" )))
9193
9294 // test fixtures
9395 testImplementation(" com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.21.3" )
@@ -135,7 +137,6 @@ subprojects {
135137 classpath = sourceSets. test. runtimeClasspath
136138 }
137139
138-
139140 test {
140141 // Before we switched to JUnit 5, we used JUnit 4 with a customized discovery of test class.
141142 // This discovery called AutoSuite and searched in the compiled classes. AutoSuite was
@@ -148,10 +149,10 @@ subprojects {
148149 }
149150
150151 addTestListener(new TestListener () {
151- void afterTest (TestDescriptor desc , TestResult result ) {
152- logger. error(" ${ result.getResultType()} : ${ desc.getClassName()} #${ desc.getName()} " )
153- }
154- })
152+ void afterTest (TestDescriptor desc , TestResult result ) {
153+ logger. error(" ${ result.getResultType()} : ${ desc.getClassName()} #${ desc.getName()} " )
154+ }
155+ })
155156
156157 addTestListener(new TestListener () {
157158 void beforeTest (TestDescriptor descriptor ) {
@@ -284,130 +285,82 @@ subprojects {
284285 // specific delimiter: normally just 'package', but spotless crashes for files in default package
285286 // (see https://github.com/diffplug/spotless/issues/30), therefore 'import' is needed. '//' is for files
286287 // with completely commented out code (which would probably better just be removed in future).
287- if (project. name == ' recoder' ) {
288- licenseHeaderFile(" $rootDir /gradle/header-recoder" , ' (package|import|//)' )
289- } else {
290- licenseHeaderFile(" $rootDir /gradle/header" , ' (package|import|//)' )
291- }
288+ licenseHeaderFile(" $rootDir /gradle/header" , ' (package|import|//)' )
292289 }
293290 }
294291
295- afterEvaluate { // required so project.description is non-null as set by sub build.gradle
296- publishing {
297- publications {
298- mavenJava(MavenPublication ) {
299- from components. java
300- artifact sourcesJar
301- artifact javadocJar
302- pom {
303- name = projects. name
304- description = project. description
305- url = ' https://key-project.org/'
306-
307- licenses {
308- license {
309- name = " GNU General Public License (GPL), Version 2"
310- url = " https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"
311- }
312- }
313-
314- developers {
315- developer {
316- id = ' key'
317- name = ' KeY Developers'
318- email = ' support@key-project.org'
319- url = " https://www.key-project.org/about/people/"
320- }
321- }
322- scm {
323- connection = ' scm:git:git://github.com/keyproject/key.git'
324- developerConnection = ' scm:git:git://github.com/keyproject/key.git'
325- url = ' https://github.com/keyproject/key/'
326- }
327- }
292+ mavenPublishing {
293+ publishToMavenCentral()
294+ signAllPublications()
295+
296+ configure(new JavaLibrary (
297+ new JavadocJar.Javadoc (),
298+ new SourcesJar.Sources ()
299+ ))
300+
301+ pom {
302+ name = project. name
303+ description = project. description
304+ url = ' https://key-project.org/'
305+
306+ licenses {
307+ license {
308+ name = " GNU General Public License (GPL), Version 2"
309+ url = " https://www.gnu.org/licenses/old-licenses/gpl-2.0.html"
328310 }
329311 }
330- repositories {
331- maven {
332- name = " LOCAL"
333- url= uri(" $rootDir /local" )
334- }
335312
336- maven { // deployment to git.key-project.org/key-public/key
337- name = " KEYLAB"
338- url = uri(" https://git.key-project.org/api/v4/projects/35/packages/maven" )
339- credentials(HttpHeaderCredentials ) {
340- def userToken = envOrPropertyValue(" GITLAB_USER_TOKEN" )
341- def deployToken = envOrPropertyValue(" GITLAB_DEPLOY_TOKEN" )
342- def ciToken = envOrPropertyValue(" GITLAB_CIJOB_TOKEN" )
343-
344- if (userToken != " " ) {
345- name = ' Private-Token'
346- value = userToken
347- } else if (deployToken != " " ) {
348- name = ' Deploy-Token'
349- value = deployToken
350- } else {
351- name = ' Job-Token'
352- value = ciToken
353- }
354- }
355- authentication {
356- header(HttpHeaderAuthentication )
357- }
313+ developers {
314+ developer {
315+ id = ' key'
316+ name = ' KeY Developers'
317+ email = ' support@key-project.org'
318+ url = " https://www.key-project.org/about/people/"
358319 }
359320 }
360- }
361- signing {
362- // sign publishing.publications.mavenJava
321+ scm {
322+ connection = ' scm:git:git://github.com/keyproject/key.git'
323+ developerConnection = ' scm:git:git://github.com/keyproject/key.git'
324+ url = ' https://github.com/keyproject/key/'
325+ }
363326 }
364327 }
365- }
366328
367- signing {
368- // does not work
369- if (System . getenv(" GPG_PRIVATE_KEY" ) == null ) {
370- useGpgCmd() // works better than the Java implementation, which requires PGP keyrings.
371- } else {
372- useInMemoryPgpKeys(
373- System . getenv(" SIGNING_KEY_ID" ),
374- System . getenv(" GPG_PRIVATE_KEY" ),
375- System . getenv(" GPG_PASSPHRASE" )
376- )
377- }
378- }
329+ publishing {
330+ repositories {
331+ maven {
332+ name = " LOCAL"
333+ url= uri(" $rootDir /local" )
334+ }
379335
380- nexusPublishing {
381- repositories {
382- central {
383- nexusUrl = uri(" https://ossrh-staging-api.central.sonatype.com/service/local/" )
384- snapshotRepositoryUrl = uri(" https://central.sonatype.com/repository/maven-snapshots/" )
385-
386- stagingProfileId. set(" org.key-project" )
387-
388- /**
389- * To be able to publish things on Maven Central, you need two things:
390- *
391- * (1) a JIRA account with permission on group-id `org.key-project`
392- * (2) a keyserver-published GPG (w/o sub-keys)
393- *
394- * Your `$HOME/.gradle/gradle.properties` should like this:
395- * ```
396- * signing.keyId=YourKeyId
397- * signing.password=YourPublicKeyPassword
398- * ossrhUsername=your-jira-id
399- * ossrhPassword=your-jira-password
400- * ```
401- *
402- * You can test signing with `gradle sign`, and publish with `gradle publish`.
403- * https://central.sonatype.org/publish/publish-guide/
404- */
405- username = envOrPropertyValue(" ossrhUsername" )
406- password = envOrPropertyValue(" ossrhPassword" )
336+ maven { // deployment to git.key-project.org/key-public/key
337+ name = " KEYLAB"
338+ url = uri(" https://git.key-project.org/api/v4/projects/35/packages/maven" )
339+ credentials(HttpHeaderCredentials ) {
340+ def userToken = envOrPropertyValue(" GITLAB_USER_TOKEN" )
341+ def deployToken = envOrPropertyValue(" GITLAB_DEPLOY_TOKEN" )
342+ def ciToken = envOrPropertyValue(" GITLAB_CIJOB_TOKEN" )
343+
344+ if (userToken != " " ) {
345+ name = ' Private-Token'
346+ value = userToken
347+ } else if (deployToken != " " ) {
348+ name = ' Deploy-Token'
349+ value = deployToken
350+ } else {
351+ name = ' Job-Token'
352+ value = ciToken
353+ }
354+ }
355+ authentication {
356+ header(HttpHeaderAuthentication )
357+ }
358+ }
407359 }
408360 }
409361}
410362
363+
411364tasks. register(' start' ){
412365 description = " Use :key.ui:run instead"
413366 doFirst {
0 commit comments