Skip to content

Commit c96fbcf

Browse files
asolntsevclaude
andcommitted
upgrade Gradle from 6.6.1 to 9.6.1
Migrate from removed `maven` plugin to `maven-publish`. Replace `uploadArchives`/`mavenDeployer` with the `publishing` DSL block. Move sourceCompatibility into the `java` extension and use `configureEach` instead of deprecated `.all`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2413511 commit c96fbcf

3 files changed

Lines changed: 64 additions & 83 deletions

File tree

build.gradle

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
subprojects {
22
apply plugin: 'java'
3-
apply plugin: 'maven'
43

5-
group 'com.codeborne.assertlog'
6-
version '0.2-SNAPSHOT'
4+
group = 'com.codeborne.assertlog'
5+
version = '0.2-SNAPSHOT'
76

8-
sourceCompatibility = 1.8
9-
targetCompatibility = 1.8
7+
java {
8+
sourceCompatibility = JavaVersion.VERSION_1_8
9+
targetCompatibility = JavaVersion.VERSION_1_8
10+
}
1011

11-
[compileJava, compileTestJava]*.options.collect {options -> options.encoding = 'UTF-8'}
12-
[compileJava, compileTestJava]*.options.collect {options -> options.debug = true}
12+
tasks.withType(JavaCompile).configureEach {
13+
options.encoding = 'UTF-8'
14+
options.debug = true
15+
}
1316
compileJava.options.debugOptions.debugLevel = "source,lines,vars"
1417

1518
repositories {
1619
mavenCentral()
1720
}
1821

19-
tasks.withType(Test).all { testTask ->
20-
testTask.jvmArgs += ['-ea', '-Dfile.encoding=UTF-8']
21-
testTask.testLogging {exceptionFormat = 'full'}
22+
tasks.withType(Test).configureEach { testTask ->
23+
testTask.jvmArgs '-ea', '-Dfile.encoding=UTF-8'
24+
testTask.testLogging { exceptionFormat = 'full' }
2225
}
2326

2427
test {

gradle/deploy.gradle

Lines changed: 50 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
subprojects {
2+
apply plugin: 'maven-publish'
3+
24
jar {
35
from sourceSets.main.allSource
46

@@ -11,89 +13,65 @@ subprojects {
1113
}
1214
}
1315

14-
task sourcesJar(type: Jar, dependsOn: classes) {
15-
classifier = 'sources'
16-
from sourceSets.main.allSource
17-
}
18-
19-
javadoc {
20-
// failOnError = false
21-
source = sourceSets.main.allJava
22-
}
23-
24-
task javadocJar(type: Jar, dependsOn: javadoc) {
25-
classifier = 'javadoc'
26-
from javadoc.destinationDir
27-
}
28-
29-
artifacts {
30-
archives jar
31-
archives sourcesJar
32-
archives javadocJar
16+
java {
17+
withSourcesJar()
18+
withJavadocJar()
3319
}
3420

35-
if (project.hasProperty("signing.keyId")) {
36-
apply plugin: 'signing'
37-
38-
signing {
39-
sign configurations.archives
40-
}
41-
42-
uploadArchives {
43-
repositories {
44-
mavenDeployer {
45-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
46-
47-
repository(url: project.version.endsWith("-SNAPSHOT") ?
48-
'https://oss.sonatype.org/content/repositories/snapshots/' :
49-
'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
50-
authentication(userName: "$sonatypeUsername", password: "$sonatypePassword")
21+
publishing {
22+
publications {
23+
mavenJava(MavenPublication) {
24+
from components.java
25+
26+
pom {
27+
name = project.name
28+
packaging = 'jar'
29+
description = 'AssertLog: Unit-tests for your logging'
30+
url = 'https://github.com/java-testkit/assertlog'
31+
32+
scm {
33+
url = 'scm:git@github.com:java-testkit/assertlog.git'
34+
connection = 'scm:git@github.com:java-testkit/assertlog.git'
35+
developerConnection = 'scm:git@github.com:java-testkit/assertlog.git'
5136
}
5237

53-
pom.project {
54-
name archivesBaseName
55-
packaging 'jar'
56-
description 'AssertLog: Unit-tests for your logging'
57-
url 'https://github.com/java-testkit/assertlog'
58-
59-
scm {
60-
url 'scm:git@github.com:java-testkit/assertlog.git'
61-
connection 'scm:git@github.com:java-testkit/assertlog.git'
62-
developerConnection 'scm:git@github.com:java-testkit/assertlog.git'
63-
}
64-
65-
licenses {
66-
license {
67-
name 'MIT'
68-
url 'https://opensource.org/licenses/MIT'
69-
distribution 'repo'
70-
}
38+
licenses {
39+
license {
40+
name = 'MIT'
41+
url = 'https://opensource.org/licenses/MIT'
42+
distribution = 'repo'
7143
}
44+
}
7245

73-
developers {
74-
developer {
75-
id 'asolntsev'
76-
name 'Andrei Solntsev'
77-
}
46+
developers {
47+
developer {
48+
id = 'asolntsev'
49+
name = 'Andrei Solntsev'
7850
}
7951
}
52+
}
53+
}
54+
}
8055

81-
//mess with the generated pom to set the 'packaging' tag
82-
pom.withXml { XmlProvider xmlProvider ->
83-
def xml = xmlProvider.asString()
84-
def pomXml = new XmlParser().parse(new ByteArrayInputStream(xml.toString().bytes))
85-
86-
pomXml.version[0] + { packaging('jar') }
56+
repositories {
57+
maven {
58+
url = version.endsWith('-SNAPSHOT') ?
59+
'https://oss.sonatype.org/content/repositories/snapshots/' :
60+
'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
8761

88-
def newXml = new StringWriter()
89-
def printer = new XmlNodePrinter(new PrintWriter(newXml))
90-
printer.preserveWhitespace = true
91-
printer.print(pomXml)
92-
xml.setLength(0)
93-
xml.append(newXml.toString())
94-
}
62+
credentials {
63+
username = findProperty('sonatypeUsername') ?: ''
64+
password = findProperty('sonatypePassword') ?: ''
9565
}
9666
}
9767
}
9868
}
99-
}
69+
70+
if (project.hasProperty("signing.keyId")) {
71+
apply plugin: 'signing'
72+
73+
signing {
74+
sign publishing.publications.mavenJava
75+
}
76+
}
77+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)