@@ -2,6 +2,7 @@ plugins {
22 id ' java-library'
33 id ' groovy'
44 id ' maven-publish'
5+ id ' signing'
56}
67
78version = rootProject. version
@@ -57,6 +58,7 @@ configurations {
5758 compileOnlyApi. extendsFrom sharedCompileOnly
5859}
5960
61+
6062dependencies {
6163 allCompileOnly libs. jetbrains. annotations
6264 allCompileOnly libs. autoservice
@@ -69,15 +71,39 @@ dependencies {
6971 transformCompileOnly sourceSets. extension. output
7072}
7173
72- publishing {
73- publications {
74- register(' mavenJava' , MavenPublication ) {
75- artifactId base. archivesName. get()
76- from components. java
74+ tasks. named(' groovydoc' , Groovydoc ) {
75+ use = true
76+ }
77+
78+ tasks. register(' groovydocJar' , Jar ) {
79+ archiveClassifier = ' javadoc'
80+ from groovydoc. destinationDir
81+ dependsOn ' groovydoc'
82+ }
83+
84+ // Publish groovydoc as javadoc
85+ configurations {
86+ javadocElements {
87+ canBeConsumed = true
88+ canBeResolved = false
89+ attributes {
90+ attribute(Usage . USAGE_ATTRIBUTE , objects. named(Usage . class, Usage . JAVA_RUNTIME ))
91+ attribute(Category . CATEGORY_ATTRIBUTE , objects. named(Category . class, Category . DOCUMENTATION ))
92+ attribute(Bundling . BUNDLING_ATTRIBUTE , objects. named(Bundling . class, Bundling . EXTERNAL ))
93+ attribute(DocsType . DOCS_TYPE_ATTRIBUTE , objects. named(DocsType . class, DocsType . JAVADOC ))
7794 }
7895 }
7996}
8097
98+ project. components. named(" java" ). configure {
99+ AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants ) it
100+ javaComponent. addVariantsFromConfiguration(configurations. javadocElements) {}
101+ }
102+
103+ artifacts {
104+ javadocElements groovydocJar
105+ }
106+
81107tasks. withType(JavaCompile ). configureEach {
82108 it. options. encoding = ' UTF-8'
83109 it. options. release = 17
@@ -134,3 +160,50 @@ jar {
134160 ])
135161 }
136162}
163+
164+ final String signingKey = System . getenv(' GPG_SIGNING_KEY' ) ?: ' '
165+ final String signingPassword = System . getenv(' GPG_KEY_PASSWORD' ) ?: ' '
166+ final boolean hasSigningDetails = ! signingKey. isEmpty() && ! signingPassword. isEmpty()
167+
168+ publishing {
169+ publications {
170+ mavenJava(MavenPublication ) {
171+ artifactId base. archivesName. get()
172+ from components. java
173+ pom {
174+ name = " CommonGroovyLibrary - ${ project.name.capitalize()} " . toString()
175+ description = ' A library for common easy Groovy mod development'
176+ packaging = ' jar'
177+ url = ' https://github.com/groovymc/CommonGroovyLibrary'
178+ inceptionYear = ' 2022'
179+
180+ licenses {
181+ license {
182+ name = ' LGPL-3.0-or-later'
183+ url = ' https://spdx.org/licenses/LGPL-3.0-or-later'
184+ }
185+ }
186+ developers {
187+ developer {
188+ id = ' groovymc'
189+ name = ' GroovyMC'
190+ email = ' holdings@groovymc.org'
191+ url = ' https://github.com/GroovyMC/'
192+ }
193+ }
194+ scm {
195+ connection= ' scm:git:git://github.com/groovymc/CommonGroovyLibrary.git'
196+ developerConnection= ' scm:git:ssh://github.com/groovymc/CommonGroovyLibrary.git'
197+ url= ' https://github.com/groovymc/CommonGroovyLibrary'
198+ }
199+ }
200+ }
201+ }
202+ }
203+
204+ if (hasSigningDetails) {
205+ signing {
206+ useInMemoryPgpKeys(signingKey, signingPassword)
207+ sign publishing. publications. mavenJava
208+ }
209+ }
0 commit comments