Skip to content

Commit 0674c79

Browse files
committed
Begin work on making publishable
1 parent 07ea4bf commit 0674c79

File tree

7 files changed

+146
-30
lines changed

7 files changed

+146
-30
lines changed

build.gradle

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,57 @@ plugins {
33
alias libs.plugins.managedversioning
44
alias libs.plugins.architectury.loom apply false
55
alias libs.plugins.registrationutils apply false
6+
alias libs.plugins.nexuspublish
67
}
78

89
managedVersioning {
910
versionFile.set rootProject.file('version.properties')
1011

1112
gitHubActions {
12-
13+
register('release') {
14+
prettyName = 'Release'
15+
workflowDispatch = true
16+
gradleJob {
17+
name = 'build'
18+
step {
19+
setupGitUser()
20+
}
21+
readOnly = false
22+
gradlew 'Tag Release', 'tagRelease'
23+
gradlew 'Build', 'build'
24+
step {
25+
run = 'git push && git push --tags'
26+
}
27+
recordVersion 'Record Version', 'version'
28+
}
29+
gradleJob {
30+
name.set 'publish'
31+
needs.add('build')
32+
readOnly = false
33+
gradlew 'Publish', 'publish', 'closeAndReleaseSonatypeStagingRepository'
34+
tag.set('${{needs.build.outputs.version}}')
35+
secrets 'GPG_SIGNING_KEY', 'GPG_KEY_PASSWORD', 'CENTRAL_MAVEN_USER', 'CENTRAL_MAVEN_PASSWORD'
36+
}
37+
}
1338
}
39+
40+
apply()
1441
}
1542

1643
managedVersioning.apply()
1744

1845
println "Building: $version"
1946

47+
nexusPublishing {
48+
repositories {
49+
sonatype {
50+
nexusUrl = uri('https://s01.oss.sonatype.org/service/local/')
51+
username = System.getenv('CENTRAL_MAVEN_USER') ?: ''
52+
password = System.getenv('CENTRAL_MAVEN_PASSWORD') ?: ''
53+
}
54+
}
55+
}
56+
2057
configurations {
2158
license {
2259
canBeResolved = false

buildSrc/src/main/groovy/convention.shared.gradle

Lines changed: 78 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'java-library'
33
id 'groovy'
44
id 'maven-publish'
5+
id 'signing'
56
}
67

78
version = rootProject.version
@@ -57,6 +58,7 @@ configurations {
5758
compileOnlyApi.extendsFrom sharedCompileOnly
5859
}
5960

61+
6062
dependencies {
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+
81107
tasks.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+
}

common/src/main/resources/mods.groovy

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,36 @@ MultiplatformModsDotGroovy.make {
66
issueTrackerUrl = 'https://github.com/GroovyMC/CommonGroovyLibrary/issues'
77

88
mod {
9-
modId = buildProperties['mod_id']
10-
displayName = buildProperties['mod_name']
11-
version = buildProperties['version']
9+
modId = buildProperties.mod_id
10+
displayName = buildProperties.mod_name
11+
version = environmentInfo.version
12+
1213
displayUrl = 'https://github.com/GroovyMC/CommonGroovyLibrary'
1314

1415
description = "A library for common easy Groovy mod development."
15-
author = buildProperties['mod_author']
16+
author = buildProperties.mod_author
1617

1718
dependencies {
18-
minecraft = ">=${buildProperties['minecraftVersion']}"
19+
minecraft = ">=${environmentInfo.minecraftVersion}"
1920

20-
onForge {
21+
onNeoForge {
2122
mod('neoforge') {
22-
versionRange = ">=${buildProperties['platformVersion']}"
23+
versionRange = ">=${environmentInfo.platformVersion}"
2324
}
2425
mod('gml') {
25-
versionRange = ">=${buildProperties['gml_version']}"
26+
versionRange = ">=${libs.versions.gml}"
2627
}
2728
}
2829

2930
onFabric {
3031
mod('groovyduvet_core') {
31-
versionRange = ">=${buildProperties['groovyduvet_core_version']}"
32+
versionRange = ">=${libs.versions.groovyduvet}"
33+
}
34+
mod('fabricloader') {
35+
versionRange = ">=${environmentInfo.platformVersion}"
3236
}
33-
mod('fabric_loader') {
34-
versionRange = ">=${buildProperties['platformVersion']}"
37+
mod('fabric-api') {
38+
versionRange = ">=${libs.versions.fabric_api}"
3539
}
3640
}
3741
}

fabric/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ modsDotGroovy {
1616
apply()
1717
}
1818

19+
tasks.named('gatherFabricPlatformDetails', AbstractGatherPlatformDetailsTask).configure {
20+
minecraftVersion = libs.versions.minecraft.get()
21+
platformVersion = libs.versions.fabric.loader.get()
22+
}
23+
1924
loom {
2025
createRemapConfigurations(sourceSets.transform)
2126
createRemapConfigurations(sourceSets.extension)
@@ -29,11 +34,6 @@ registrationUtils {
2934
}
3035
}
3136

32-
tasks.named('gatherFabricPlatformDetails', AbstractGatherPlatformDetailsTask).configure {
33-
minecraftVersion = libs.versions.minecraft.get()
34-
platformVersion = libs.versions.fabric.loader.get()
35-
}
36-
3737
dependencies {
3838
mappings loom.layered() {
3939
officialMojangMappings()

gradle/libs.versions.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ neoforge = "20.4.167"
88
fabric_loader = "0.15.3"
99
fabric_api = "0.92.0+1.20.4"
1010

11-
mdg = "2.0.0-beta.10"
11+
mdg = "2.0.0-beta.14"
1212
autoservice = "1.1.1"
13+
nexuspublish = "2.0.0-rc-1"
1314

1415
architectury_loom = "1.4.373"
1516

1617
jetbrains_annotations = "24.1.0"
1718

1819
managedversioning = "1.2.8"
19-
registrationutils = "1.20.2-0.1.1"
20+
registrationutils = "1.20.2-0.1.2"
2021
enhancedgroovy = "0.2.0"
2122

2223
groovybundler = "2.1.1"
@@ -54,4 +55,5 @@ managedversioning = { id = "dev.lukebemish.managedversioning", version.ref = "ma
5455
mdg = { id = "org.groovymc.modsdotgroovy", version.ref = "mdg" }
5556
architectury_loom = { id = "dev.architectury.loom", version.ref = "architectury_loom" }
5657
registrationutils = { id = "com.matyrobbrt.mc.registrationutils", version.ref = "registrationutils" }
58+
nexuspublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexuspublish" }
5759

neoforge/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ modsDotGroovy {
1616
apply()
1717
}
1818

19+
tasks.named('gatherNeoForgePlatformDetails', AbstractGatherPlatformDetailsTask).configure {
20+
minecraftVersion = libs.versions.minecraft.get()
21+
platformVersion = libs.versions.neoforge.get()
22+
}
23+
1924
registrationUtils {
2025
projects {
2126
neoforge {
@@ -24,11 +29,6 @@ registrationUtils {
2429
}
2530
}
2631

27-
tasks.named('gatherNeoForgePlatformDetails', AbstractGatherPlatformDetailsTask).configure {
28-
minecraftVersion = libs.versions.minecraft.get()
29-
platformVersion = libs.versions.neoforge.get()
30-
}
31-
3232
repositories {
3333
maven {
3434
name = 'NeoForged'

version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=1.0.0
1+
version=0.4.0

0 commit comments

Comments
 (0)