Skip to content

Commit bcc7a98

Browse files
authored
Switch from gradle maven plugin to the maven-publish plugin. (#720)
Since `maven` plugin was deprecated and removed since gradle 7.0+
1 parent ba5becc commit bcc7a98

File tree

2 files changed

+50
-54
lines changed

2 files changed

+50
-54
lines changed

build.gradle

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ group = 'com.linecorp.bot'
5050
version = '4.8.0'
5151

5252
//set build variables based on build type (release, continuous integration, development)
53-
def isDevBuild
5453
def isReleaseBuild
5554
def sonatypeRepositoryUrl
5655
if (hasProperty('release')) {
@@ -60,8 +59,8 @@ if (hasProperty('release')) {
6059
version += '-SNAPSHOT'
6160
sonatypeRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
6261
} else {
63-
isDevBuild = true
6462
version += '-SNAPSHOT'
63+
sonatypeRepositoryUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
6564
}
6665

6766
allprojects {
@@ -257,60 +256,66 @@ task codeCoverageReport(type: JacocoReport) {
257256
project(projectName) { project ->
258257
apply plugin: 'jacoco'
259258
apply plugin: 'signing'
260-
apply plugin: 'maven'
259+
apply plugin: 'maven-publish'
261260

262-
signing {
263-
required { isReleaseBuild }
264-
sign configurations.archives
261+
java {
262+
withJavadocJar()
263+
withSourcesJar()
265264
}
266265

267-
uploadArchives {
268-
repositories {
269-
if (isDevBuild) {
270-
mavenLocal()
271-
} else {
272-
mavenDeployer {
273-
if (isReleaseBuild) {
274-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
266+
publishing {
267+
publications {
268+
mavenJava(MavenPublication) {
269+
from components.java
270+
271+
pom {
272+
name = project.name
273+
packaging = 'jar'
274+
description = project.description
275+
url = 'https://github.com/line/line-bot-sdk-java'
276+
277+
scm {
278+
url = 'scm:[email protected]:line/line-bot-sdk-java.git'
279+
connection = 'scm:[email protected]:line/line-bot-sdk-java.git'
280+
developerConnection = 'scm:[email protected]:line/line-bot-sdk-java.git'
275281
}
276-
277-
repository(url: sonatypeRepositoryUrl) {
278-
authentication(userName: sonatypeUsername, password: sonatypePassword)
279-
}
280-
281-
pom.project {
282-
name project.name
283-
packaging 'jar'
284-
description project.description
285-
url 'https://github.com/line/line-bot-sdk-java'
286-
287-
scm {
288-
url 'scm:[email protected]:line/line-bot-sdk-java.git'
289-
connection 'scm:[email protected]:line/line-bot-sdk-java.git'
290-
developerConnection 'scm:[email protected]:line/line-bot-sdk-java.git'
282+
licenses {
283+
license {
284+
name = 'Apache'
285+
url = 'https://opensource.org/licenses/Apache-2.0'
291286
}
292-
licenses {
293-
license {
294-
name 'Apache'
295-
url 'https://opensource.org/licenses/Apache-2.0'
296-
}
287+
}
288+
developers {
289+
developer {
290+
id = 'tokuhirom'
291+
name = 'Tokuhiro Matsuno'
292+
297293
}
298-
developers {
299-
developer {
300-
id 'tokuhirom'
301-
name 'Tokuhiro Matsuno'
302-
303-
}
304-
developer {
305-
id 'kazuki-ma'
306-
name 'Kazuki MATSUDA'
307-
308-
}
294+
developer {
295+
id = 'kazuki-ma'
296+
name = 'Kazuki MATSUDA'
297+
309298
}
310299
}
311300
}
312301
}
313302
}
303+
repositories {
304+
maven {
305+
url sonatypeRepositoryUrl
306+
if (project.hasProperty("sonatypeUsername")) {
307+
credentials {
308+
username = "${sonatypeUsername}"
309+
password = "${sonatypePassword}"
310+
}
311+
}
312+
}
313+
}
314+
}
315+
316+
signing {
317+
required { isReleaseBuild }
318+
sign publishing.publications.mavenJava
314319
}
315320
}
316321
}

line-bot-cli/build.gradle

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,6 @@ bootJar {
3939
mainClass = 'com.linecorp.bot.cli.Application'
4040
}
4141

42-
// Reset bootRepackage dependency to remove dependency from bootRepackage to signArchives.
43-
// This causes circular dependency.
44-
//
45-
// Memo: By default, bootRepackage dependsOn the all tasks creating jar including signArchives task.
46-
// But signArchives should be after repackages.
47-
bootJar.dependsOn.clear()
48-
bootJar.dependsOn jar
49-
signArchives.dependsOn bootJar
50-
5142
// Add exec jar into archives to be uploaded.
5243
artifacts.add(
5344
'archives',

0 commit comments

Comments
 (0)