Skip to content

Commit 5912a4c

Browse files
committed
First version?
1 parent 738c277 commit 5912a4c

File tree

6 files changed

+204
-34
lines changed

6 files changed

+204
-34
lines changed

.github/workflows/_publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# REQUIRES DATAGEN TO BE CALLED IN A JOB BEFORE THIS!!
2+
3+
name: Publish
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
version:
9+
required: true
10+
type: string
11+
12+
jobs:
13+
publish:
14+
name: Publish Code as Github Package - ${{ inputs.version }}
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: true
21+
22+
- name: Set up JDK
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: temurin
26+
java-version: 17
27+
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@v4
30+
31+
- name: Publish
32+
run: ./gradlew :publish
33+
env:
34+
VERSION: ${{ inputs.version }}
35+
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci-builds.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Continuous Integration
2+
3+
env:
4+
GH_PKG_URL: "https://maven.pkg.github.com/${{ github.repository }}"
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
paths-ignore:
10+
- "README.md"
11+
- "LICENSE"
12+
- ".github/**/*"
13+
- "**/*.gradle.kts"
14+
- "**/gradle.properties"
15+
16+
jobs:
17+
vars:
18+
name: Get Variables
19+
runs-on: ubuntu-22.04
20+
outputs:
21+
version: ${{steps.version.outputs.version}}
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 150
28+
fetch-tags: true
29+
30+
- name: Version
31+
id: version
32+
uses: paulhatch/[email protected]
33+
with:
34+
version_format: "${major}.${minor}.${patch}"
35+
search_commit_body: true
36+
bump_each_commit: true
37+
38+
publish:
39+
needs: [vars]
40+
uses: ./.github/workflows/_publish.yml
41+
secrets: inherit
42+
with:
43+
version: ${{ needs.vars.outputs.version }}

buildSrc/src/main/java/dev/compactmachines/GanderConstants.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@ public interface GanderConstants {
1111
JvmVendorSpec JAVA_VENDOR = IS_CI ? JvmVendorSpec.ADOPTIUM : JvmVendorSpec.JETBRAINS;
1212

1313
String MINECRAFT_VERSION = "1.20.1";
14-
String MINECRAFT_VERSION_SHORT = MINECRAFT_VERSION.substring("1.".length());
1514

1615
String FORGE_VERSION = MINECRAFT_VERSION + "-47.3.12";
1716

1817
String PARCHMENT_VERSION = MINECRAFT_VERSION;
1918
String PARCHMENT_MAPPINGS = "2023.09.03";
20-
21-
String GROUP = "dev.compactmachines";
22-
String VERSION = MINECRAFT_VERSION_SHORT + ".0";
2319
}

buildSrc/src/main/kotlin/gander-convention.gradle.kts

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
import dev.compactmachines.GanderConstants
22
import org.slf4j.event.Level
33

4+
var envVersion: String = System.getenv("VERSION") ?: "9.9.9"
5+
if (envVersion.startsWith("v"))
6+
envVersion = envVersion.trimStart('v')
7+
48
plugins {
59
id("java-library")
610
id("idea")
711
id("org.jetbrains.gradle.plugin.idea-ext")
812
id("net.neoforged.moddev.legacyforge")
13+
id("maven-publish")
914
}
1015

1116
// main convention script which sets up a basic MDG workspace
1217
// pulling in version data from GanderConstants since version catalogs
1318
// from the main outer project are not accessible here
1419

15-
group = GanderConstants.GROUP
16-
version = GanderConstants.VERSION
17-
1820
base {
1921
archivesName = project.name
22+
group = "dev.compactmods.gander"
23+
version = envVersion
24+
2025
libsDirectory.convention(rootProject.layout.projectDirectory.dir("libs/${project.name}"))
2126
}
2227

@@ -61,31 +66,6 @@ neoForge {
6166
publish(atFile)
6267
}
6368
}
64-
65-
runs.configureEach {
66-
// set up basic common run config properties
67-
// due to using convention this can be override in each run config
68-
logLevel.convention(Level.DEBUG)
69-
sourceSet.convention(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
70-
loadedMods.convention(mods) // all registered mods
71-
gameDirectory.convention(type.map { layout.projectDirectory.dir("run/$it") })
72-
73-
// using '.map' adds args as a 'provider'
74-
// making them lazily evaluated later
75-
// when 'type' actually exists
76-
//
77-
// adds jbr jvm args only for client/server run types
78-
jvmArguments.addAll(type.map {
79-
if(GanderConstants.IS_CI || (it != "client" && it != "server"))
80-
return@map emptyList<String>()
81-
82-
return@map listOf(
83-
"-XX:+AllowEnhancedClassRedefinition",
84-
"-XX:+IgnoreUnrecognizedVMOptions",
85-
"-XX:+AllowRedefinitionToAddDeleteMethods"
86-
)
87-
})
88-
}
8969
}
9070

9171
tasks.jar {
@@ -97,7 +77,6 @@ dependencies {
9777
// does not affect runtime or production
9878
// safe to have at compile time with no issues
9979
compileOnly("org.jetbrains:annotations:26.0.1")
100-
10180
annotationProcessor("org.spongepowered:mixin:0.8.5:processor")
10281
}
10382

@@ -114,3 +93,21 @@ javaToolchains.compilerFor {
11493
languageVersion.convention(GanderConstants.JAVA_VERSION)
11594
vendor.convention(GanderConstants.JAVA_VENDOR)
11695
}
96+
97+
val PACKAGES_URL = System.getenv("GH_PKG_URL") ?: "https://maven.pkg.github.com/compactmods/gander"
98+
publishing {
99+
publications.register<MavenPublication>(project.name) {
100+
from(components.getByName("java"))
101+
}
102+
103+
repositories {
104+
// GitHub Packages
105+
maven(PACKAGES_URL) {
106+
name = "GitHubPackages"
107+
credentials {
108+
username = System.getenv("GITHUB_ACTOR")
109+
password = System.getenv("GITHUB_TOKEN")
110+
}
111+
}
112+
}
113+
}

core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
val isRelease: Boolean = (System.getenv("RELEASE") ?: "false").equals("true", true)
2+
13
plugins {
24
id("gander-convention")
35
}

testmod/build.gradle.kts

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
1+
import dev.compactmachines.GanderConstants
2+
import gradle.kotlin.dsl.accessors._53f21c2e2286c58eadab8fd2d7f5601a.*
3+
import org.slf4j.event.Level
4+
5+
var envVersion: String = System.getenv("VERSION") ?: "9.9.9"
6+
if (envVersion.startsWith("v"))
7+
envVersion = envVersion.trimStart('v')
8+
19
plugins {
2-
id("gander-convention")
10+
id("java-library")
11+
id("idea")
12+
id("org.jetbrains.gradle.plugin.idea-ext")
13+
id("net.neoforged.moddev.legacyforge")
14+
id("maven-publish")
15+
}
16+
17+
// main convention script which sets up a basic MDG workspace
18+
// pulling in version data from GanderConstants since version catalogs
19+
// from the main outer project are not accessible here
20+
21+
base {
22+
archivesName = project.name
23+
group = "dev.compactmods.gander"
24+
version = envVersion
25+
26+
libsDirectory.convention(rootProject.layout.projectDirectory.dir("libs/${project.name}"))
27+
}
28+
29+
javaToolchains.compilerFor {
30+
languageVersion.convention(GanderConstants.JAVA_VERSION)
31+
vendor.convention(GanderConstants.JAVA_VENDOR)
332
}
433

534
// sets up MDG workspace and includes all other gander modules
@@ -13,6 +42,27 @@ val gModules = listOf(
1342
gModules.map { it.path }.forEach(::evaluationDependsOn)
1443

1544
neoForge {
45+
version = GanderConstants.FORGE_VERSION
46+
// not currently usable since the AT included in legacy forge
47+
// does not itself validate, many unused/nonexistent AT entries exist in it
48+
// validateAccessTransformers.convention(true)
49+
50+
parchment {
51+
minecraftVersion = GanderConstants.PARCHMENT_VERSION
52+
mappingsVersion = GanderConstants.PARCHMENT_MAPPINGS
53+
}
54+
55+
// apply this modules AT file if it exists
56+
// also mark for publishing with maven publication
57+
val atFile = file("src/main/resources/META-INF/accesstransformer.cfg")
58+
59+
if(atFile.exists()) {
60+
accessTransformers {
61+
from(atFile)
62+
publish(atFile)
63+
}
64+
}
65+
1666
mods {
1767
create(SourceSet.MAIN_SOURCE_SET_NAME) {
1868
sourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
@@ -33,6 +83,31 @@ neoForge {
3383
}
3484

3585
runs {
86+
configureEach {
87+
// set up basic common run config properties
88+
// due to using convention this can be override in each run config
89+
logLevel = Level.DEBUG
90+
sourceSet = sourceSets[SourceSet.MAIN_SOURCE_SET_NAME]
91+
loadedMods = mods // all registered mod
92+
gameDirectory = type.map { layout.projectDirectory.dir("run/$it") }
93+
94+
// using '.map' adds args as a 'provider'
95+
// making them lazily evaluated later
96+
// when 'type' actually exists
97+
//
98+
// adds jbr jvm args only for client/server run types
99+
jvmArguments.addAll(type.map {
100+
if(GanderConstants.IS_CI || (it != "client" && it != "server"))
101+
return@map emptyList<String>()
102+
103+
return@map listOf(
104+
"-XX:+AllowEnhancedClassRedefinition",
105+
"-XX:+IgnoreUnrecognizedVMOptions",
106+
"-XX:+AllowRedefinitionToAddDeleteMethods"
107+
)
108+
})
109+
}
110+
36111
create("client") {
37112
client()
38113
}
@@ -61,3 +136,24 @@ mixin {
61136
config("gander_render.mixins.json")
62137
config("gander_levels.mixins.json")
63138
}
139+
140+
tasks.jar {
141+
manifest.from(file("src/main/resources/META-INF/MANIFEST.MF"))
142+
}
143+
144+
145+
dependencies {
146+
// not included with MDG currently
147+
// does not affect runtime or production
148+
// safe to have at compile time with no issues
149+
compileOnly("org.jetbrains:annotations:26.0.1")
150+
annotationProcessor("org.spongepowered:mixin:0.8.5:processor")
151+
}
152+
153+
tasks.withType<JavaCompile> {
154+
options.encoding = "UTF-8"
155+
156+
if(!GanderConstants.IS_CI) {
157+
options.compilerArgs.addAll(arrayOf("-Xmaxerrs", "9000"))
158+
}
159+
}

0 commit comments

Comments
 (0)