1- import org. gradle.internal.os.OperatingSystem
1+ import aQute.bnd. gradle.Bundle
22
33plugins {
4- id ' java'
5- id ' java-library'
6- id ' maven-publish'
7- id ' jacoco'
8- id ' com.github.kt3k.coveralls' version ' 2.12.2'
9- id " org.gradle.test-retry" version " 1.1.9"
10- id ' io.github.gradle-nexus.publish-plugin' version ' 1.1.0'
11- id ' signing'
4+ id(" java-library" )
5+ id(" maven-publish" )
6+ id(" jacoco" )
7+ id(" biz.aQute.bnd.builder" ) version " 7.2.1"
8+ id(" org.gradle.test-retry" ) version " 1.6.4"
9+ id(" io.github.gradle-nexus.publish-plugin" ) version " 2.0.0"
10+ id(" signing" )
1211}
1312
14- def jarVersion = " 2.22 .0"
13+ def jarVersion = " 3.0 .0"
1514group = ' io.nats'
1615
17- def isMerge = System . getenv(" BUILD_EVENT" ) == " push"
1816def isRelease = System . getenv(" BUILD_EVENT" ) == " release"
17+ def tc = System . getenv(" TARGET_COMPATIBILITY" )
18+ def targetCompat = tc == " 25" ? JavaVersion . VERSION_25 : JavaVersion . VERSION_21
19+ def jarEnd = tc == " 25" ? " -jdk25" : " "
20+ def bundleEnd = tc == " 25" ? " .jdk25" : " "
21+ def jarAndArtifactName = " jnats-json" + jarEnd
22+ def bundleName = " io.nats.jnats.json" + bundleEnd
1923
20- // version is the variable the build actually uses.
21- version = isRelease ? jarVersion : jarVersion + " -SNAPSHOT"
24+ version = isRelease ? jarVersion : jarVersion + " -SNAPSHOT" // version is the variable the build actually uses.
2225
2326java {
24- sourceCompatibility = JavaVersion . VERSION_1_8
25- targetCompatibility = JavaVersion . VERSION_1_8
27+ sourceCompatibility = JavaVersion . VERSION_21
28+ targetCompatibility = targetCompat
29+ withSourcesJar()
30+ withJavadocJar()
2631}
2732
2833repositories {
2934 mavenCentral()
30- maven { url " https://oss.sonatype.org/content/repositories/releases/" }
35+ maven { url= " https://repo1.maven.org/maven2/" }
36+ maven { url= " https://central.sonatype.com/repository/maven-snapshots/" }
3137}
3238
3339dependencies {
34- testImplementation ' org.junit.jupiter:junit-jupiter:5.7.1'
35- testImplementation ' nl.jqno.equalsverifier:equalsverifier:3.12.3'
40+ implementation ' org.jspecify:jspecify:1.0.0'
41+ implementation ' commons-codec:commons-codec:1.20.0'
42+
43+ testImplementation ' org.junit.jupiter:junit-jupiter:5.14.1'
44+
45+ testRuntimeOnly ' org.junit.platform:junit-platform-launcher'
46+ }
47+
48+ tasks. register(' bundle' , Bundle ) {
49+ from sourceSets. main. output
50+ }
51+
52+ jar {
53+ bundle {
54+ bnd(" Bundle-Name" : bundleName,
55+ " Bundle-Vendor" : " nats.io" ,
56+ " Bundle-Description" : " JNats JSON Utility" ,
57+ " Bundle-DocURL" : " https://github.com/nats-io/jnats.json" ,
58+ " Target-Compatibility" : " Java " + targetCompat
59+ )
60+ }
3661}
3762
3863test {
@@ -45,35 +70,11 @@ test {
4570}
4671
4772javadoc {
73+ failOnError = false
4874 options. overview = ' src/main/javadoc/overview.html' // relative to source root
4975 source = sourceSets. main. allJava
50- title = " NATS.IO JNats JSON"
76+ title = " JNats JSON Utility "
5177 classpath = sourceSets. main. runtimeClasspath
52- doLast {
53- if (! OperatingSystem . current(). isWindows()) {
54- exec {
55- println " Updating favicon on all html files"
56- workingDir ' build/docs/javadoc'
57- // Only on linux, mac at this point
58- commandLine ' find' , ' .' , ' -name' , ' *.html' , ' -exec' , ' sed' , ' -i' , ' -e' , ' s#<head>#<head><link rel="icon" type="image/ico" href="favicon.ico">#' , ' {}' , ' ;'
59- }
60- copy {
61- println " Copying images to javadoc folder"
62- from ' src/main/javadoc/images'
63- into ' build/docs/javadoc'
64- }
65- }
66- }
67- }
68-
69- task javadocJar (type : Jar ) {
70- archiveClassifier. set(' javadoc' )
71- from javadoc
72- }
73-
74- task sourcesJar (type : Jar ) {
75- archiveClassifier. set(' sources' )
76- from sourceSets. main. allSource
7778}
7879
7980jacoco {
@@ -82,30 +83,18 @@ jacoco {
8283
8384jacocoTestReport {
8485 reports {
85- xml. enabled = true // coveralls plugin depends on xml format report
86- html. enabled = true
87- }
88- afterEvaluate { // only report on main library not examples
89- classDirectories. setFrom(files(classDirectories. files. collect {
90- fileTree(dir : it,
91- exclude : [' **/examples**' ])
92- }))
86+ xml. required = true // coveralls plugin depends on xml format report
87+ html. required = true
9388 }
9489}
9590
96- artifacts {
97- archives javadocJar, sourcesJar
98- }
99-
100- if (isMerge || isRelease) {
101- nexusPublishing {
102- repositories {
103- sonatype {
104- nexusUrl. set(uri(" https://ossrh-staging-api.central.sonatype.com/service/local/" ))
105- snapshotRepositoryUrl. set(uri(" https://central.sonatype.com/repository/maven-snapshots/" ))
106- username = System . getenv(' OSSRH_USERNAME' )
107- password = System . getenv(' OSSRH_PASSWORD' )
108- }
91+ nexusPublishing {
92+ repositories {
93+ sonatype {
94+ nexusUrl. set(uri(" https://ossrh-staging-api.central.sonatype.com/service/local/" ))
95+ snapshotRepositoryUrl. set(uri(" https://central.sonatype.com/repository/maven-snapshots/" ))
96+ username = System . getenv(' OSSRH_USERNAME' )
97+ password = System . getenv(' OSSRH_PASSWORD' )
10998 }
11099 }
111100}
@@ -114,31 +103,31 @@ publishing {
114103 publications {
115104 mavenJava(MavenPublication ) {
116105 from components. java
117- artifact sourcesJar
118- artifact javadocJar
119106 pom {
120- name = rootProject. name
121- packaging = ' jar'
107+ name = ' JNats JSON Utility'
108+ description = ' JSON Parser originally built for JNATS'
109+ url = ' https://github.com/nats-io/jnats.json'
110+
122111 groupId = group
123- artifactId = archivesBaseName
124- description = ' JSON Parser built specifically for JNATS'
125- url = ' https://github.com/nats-io/nats.java.json'
112+ artifactId = jarAndArtifactName
113+
126114 licenses {
127115 license {
128116 name = ' The Apache License, Version 2.0'
129117 url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
130118 }
131119 }
120+
132121 developers {
133122 developer {
134- id = " synadia"
135- name = " Synadia"
136- email = " info@synadia.com"
137- url = " https://nats .io"
123+ id = ' synadia'
124+ name = ' Synadia'
125+ email = ' info@synadia.com'
126+ url = ' https://synadia .io'
138127 }
139128 }
140129 scm {
141- url = ' https://github.com/nats-io/nats.java .json'
130+ url = ' https://github.com/nats-io/jnats .json'
142131 }
143132 }
144133 }
0 commit comments