Skip to content

Commit b254958

Browse files
committed
Upgrade to ForgeGradle 5.0
Upgrade to Gradle 7.5. Update BUILDING.md. Fix IntelliJ run configuration resources.
1 parent 31f0a20 commit b254958

File tree

8 files changed

+272
-151
lines changed

8 files changed

+272
-151
lines changed

BUILDING.md

+26-18
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ But we have some required steps that you need to follow to make things work.
99

1010
1. Having [git](http://git-scm.com/) and git-lfs installed
1111
2. Having an IDE (we do use [IntelliJ IDEA](https://www.jetbrains.com/idea/))
12-
3. Having [Lombok](http://projectlombok.org/) installed with your IDE (in
13-
IntelliJ IDEA there is a plugin for Lombok which requires annotation processing
14-
to be enabled)
15-
4. Having Java JDK 8, newer versions are not supported.
16-
5. [Discord](https://discord.gg/6vPP3A8) wouldn't be bad if you want to communicate with other
12+
3. Having Java Development Kit 8; newer versions are not supported by this
13+
Minecraft or Minecraft Forge version.
14+
4. Matrix/Discord wouldn't be bad if you want to communicate with other
1715
contributors and us.
1816

1917

2018
## Matrix
2119

22-
[Dev Channel](https://matrix.to/#/#logisticspipes+dev:rs485.network)
20+
[Logistics Pipes Space](https://matrix.to/#/#logisticspipes+space:rs485.network)
2321

24-
[LP Community](https://matrix.to/#/+logisticspipes:rs485.network)
22+
- [Dev Channel](https://matrix.to/#/#logisticspipes+dev:rs485.network)
2523

2624
The channels are all linked to Discord and some even to IRC.
2725

@@ -54,27 +52,37 @@ $ git lfs checkout
5452

5553
### Gradle
5654

57-
After cloning, you can build LP with `./gradlew build` and find the output in
58-
`build/libs`. If the task fails there may be something wrong with maven
59-
repositories or [a Java update broke ForgeGradle 2](https://github.com/MinecraftForge/ForgeGradle/issues/652)
55+
Make sure you are running Gradle with Java 8: You can check the default
56+
java version with `java -version` and control the version Gradle uses with
57+
the `JAVA_HOME` environment variable. LP can be built with `./gradlew build`
58+
and the output found in the directory `build/libs`.
59+
If the task fails there may be something wrong with maven repositories or
60+
[a Java update broke ForgeGradle 2](https://github.com/MinecraftForge/ForgeGradle/issues/652)
6061
or something may be wrong with your setup. You may definitely ask for help on
6162
the mentioned communication channels above, but please be sure to state your
6263
issue as good as possible and be nice to others.
6364

6465
### IDEA Quirks
6566

66-
If you opened the project in IDEA before running the `./gradlew build` command the run
67-
configurations will not be visible, simple fix is to reload the project.
68-
69-
If the run configurations are not present still, run `genIntellijRuns` task using IDEA's
70-
Gradle integration, then the configurations will appear.
67+
For IDEA to use the correct Java SDK, you might have to select the correct
68+
JDK (Java JDK 8, OpenJDK build preferred) in `File > Project Structure` in the
69+
project part of the project settings under SDK.
7170

7271
### Running Minecraft from your dev environment
7372

7473
After you successfully built LP you can probably run Minecraft directly from
75-
your IDE. There may be a ton of missing texture errors and missing language
76-
files though and this problem even happens when using a new clean mod template,
77-
but don't be sad! The solution is to copy your `build/resources/main/*` into
74+
your IDE after running the correct ForgeGradle generate run configuration task.
75+
Please look at ForgeGradle documentation for more information.
76+
77+
If you are not using IntelliJ IDEA, there may be a ton of missing texture
78+
errors and missing language files. The cause is newer ForgeGradle versions.
79+
Our ForgeGradle version and our build script contain fixes for IntelliJ IDEA
80+
only; sorry if you are not using IDEA. The solution is to remove
81+
`build/classes/*/*` and `build/resources/*` from the run configuration
82+
classpath and add the custom `build/run_classes` path to the classpath.
83+
We are open for any contributions for a better solution or wider support.
84+
85+
The workaround is to copy your `build/resources/main/*` into
7886
`build/classes/java/main` before launching the game, or you may link those two
7987
together (Linux or WSL):
8088

build.gradle

+86-25
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ buildscript {
66
}
77
}
88
dependencies {
9-
classpath group: 'network.rs485', name: 'ForgeGradle', version: forgegradle_version
9+
classpath group: 'network.rs485.forge', name: 'ForgeGradle', version: forgegradle_version
1010
}
1111
}
1212

1313
plugins {
14-
id 'maven'
1514
id 'java'
15+
id 'maven-publish'
1616
id 'org.jetbrains.kotlin.jvm' version "$kotlin_version"
1717
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
1818
id 'org.jetbrains.kotlin.plugin.lombok' version "$kotlin_version"
@@ -21,16 +21,17 @@ plugins {
2121
id 'com.matthewprenger.cursegradle' version "$cursegradle_version"
2222
id 'com.github.johnrengelman.shadow' version "$shadow_version"
2323
}
24-
apply plugin: 'net.minecraftforge.gradle'
24+
apply plugin: 'network.rs485.forge'
2525

2626
archivesBaseName = "logisticspipes"
2727
group = "network.rs485"
2828
version = "0.10.4"
2929
ext.vendor = "unknown"
3030
ext.target = "Forge $forge_version"
3131

32-
sourceCompatibility = JavaVersion.VERSION_1_8
33-
targetCompatibility = JavaVersion.VERSION_1_8
32+
java.toolchain.languageVersion = JavaLanguageVersion.of(8)
33+
34+
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
3435

3536
def ENV = System.getenv()
3637

@@ -110,6 +111,18 @@ kotlinLombok {
110111
lombokConfigurationFile file("lombok.config")
111112
}
112113

114+
project.afterEvaluate {
115+
tasks.register('copyRunClasses', Copy.class) {
116+
dependsOn ['classes']
117+
from sourceSets.main.output.classesDirs, sourceSets.main.output.resourcesDir, sourceSets.api.output.classesDirs
118+
into "${project.buildDir}/run_classes/"
119+
120+
includeEmptyDirs false
121+
}
122+
123+
tasks['prepareRuns'].dependsOn('copyRunClasses')
124+
}
125+
113126
minecraft {
114127
mappings channel: 'snapshot', version: "$mappings_version"
115128
accessTransformer = file("$rootDir/resources/META-INF/lp_at.cfg")
@@ -127,7 +140,22 @@ minecraft {
127140
// load LP core mod from classpath
128141
property 'fml.coreMods.load', 'logisticspipes.asm.LogisticsPipesCoreLoader'
129142

130-
jvmArg '-ea'
143+
jvmArgs '-ea'
144+
environment 'MC_VERSION', mcversion
145+
146+
lazyToken 'classpathExclude', {
147+
def paths = [
148+
sourceSets.main.output.classesDirs.asPath,
149+
sourceSets.api.output.classesDirs.asPath,
150+
sourceSets.main.output.resourcesDir.path,
151+
sourceSets.api.output.resourcesDir.path,
152+
]
153+
String.join(File.pathSeparator, paths)
154+
}
155+
lazyToken 'classpathInclude', {
156+
def paths = ["${project.buildDir}/run_classes/"]
157+
String.join(File.pathSeparator, paths)
158+
}
131159

132160
mods {
133161
logisticspipes {
@@ -148,7 +176,22 @@ minecraft {
148176
// load LP core mod from classpath
149177
property 'fml.coreMods.load', 'logisticspipes.asm.LogisticsPipesCoreLoader'
150178

151-
jvmArg '-ea'
179+
jvmArgs '-ea'
180+
environment 'MC_VERSION', mcversion
181+
182+
lazyToken 'classpathExclude', {
183+
def paths = [
184+
sourceSets.main.output.classesDirs.asPath,
185+
sourceSets.api.output.classesDirs.asPath,
186+
sourceSets.main.output.resourcesDir.path,
187+
sourceSets.api.output.resourcesDir.path,
188+
]
189+
String.join(File.pathSeparator, paths)
190+
}
191+
lazyToken 'classpathInclude', {
192+
def paths = ["${project.buildDir}/run_classes/"]
193+
String.join(File.pathSeparator, paths)
194+
}
152195

153196
mods {
154197
logisticspipes {
@@ -162,6 +205,7 @@ minecraft {
162205
// mimic the runServer task
163206
environment 'mainClass', 'net.minecraft.launchwrapper.Launch'
164207
environment 'MCP_TO_SRG', "$buildDir/createSrgToMcp/output.srg"
208+
environment 'MC_VERSION', mcversion
165209
main 'net.minecraftforge.legacydev.MainServer'
166210
args '--tweakClass', 'net.minecraftforge.fml.common.launcher.FMLServerTweaker'
167211
arg 'nogui' // without GUI
@@ -186,6 +230,7 @@ minecraft {
186230
jar {
187231
from sourceSets.api.output
188232
finalizedBy 'shadowJar'
233+
duplicatesStrategy = DuplicatesStrategy.WARN
189234

190235
manifest = project.manifest {
191236
from sharedManifest
@@ -241,26 +286,19 @@ processResources {
241286
// this will ensure that this task is redone when the versions change.
242287
inputs.property "version", project.version
243288

289+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
290+
244291
// replace stuff in mcmod.info, nothing else
245292
from(sourceSets.main.resources.srcDirs) {
246293
include 'mcmod.info'
247294

248295
// replace version and mcversion
249-
expand 'version': project.version
250-
}
251-
252-
// copy everything else, thats not the mcmod.info
253-
from(sourceSets.main.resources.srcDirs) {
254-
exclude 'mcmod.info'
296+
expand 'version': project.version, 'mcversion': mcversion
255297
}
256298
}
257299

258300
repositories {
259301
mavenCentral()
260-
maven {
261-
name = 'JitPack.io'
262-
url = 'https://jitpack.io'
263-
}
264302
maven {
265303
url = "https://maven.removeco.de/"
266304
}
@@ -312,10 +350,17 @@ import java.nio.file.Files
312350
final nonMinecraftConfigurations = configurations.findAll { conf -> conf != configurations.minecraft }
313351
if (!nonMinecraftConfigurations.empty) {
314352
final fgextension = project.getExtensions().findByName("minecraft")
315-
final mcrepo = new MinecraftUserRepo(project, 'net.minecraftforge', 'forge', "$forge_version", fgextension.getAccessTransformers(), fgextension.getMappings())
353+
final mcrepo = new MinecraftUserRepo(
354+
/* project = */ project,
355+
/* group = */ 'net.minecraftforge',
356+
/* name = */ 'forge',
357+
/* version = */ "$forge_version",
358+
/* ats = */ fgextension.getAccessTransformers().getFrom().toList(),
359+
/* mapping = */ fgextension.getMappings().get(),
360+
)
316361
nonMinecraftConfigurations.each {
317362
it.resolutionStrategy.dependencySubstitution {
318-
substitute module('net.minecraftforge:forge') with module(mcrepo.getDependencyString())
363+
substitute module('net.minecraftforge:forge') using module(mcrepo.getDependencyString())
319364
}
320365
}
321366
}
@@ -339,6 +384,7 @@ task deobfJar(type: Jar) {
339384
from sourceSets.main.output
340385
from sourceSets.api.output
341386
archiveClassifier.set('deobf')
387+
duplicatesStrategy = DuplicatesStrategy.WARN
342388

343389
manifest = project.manifest {
344390
from sharedManifest
@@ -349,6 +395,7 @@ task apiJar(type: Jar, dependsOn: apiClasses) {
349395
from sourceSets.api.output
350396
from sourceSets.api.allSource
351397
archiveClassifier.set('api')
398+
duplicatesStrategy = DuplicatesStrategy.WARN
352399
}
353400

354401
curseforge {
@@ -464,7 +511,8 @@ gradle.taskGraph.whenReady { TaskExecutionGraph taskGraph ->
464511
}
465512
}
466513

467-
class DownloadTask extends DefaultTask {
514+
abstract class DownloadTask extends DefaultTask {
515+
@Input
468516
String url
469517

470518
@OutputFile
@@ -507,12 +555,8 @@ task language(dependsOn: [languageMain, languageBook], type: Copy) {
507555
processResources.dependsOn language
508556
}
509557

510-
install.repositories.mavenInstaller.pom.whenConfigured { pom ->
511-
pom.dependencies.clear()
512-
}
513-
514558
tasks.named('wrapper') {
515-
gradleVersion = '6.8.3'
559+
gradleVersion = '7.5'
516560
distributionType = Wrapper.DistributionType.ALL
517561
}
518562

@@ -545,3 +589,20 @@ task integrationTests(dependsOn: ['prepareRunServerTest'], type: Exec) {
545589
}
546590
}
547591
}
592+
593+
publishing {
594+
publications {
595+
mavenJava(MavenPublication) {
596+
artifact jar
597+
}
598+
}
599+
repositories {
600+
maven {
601+
url "file://${project.projectDir}/mcmodsrepo"
602+
}
603+
}
604+
}
605+
606+
tasks.withType(JavaCompile).configureEach {
607+
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
608+
}

common/logisticspipes/asm/LogisticsPipesCoreLoader.java

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import lombok.Getter;
1010

11+
@IFMLLoadingPlugin.MCVersion("1.12.2")
1112
//@IFMLLoadingPlugin.SortingIndex(1001) TODO: For next MC update. Changing this now, will change ASM check sums as well.
1213
public class LogisticsPipesCoreLoader implements IFMLLoadingPlugin {
1314

gradle.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ kcoroutines_version = 1.6.4
88
kserialization_version = 1.4.0
99
kaml_version = 0.47.0
1010
shadow_version = 6.1.0
11+
mcversion = 1.12.2
1112
forge_version = 1.12.2-14.23.5.2860
1213
mappings_version = 20171120-1.12
13-
forgegradle_version = 4.1.17
14+
forgegradle_version = 5.1.60
1415
cursegradle_version = 1.4.0
1516
lombok_plugin_version = 5.3.3.3

gradle/wrapper/gradle-wrapper.jar

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:e996d452d2645e70c01c11143ca2d3742734a28da2bf61f25c82bdc288c9e637
3-
size 59203
2+
oid sha256:575098db54a998ff1c6770b352c3b16766c09848bee7555dab09afc34e8cf590
3+
size 59821
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)