Skip to content

Commit 16c55d9

Browse files
fix: gradle snapshot publishing
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent 496221a commit 16c55d9

1 file changed

Lines changed: 63 additions & 38 deletions

File tree

build.gradle

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def getVersion = { boolean considerSnapshot ->
7373
// for publishing a release, call Gradle with Environment Variable RELEASE:
7474
// RELEASE=true gradle JSQLParser:publish
7575
version = getVersion( !System.getenv("RELEASE") )
76-
group = 'com.manticore-projects.jsqlformatter'
76+
group = 'com.github.jsqlparser'
7777
description = 'JSQLParser library'
7878

7979
tasks.register('generateBuildInfo') {
@@ -591,56 +591,81 @@ publish {
591591
dependsOn(check, gitChangelogTask, renderRR, xslt, xmldoc)
592592
}
593593

594-
mavenPublishing {
595-
publishToMavenCentral(true)
596-
signAllPublications()
594+
publishing {
595+
publications {
596+
mavenJava(MavenPublication) {
597+
artifactId = 'jsqlparser'
597598

598-
coordinates(group, "jsqlparser", version)
599+
from components.java
599600

600-
pom {
601-
name.set('JSQLParser library')
602-
description.set('Parse SQL Statements into Abstract Syntax Trees (AST)')
603-
url.set('https://github.com/JSQLParser/JSqlParser')
604-
605-
licenses {
606-
license {
607-
name.set('GNU Library or Lesser General Public License (LGPL) V2.1')
608-
url.set('http://www.gnu.org/licenses/lgpl-2.1.html')
609-
}
610-
license {
611-
name.set('The Apache Software License, Version 2.0')
612-
url.set('http://www.apache.org/licenses/LICENSE-2.0.txt')
601+
versionMapping {
602+
usage('java-api') {
603+
fromResolutionOf('runtimeClasspath')
604+
}
605+
usage('java-runtime') {
606+
fromResolutionResult()
607+
}
613608
}
614-
}
615609

616-
developers {
617-
developer {
618-
id.set('twa')
619-
name.set('Tobias Warneke')
620-
email.set('t.warneke@gmx.net')
621-
}
622-
developer {
623-
id.set('are')
624-
name.set('Andreas Reichel')
625-
email.set('andreas@manticore-projects.com')
610+
pom {
611+
name.set('JSQLParser library')
612+
description.set('Parse SQL Statements into Abstract Syntax Trees (AST)')
613+
url.set('https://github.com/JSQLParser/JSqlParser')
614+
615+
licenses {
616+
license {
617+
name.set('GNU Library or Lesser General Public License (LGPL) V2.1')
618+
url.set('http://www.gnu.org/licenses/lgpl-2.1.html')
619+
}
620+
license {
621+
name.set('The Apache Software License, Version 2.0')
622+
url.set('http://www.apache.org/licenses/LICENSE-2.0.txt')
623+
}
624+
}
625+
626+
developers {
627+
developer {
628+
id.set('twa')
629+
name.set('Tobias Warneke')
630+
email.set('t.warneke@gmx.net')
631+
}
632+
developer {
633+
id.set('are')
634+
name.set('Andreas Reichel')
635+
email.set('andreas@manticore-projects.com')
636+
}
637+
}
638+
639+
scm {
640+
connection.set('scm:git:https://github.com/JSQLParser/JSqlParser.git')
641+
developerConnection.set('scm:git:ssh://git@github.com:JSQLParser/JSqlParser.git')
642+
url.set('https://github.com/JSQLParser/JSqlParser.git')
643+
}
626644
}
627645
}
646+
}
628647

629-
scm {
630-
connection.set('scm:git:https://github.com/JSQLParser/JSqlParser.git')
631-
developerConnection.set('scm:git:ssh://git@github.com:JSQLParser/JSqlParser.git')
632-
url.set('https://github.com/JSQLParser/JSqlParser.git')
648+
repositories {
649+
maven {
650+
name = "ossrh"
651+
def releasesRepoUrl = "https://central.sonatype.com/repository/maven-releases"
652+
def snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/"
653+
url(version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl)
654+
655+
credentials {
656+
username = providers.environmentVariable("ossrhUsername").orNull
657+
password = providers.environmentVariable("ossrhPassword").orNull
658+
}
633659
}
634660
}
635661
}
636662

637-
// Fix signing task dependencies
638-
tasks.withType(AbstractPublishToMaven).configureEach {
639-
dependsOn(tasks.withType(Sign))
640-
}
641663

642664
signing {
643-
required { !version.endsWith("SNAPSHOT") && gradle.taskGraph.hasTask("publish") }
665+
// don't sign SNAPSHOTS
666+
if (!version.endsWith('SNAPSHOT')) {
667+
sign publishing.publications.mavenJava
668+
}
644669
}
645670

646671
tasks.withType(JavaCompile).configureEach {

0 commit comments

Comments
 (0)