Skip to content

Commit 498fdb5

Browse files
committed
Compiled with ForgeGradle 5.1 and Gradle 7.1.1 in preparation for MC 1.17.1.
1 parent c577537 commit 498fdb5

File tree

9 files changed

+205
-26
lines changed

9 files changed

+205
-26
lines changed

Jenkinsfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ pipeline {
1010

1111
stages {
1212

13+
stage('Setup') {
14+
15+
steps {
16+
17+
echo 'Setup Project'
18+
sh 'chmod +x gradlew'
19+
sh './gradlew clean'
20+
}
21+
}
22+
1323
stage('Build') {
1424

1525
steps {
@@ -21,8 +31,7 @@ pipeline {
2131
]) {
2232

2333
echo 'Building project.'
24-
sh 'chmod +x gradlew'
25-
sh './gradlew clean build publish curseforge updateVersionTracker postTweet --stacktrace --warn'
34+
sh './gradlew build publish curseforge updateVersionTracker postTweet --stacktrace --warn'
2635
}
2736
}
2837
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ ext.mcVersion = getRequiredString('minecraft_version')
2121
apply from: 'gradle/build_number.gradle'
2222
apply from: 'gradle/git_changelog.gradle'
2323
apply from: 'gradle/patreon.gradle'
24-
apply from: 'gradle/common_manifest.gradle'
25-
apply from: 'gradle/common_artifacts.gradle'
24+
apply from: 'gradle/java.gradle'
2625
apply from: 'gradle/forge.gradle'
26+
apply from: 'gradle/dependencies.gradle'
2727
apply from: 'gradle/minify_jsons.gradle'
2828

2929
// Load publishing modules

gradle.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ forge_version=36.2.2
1616
forge_at=src/main/resources/META-INF/accesstransformer.cfg
1717

1818
# CurseForge properties (gradle/curseforge.gradle)
19-
curse_project=228525
19+
curse_project=228525
20+
21+
# Dependencies (gradle/dependencies.gradle)
22+
dependencies_compile_enabled=false
23+
dependencies_runtime_enabled=false

gradle/common_artifacts.gradle

Lines changed: 0 additions & 19 deletions
This file was deleted.

gradle/curseforge.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ curseforge {
9292
addGameVersion version
9393
}
9494
}
95+
96+
else {
97+
98+
addGameVersion project.ext.mcVersion
99+
addGameVersion 'Forge'
100+
addGameVersion 'Java 16'
101+
}
95102

96103
mainArtifact(jar) {
97104

gradle/dependencies.gradle

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
apply from: 'gradle/property_helper.gradle'
2+
3+
repositories {
4+
5+
// This maven repository hosts files for hundreds of mods. Some notable
6+
// mods include Bookshelf, Botania, BotanyPots, CraftTweaker, DarkUtils,
7+
// GameStages, Patchouli, Psi, and Quark.
8+
maven {
9+
10+
url 'https://maven.blamejared.com'
11+
}
12+
13+
// This maven repository hosts files for dozens of mods. Some notable
14+
// mods include JEI, TinkersConstruct, and ChiselAndBits.
15+
maven {
16+
17+
url 'https://dvs1.progwml6.com/files/maven'
18+
}
19+
20+
// This maven repository hosts files for mods by TheIllusiveC4. This
21+
// includes Curios, Caelus, and other APIs.
22+
maven {
23+
24+
url = 'https://maven.theillusivec4.top/'
25+
}
26+
27+
// This maven repository proxies requests to the CurseForge API. This will
28+
// allow mods without traditional mavens to be used in a dev environment.
29+
// They use the pattern curse.maven:<descriptor>-<projectid>:<fileid> for
30+
// maven coordinates.
31+
maven {
32+
33+
url = 'https://www.cursemaven.com'
34+
35+
// Improve performance by only querying for their specific group.
36+
content {
37+
38+
includeGroup 'curse.maven'
39+
}
40+
}
41+
}
42+
43+
dependencies {
44+
45+
// This section includes mods that are commonly compiled against. It is
46+
// recommended to add support for these mods if it makes sense for the
47+
// content of your mod.
48+
if (getDefaultBoolean('dependencies_compile_enabled')) {
49+
50+
}
51+
52+
// This section includes mods that are commonly used by players and meet a
53+
// minimum level of quality and performance. These mods are only available
54+
// at runtime by default meaning you may not directly access their code.
55+
if (getDefaultBoolean('dependencies_runtime_enabled')) {
56+
57+
// Replaces the config GUI with a shiny new one. Mods can enable a
58+
// custom menu icon by defining additional properties in the mods.toml
59+
// file of their mod.
60+
deobfRuntime('catalogue', 'curse.maven', 'catalogue-459701', '3399552')
61+
62+
// Controlling overhauls the keybind menu by adding a search bar and
63+
// other QoL features.
64+
deobfRuntime('controlling', 'com.blamejared.controlling', 'Controlling', '8.0.0')
65+
}
66+
}
67+
68+
/**
69+
* Creates a deobfuscated compile dependency. These are available at compile
70+
* time and runtime. This means you can reference code from this dependency
71+
* in your mod.
72+
*
73+
* See deobfDep for more info.
74+
*/
75+
def deobfCompile(modid, defaultGroup, defaultName, defaultVersion) {
76+
77+
deobfDep(modid, 'implementation', defaultGroup, defaultName, defaultVersion)
78+
}
79+
80+
/**
81+
* Creates a deobfuscated runtime dependency. These are only available during
82+
* runtime and not compile time. This means the dependency will show up when
83+
* you run the game but you can not directly reference it's code in your mod.
84+
*
85+
* See deobfDep for more info.
86+
*/
87+
def deobfRuntime(modid, defaultGroup, defaultName, defaultVersion) {
88+
89+
deobfDep(modid, 'runtimeOnly', defaultGroup, defaultName, defaultVersion)
90+
}
91+
92+
/**
93+
* Creates a new deobfuscated project dependency that is configured using
94+
* properties. This allows for greater flexability and additional logging.
95+
*
96+
* | Property | Description | Example |
97+
* |---------------|---------------------------------------------------|-----------------------|
98+
* | modid_enabled | When set to false the dependency will be skipped. | true/false, y/n, 1/0 |
99+
* | modid_deptype | The type of dependency to create. | compile, runtimeOnly |
100+
* | modid_group | The maven group for the dependency. | net.darkhax.bookshelf |
101+
* | modid_name | The name of the dependency. | Bookshelf-1.16.5 |
102+
* | modid_version | The artefact version of the dependency. | 10.0.7 |
103+
*
104+
* @param modid An ID used in logging and the names of properties.
105+
* @param defaultType The default type of dependency to create.
106+
* @param defaultGroup The default group for the maven coordinate. modid_group
107+
* @param defaultName The default name for the maven coordinate. modid_name
108+
* @param defaultVersion the default version for the maven coordinate. modid_version
109+
*/
110+
def deobfDep(modid, defaultType, defaultGroup, defaultName, defaultVersion) {
111+
112+
if (getDefaultBoolean("${modid}_enabled")) {
113+
114+
def depType = getDefaultString("${modid}_deptype", defaultType)
115+
def group = getDefaultString("${modid}_group", defaultGroup)
116+
def name = getDefaultString("${modid}_name", defaultName)
117+
def version = getDefaultString("${modid}_version", defaultVersion)
118+
119+
project.logger.lifecycle("Dependency ${modid} added. ${depType} \'${group}:${name}:${version}\'")
120+
project.getDependencies().add(depType, fg.deobf("${group}:${name}:${version}"))
121+
}
122+
123+
else {
124+
125+
project.logger.warn("Dependency ${modid} has been disabled for this build.")
126+
}
127+
}
128+
129+
// Gradle introduced a new metadata format that will override data from other
130+
// formats like Maven. When publishing Forge mods this metadata will include
131+
// dependency entries for mapped versions of Forge and other mods used in the
132+
// userdev environment. Gradle will try and fail to resolve these dependencies.
133+
// The simplest fix is for those publishing artefacts to disable the publishing
134+
// of this metadata or to strip the mapped dependencies however we can not rely
135+
// on them to do that. This code will tell Gradle to ignore that metadata.
136+
project.repositories.each {
137+
138+
if (it.hasProperty('metadataSources')) {
139+
140+
it.metadataSources.ignoreGradleMetadataRedirection()
141+
}
142+
}
143+
144+
ext {
145+
146+
deobfDep = this.&deobDep
147+
deobfRuntime = this.&deobRuntime
148+
deobfCompile = this.&deobCompile
149+
}

gradle/forge.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def mappingVersion = getDefaultString('forge_mapping_version', project.ext.mcVer
4242
def remapRefmap = getDefaultBoolean('mixin_remap_refmap')
4343
def remapRefmapFile = getDefaultString('mixin_remap_refmap_file', "${projectDir}/build/createSrgToMcp/output.srg")
4444

45-
archivesBaseName = "${mod_name}-${minecraft_version}"
46-
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
45+
// Makes sure jar files are reobfuscated by Forge when built.
46+
jar.finalizedBy('reobfJar')
4747

4848
minecraft {
4949

gradle/common_manifest.gradle renamed to gradle/java.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
// Sets the name of files to ModName-Forge-MCVersion.
2+
archivesBaseName = "${mod_name}-Forge-${minecraft_version}"
3+
4+
java {
5+
6+
// Generate a sources JAR.
7+
withSourcesJar()
8+
9+
// Generate a JavaDoc JAR.
10+
withJavadocJar()
11+
12+
// Set minimum language version.
13+
toolchain.languageVersion = JavaLanguageVersion.of(8)
14+
}
15+
16+
javadoc {
17+
18+
// Supress annoying warnings when generating JavaDoc files.
19+
options.addStringOption('Xdoclint:none', '-quiet')
20+
}
21+
122
jar {
223
manifest {
324
attributes([

gradle/maven.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ def getMavenCoordinateStringCompact() {
7575
return "${project.group}:${project.name}:${project.version}"
7676
}
7777

78+
// Disables Gradle's custom module metadata from being published to maven. The
79+
// metadata includes mapped dependencies which are not reasonably consumable by
80+
// other mod developers.
81+
tasks.withType(GenerateModuleMetadata) {
82+
83+
enabled = false
84+
}
85+
7886
ext {
7987

8088
getMavenCoordinateString = this.&getMavenCoordinateString

0 commit comments

Comments
 (0)