11plugins {
2- id ' java'
3- id ' org.jetbrains.kotlin.jvm' version ' 1.4.32 '
2+ id ' java-library '
3+ id ' org.jetbrains.kotlin.jvm' version ' 2.3.0 '
44 id ' maven-publish'
55 id ' signing'
66}
77
8- group ' org.dxworks.utils'
9- version ' 1.0.0'
8+ group = ' org.dxworks.utils'
9+ version = ' 1.0.0'
1010ext. isReleaseVersion = ! version. endsWith(" SNAPSHOT" )
1111
1212repositories {
1313 mavenCentral()
1414}
1515
16+ java {
17+ withSourcesJar()
18+ withJavadocJar()
19+ }
20+
1621dependencies {
22+ implementation platform(" org.jetbrains.kotlin:kotlin-bom:2.3.0" )
1723 implementation " org.jetbrains.kotlin:kotlin-stdlib"
24+
1825 testImplementation " org.junit.jupiter:junit-jupiter:5.7.0"
1926 testRuntimeOnly " org.junit.jupiter:junit-jupiter-engine:5.7.0"
2027}
@@ -23,37 +30,14 @@ test {
2330 useJUnitPlatform()
2431}
2532
26- tasks. withType(GenerateModuleMetadata ) {
33+ tasks. withType(GenerateModuleMetadata ). configureEach {
2734 enabled = false
2835}
2936
30- tasks. withType(Sign ) {
37+ tasks. withType(Sign ). configureEach {
3138 onlyIf { isReleaseVersion && findProperty(" signingKey" ) != null }
3239}
3340
34- task sourceJar (type : Jar ) {
35- classifier " sources"
36- from sourceSets. main. allJava
37- }
38-
39- task javadocJar (type : Jar , dependsOn : javadoc) {
40- classifier " javadoc"
41- from javadoc. destinationDir
42- }
43-
44- artifacts {
45- archives jar
46- archives sourceJar
47- archives javadocJar
48- }
49-
50- signing {
51- def signingKey = findProperty(" signingKey" )
52- def signingPassword = findProperty(" signingPassword" )
53- useInMemoryPgpKeys(signingKey, signingPassword)
54- sign configurations. archives
55- }
56-
5741publishing {
5842 repositories {
5943 maven {
@@ -62,100 +46,44 @@ publishing {
6246 def snapshotsRepoUrl = " https://s01.oss.sonatype.org/content/repositories/snapshots/"
6347 url = version. endsWith(' SNAPSHOT' ) ? snapshotsRepoUrl : releasesRepoUrl
6448 credentials {
65- username = project. findProperty(" ossrh.user" ) as String ?: System . getenv(" MAVEN_USERNAME" )
66- password = project. findProperty(" ossrh.password" ) as String ?: System . getenv(" MAVEN_PASSWORD" )
49+ username = ( project. findProperty(" ossrh.user" ) as String ) ?: System . getenv(" MAVEN_USERNAME" )
50+ password = ( project. findProperty(" ossrh.password" ) as String ) ?: System . getenv(" MAVEN_PASSWORD" )
6751 }
6852 }
6953 }
54+
7055 publications {
7156 mavenJava(MavenPublication ) {
57+ from components. java
58+
7259 pom {
7360 name = ' Argumenthor'
7461 description = ' A library to help parse arguments from multiple, configurable sources'
7562 url = ' https://dxworks.github.io/argumenthor'
63+
7664 licenses {
7765 license {
7866 name = ' The Apache License, Version 2.0'
7967 url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
8068 }
8169 }
8270 developers {
83- developer {
84- name = ' Darius Nagy'
85- }
86- developer {
87- name = ' Mario Rivis'
88- }
71+ developer { name = ' Darius Nagy' }
72+ developer { name = ' Mario Rivis' }
8973 }
9074 scm {
9175 connection = ' scm:git:git://gitub.com/dxworks/argumenthor.git'
9276 developerConnection = ' scm:git:ssh://gitub.com:dxworks/argumenthor.git'
9377 url = ' http://gitub.com/dxworks/argumenthor'
9478 }
9579 }
96-
97- from components. java
98-
99- pom. withXml {
100- def pomFile = file(" ${ project.buildDir} /generated-pom.xml" )
101- writeTo(pomFile)
102- def pomAscFile = signing. sign(pomFile). signatureFiles[0 ]
103- artifact(pomAscFile) {
104- classifier = null
105- extension = ' pom.asc'
106- }
107- }
108-
109- artifact(sourceJar) {
110- classifier = ' sources'
111- }
112- artifact(javadocJar) {
113- classifier = ' javadoc'
114- }
115-
116- // create the signed artifacts
117- project. tasks. signArchives. signatureFiles. each {
118- artifact(it) {
119- def matcher = it. file =~ / -(sources|javadoc)\. jar\. asc$/
120- if (matcher. find()) {
121- classifier = matcher. group(1 )
122- } else {
123- classifier = null
124- }
125- extension = ' jar.asc'
126- }
127- }
12880 }
12981 }
13082}
13183
132- def customizePom (pom ) {
133- pom. withXml {
134- def root = asNode()
135-
136- // eliminate test-scoped dependencies (no need in maven central POMs)
137- root. dependencies. removeAll { dep ->
138- dep. scope == " test"
139- }
140-
141- // add all items necessary for maven central publication
142- root. children(). last() + {
143- resolveStrategy = Closure . DELEGATE_FIRST
144-
145-
146- }
147- }
148- }
149-
150-
151- model {
152- tasks. generatePomFileForMavenJavaPublication {
153- destination = file(" $buildDir /generated-pom.xml" )
154- }
155- tasks. publishMavenJavaPublicationToMavenLocal {
156- dependsOn project. tasks. signArchives
157- }
158- tasks. publishMavenJavaPublicationToOssrhRepository {
159- dependsOn project. tasks. signArchives
160- }
84+ signing {
85+ def signingKey = findProperty(" signingKey" )
86+ def signingPassword = findProperty(" signingPassword" )
87+ useInMemoryPgpKeys(signingKey, signingPassword)
88+ sign publishing. publications. mavenJava
16189}
0 commit comments