Skip to content

Commit beb8dbd

Browse files
committed
Update Gradle build file
- Migration from Legacy OSSRH to Maven Central Publishing Portal
1 parent 976c279 commit beb8dbd

File tree

2 files changed

+127
-168
lines changed

2 files changed

+127
-168
lines changed

build.gradle

Lines changed: 125 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,237 +1,196 @@
11
plugins {
2-
id 'java-library'
3-
id 'maven-publish'
4-
id 'signing'
5-
id 'checkstyle'
6-
id 'org.gradlex.extra-java-module-info' version '1.13'
2+
id 'java-library'
3+
id 'maven-publish'
4+
id 'signing'
5+
id 'checkstyle'
6+
id 'org.gradlex.extra-java-module-info' version '1.13'
77
}
88

9-
apply plugin: 'maven-publish'
10-
119
repositories {
12-
// Access the Central Repository with Gradle via HTTPS
13-
// Ref: https://central.sonatype.org/consume/consume-gradle/
14-
maven {
15-
url = uri('https://repo.maven.apache.org/maven2/')
16-
}
10+
maven {
11+
url = uri('https://repo.maven.apache.org/maven2/')
12+
}
1713
}
1814

1915
// JAXB configuration holds classpath for running the JAXB XJC compiler
2016
configurations {
21-
jaxb
17+
jaxb
2218
}
2319

2420
dependencies {
25-
jaxb "org.glassfish.jaxb:jaxb-xjc:4.0.5"
26-
jaxb "org.glassfish.jaxb:jaxb-runtime:4.0.5"
21+
jaxb "org.glassfish.jaxb:jaxb-xjc:4.0.5"
22+
jaxb "org.glassfish.jaxb:jaxb-runtime:4.0.5"
2723

28-
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
29-
implementation 'org.apache.logging.log4j:log4j-core:2.23.1'
24+
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
25+
implementation 'org.apache.logging.log4j:log4j-core:2.23.1'
3026

31-
// JAXB API only
32-
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
33-
// JAXB RI, Jakarta XML Binding (do not change to runtimeOnly)
34-
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.5'
27+
// JAXB API only
28+
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
29+
// JAXB RI, Jakarta XML Binding (do not change to runtimeOnly)
30+
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.5'
3531

36-
// JUnit Jupiter using Gradle's native JUnit Platform
37-
testImplementation platform('org.junit:junit-bom:5.13.4')
38-
testImplementation 'org.junit.jupiter:junit-jupiter'
39-
testImplementation 'org.junit.jupiter:junit-jupiter-params'
40-
testRuntimeOnly 'org.junit.platform:junit-platform-reporting'
32+
// JUnit Jupiter using Gradle's native JUnit Platform
33+
testImplementation platform('org.junit:junit-bom:5.13.4')
34+
testImplementation 'org.junit.jupiter:junit-jupiter'
35+
testImplementation 'org.junit.jupiter:junit-jupiter-params'
36+
testRuntimeOnly 'org.junit.platform:junit-platform-reporting'
4137

42-
// PLIST implementation
43-
implementation 'com.googlecode.plist:dd-plist:1.28'
38+
// PLIST implementation
39+
implementation 'com.googlecode.plist:dd-plist:1.28'
4440

45-
// Required to read InputStream with BOM-field
46-
// https://mvnrepository.com/artifact/commons-io/commons-io
47-
implementation 'commons-io:commons-io:2.20.0'
41+
// Required to read InputStream with BOM-field
42+
// https://mvnrepository.com/artifact/commons-io/commons-io
43+
implementation 'commons-io:commons-io:2.20.0'
4844

49-
// Testing: Used to load MIME-types from JSON
50-
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
51-
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.19.2'
45+
// Testing: Used to load MIME-types from JSON
46+
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
47+
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.19.0'
5248

53-
// Runtime: Used for JSPF playlists (de)serializiation
54-
// Testing: Used to load MIME-types from JSON
55-
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
56-
implementation 'com.fasterxml.jackson.core:jackson-databind:2.19.2'
49+
// Runtime: Used for JSPF playlists (de)serializiation
50+
// Testing: Used to load MIME-types from JSON
51+
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
52+
implementation 'com.fasterxml.jackson.core:jackson-databind:2.19.0'
5753
}
5854

5955
// Convert legacy dependency to named Java module
6056
extraJavaModuleInfo {
61-
module('com.googlecode.plist:dd-plist', 'dd.plist') {
62-
exports('com.dd.plist')
63-
requires('java.xml')
64-
}
57+
module('com.googlecode.plist:dd-plist', 'dd.plist') {
58+
exports('com.dd.plist')
59+
requires('java.xml')
60+
}
6561
}
6662

6763
task javadocJar(type: Jar) {
68-
from javadoc
69-
archiveClassifier.set('javadoc')
64+
from javadoc
65+
archiveClassifier.set('javadoc')
7066
}
7167

7268
task sourcesJar(type: Jar) {
73-
archiveClassifier.set('sources')
74-
from sourceSets.main.allSource
75-
duplicatesStrategy = DuplicatesStrategy.INCLUDE
69+
archiveClassifier.set('sources')
70+
from sourceSets.main.allSource
71+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
7672
}
7773

7874
java {
79-
withSourcesJar()
80-
withJavadocJar()
75+
withSourcesJar()
76+
withJavadocJar()
8177
}
8278

8379
def generated_dir = "build/generated/sources/xjc/java"
8480
sourceSets {
85-
main {
86-
java.srcDirs += generated_dir
87-
}
81+
main {
82+
java.srcDirs += generated_dir
83+
}
8884
}
8985

90-
9186
group = 'io.github.borewit'
9287
version = '4.1.2'
9388
description = 'Lizzy'
9489
java.sourceCompatibility = JavaVersion.VERSION_1_9
9590

9691
publishing {
97-
publications {
98-
99-
mavenJava(MavenPublication) {
100-
from(components.java)
101-
pom {
102-
name = 'Lizzy'
103-
description = 'Multimedia playlist parser, supporting a wide range of playlist file formats.'
104-
url = 'https://github.com/Borewit/lizzy'
105-
licenses {
106-
license {
107-
name = 'MIT'
108-
url = 'https://github.com/Borewit/lizzy/blob/main/LICENSE.txt'
109-
}
110-
}
111-
developers {
112-
developer {
113-
id = 'Borewit'
114-
name = 'Borewit'
115-
timezone = 'Europe/Amsterdam'
116-
url = 'https://github.com/Borewit'
117-
}
118-
}
119-
contributors {
120-
contributor {
121-
name = 'Borewit'
122-
timezone = 'Europe/Amsterdam'
123-
url = 'https://github.com/Borewit'
124-
}
125-
contributor {
126-
name = 'Christophe Delory'
127-
}
128-
}
129-
scm {
130-
connection = 'scm:git:https://github.com/Borewit/lizzy.git'
131-
url = 'https://github.com/Borewit/lizzy'
132-
}
133-
}
92+
publications {
93+
mavenJava(MavenPublication) {
94+
from(components.java)
95+
artifactId = 'lizzy'
96+
97+
pom {
98+
name = 'Lizzy'
99+
description = 'Multimedia playlist parser, supporting a wide range of playlist file formats.'
100+
url = 'https://github.com/Borewit/lizzy'
101+
packaging = 'jar'
102+
licenses {
103+
license {
104+
name = 'MIT'
105+
url = 'https://github.com/Borewit/lizzy/blob/main/LICENSE.txt'
106+
}
134107
}
135-
}
136-
repositories {
137-
maven {
138-
name = "OSSRH"
139-
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/'
140-
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
141-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
142-
143-
credentials {
144-
username = ossrhUsername
145-
password = ossrhPassword
146-
}
108+
developers {
109+
developer {
110+
id = 'Borewit'
111+
name = 'Borewit'
112+
timezone = 'Europe/Amsterdam'
113+
url = 'https://github.com/Borewit'
114+
}
147115
}
116+
contributors {
117+
contributor {
118+
name = 'Borewit'
119+
timezone = 'Europe/Amsterdam'
120+
url = 'https://github.com/Borewit'
121+
}
122+
}
123+
scm {
124+
connection = 'scm:git:https://github.com/Borewit/lizzy.git'
125+
url = 'https://github.com/Borewit/lizzy'
126+
}
127+
}
128+
}
129+
}
130+
repositories {
131+
maven {
132+
name = "OSSRH"
133+
def releasesRepoUrl = 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
134+
def snapshotsRepoUrl = 'https://central.sonatype.com/repository/maven-snapshots/'
135+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
136+
137+
credentials {
138+
username = findProperty('ossrhUsername') ?: ""
139+
password = findProperty('ossrhPassword') ?: ""
140+
}
148141
}
142+
}
149143
}
150144

151145
task checkStyle(type: DefaultTask, dependsOn: [checkstyleMain, checkstyleTest]) {
152-
group = 'verification'
146+
group = 'verification'
153147
}
154148

155149
signing {
156-
useGpgCmd()
157-
sign publishing.publications.mavenJava
150+
useGpgCmd()
151+
sign publishing.publications.mavenJava
158152
}
159153

160154
tasks.withType(Test).configureEach {
161-
useJUnitPlatform()
155+
useJUnitPlatform()
162156
}
163157

164158
javadoc {
165-
options.addBooleanOption("Xdoclint:none", true)
166-
options.addStringOption("Xmaxwarns", "1")
159+
options.addBooleanOption("Xdoclint:none", true)
160+
options.addStringOption("Xmaxwarns", "1")
167161
}
168162

169163
task checkJavaSources(type: SourceTask) {
170-
source 'src/main/java'
164+
source 'src/main/java'
171165
}
172166

173-
// Prevent generated Java sources are checked
167+
// Prevent generated Java sources from being checkstyled
174168
tasks.checkstyleMain.source = fileTree(dir: 'src/main/java').include('**/*.java')
175169

176-
177-
// Cookie cutter function for defining multiple XJC tasks
170+
// JAXB XJC generation tasks
178171
def addXjcTask(taskName, schema, binding, dest) {
172+
file(dest).mkdirs()
179173

180-
// If you haven't already, create the generated output dir before running XJC or it will fail
181-
file(dest).mkdirs()
182-
183-
// The main XJC task, calls XJCFacade which is the entry point of the XJC JAR
184-
tasks.create(name: taskName, type: JavaExec) {
185-
group = 'xjc'
186-
classpath configurations.jaxb
187-
mainClass = 'com.sun.tools.xjc.XJCFacade'
188-
189-
// To explore available args, download the XJC JAR and run java -jar jaxb-xjc.jar --help
190-
// or see https://docs.oracle.com/javase/8/docs/technotes/tools/unix/xjc.html
191-
args "-extension", schema, "-b", binding, "-d", dest, "-no-header"
192-
193-
tasks.findByName('build').mustRunAfter 'clean'
194-
}
195-
}
196-
197-
addXjcTask("xjc-asx",
198-
"src/main/schema/asx/asx-3.0.xsd",
199-
"src/main/schema/asx/binding.xjb",
200-
"$generated_dir")
201-
202-
addXjcTask("xjc-atom",
203-
"src/main/schema/atom/atom.xsd",
204-
"src/main/schema/atom/binding.xjb",
205-
"$generated_dir")
206-
207-
addXjcTask("xjc-b4s",
208-
"src/main/schema/b4s/b4s.xsd",
209-
"src/main/schema/b4s/binding.xjb",
210-
"$generated_dir")
211-
212-
addXjcTask("xjc-rmp",
213-
"src/main/schema/rmp/rmp.xsd",
214-
"src/main/schema/rmp/binding.xjb",
215-
"$generated_dir")
216-
217-
addXjcTask("xjc-rss",
218-
"src/main/schema/rss/rss-2.0.xsd",
219-
"src/main/schema/rss/binding.xjb",
220-
"$generated_dir")
221-
222-
addXjcTask("xjc-smil",
223-
"src/main/schema/smil20/smil20.xsd",
224-
"src/main/schema/smil20/binding.xjb",
225-
"$generated_dir")
226-
227-
addXjcTask("xjc-xspf",
228-
"src/main/schema/xspf/xspf-1_0.2.xsd",
229-
"src/main/schema/xspf/binding.xjb",
230-
"$generated_dir")
231-
232-
task xjc(type: GradleBuild) {
174+
tasks.create(name: taskName, type: JavaExec) {
233175
group = 'xjc'
234-
tasks = ['xjc-asx', 'xjc-atom', 'xjc-b4s', 'xjc-b4s', 'xjc-rmp', 'xjc-rss', 'xjc-smil', 'xjc-xspf']
176+
classpath configurations.jaxb
177+
mainClass = 'com.sun.tools.xjc.XJCFacade'
178+
args "-extension", schema, "-b", binding, "-d", dest, "-no-header"
179+
tasks.findByName('build').mustRunAfter 'clean'
180+
}
181+
}
182+
183+
addXjcTask("xjc-asx", "src/main/schema/asx/asx-3.0.xsd", "src/main/schema/asx/binding.xjb", "$generated_dir")
184+
addXjcTask("xjc-atom", "src/main/schema/atom/atom.xsd", "src/main/schema/atom/binding.xjb", "$generated_dir")
185+
addXjcTask("xjc-b4s", "src/main/schema/b4s/b4s.xsd", "src/main/schema/b4s/binding.xjb", "$generated_dir")
186+
addXjcTask("xjc-rmp", "src/main/schema/rmp/rmp.xsd", "src/main/schema/rmp/binding.xjb", "$generated_dir")
187+
addXjcTask("xjc-rss", "src/main/schema/rss/rss-2.0.xsd", "src/main/schema/rss/binding.xjb", "$generated_dir")
188+
addXjcTask("xjc-smil", "src/main/schema/smil20/smil20.xsd", "src/main/schema/smil20/binding.xjb", "$generated_dir")
189+
addXjcTask("xjc-xspf", "src/main/schema/xspf/xspf-1_0.2.xsd", "src/main/schema/xspf/binding.xjb", "$generated_dir")
190+
191+
task xjc {
192+
group = 'xjc'
193+
dependsOn 'xjc-asx', 'xjc-atom', 'xjc-b4s', 'xjc-rmp', 'xjc-rss', 'xjc-smil', 'xjc-xspf'
235194
}
236195

237196
tasks.compileJava.dependsOn(tasks.xjc)

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Overide this settings in ~/.gradle/gradle.properties
2-
ossrhUsername = ''
3-
ossrhPassword = ''
2+
mavenCentralUsername = ''
3+
mavenCentralPassword = ''
44

55
# Read .java files as UTF-8
66
org.gradle.jvmargs = -Dfile.encoding=UTF-8

0 commit comments

Comments
 (0)