-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help using loom in common module #17
Comments
Have you tried removing loom from the fabric part? |
I hadn't, but trying to remove the fabric-loom gradle plugin from the Fabric module (I assume this is what you meant) causes even worse errors. A short excerpt is below:
I am pretty sure that the Fabric module requires fabric-loom itself too |
Just spoke with @modmuss50 about this a bit, and this is what I came up with: diff --git a/Common/build.gradle b/Common/build.gradle
index ea3a28a..9053a53 100644
--- a/Common/build.gradle
+++ b/Common/build.gradle
@@ -1,29 +1,22 @@
plugins {
id 'java'
- id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
+ id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
}
archivesBaseName = "${mod_name}-common-${minecraft_version}"
-minecraft {
- version(minecraft_version)
- runs {
- if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) {
-
- server(project.hasProperty('common_server_run_name') ? project.findProperty('common_server_run_name') : 'vanilla_server') {
- workingDirectory(this.file("run"))
- }
- client(project.hasProperty('common_client_run_name') ? project.findProperty('common_client_run_name') : 'vanilla_client') {
- workingDirectory(this.file("run"))
- }
- }
- }
+dependencies {
+ minecraft "com.mojang:minecraft:${minecraft_version}"
+ mappings loom.officialMojangMappings()
}
-dependencies {
- compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
- implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
+loom {
+ shareCaches()
+ remapArchives = false
+ mixin {
+ useLegacyMixinAp = false
+ }
}
processResources {
diff --git a/Fabric/build.gradle b/Fabric/build.gradle
index 337a4a2..56712f1 100644
--- a/Fabric/build.gradle
+++ b/Fabric/build.gradle
@@ -12,10 +12,11 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
- implementation project(":Common")
+ implementation project(path: ":Common", configuration: "namedElements")
}
loom {
+ shareCaches()
runs {
client {
client()
I believe the line that solves the original issue (circular tasks) is: implementation project(path: ":Common", configuration: "namedElements") loom {
mixin {
useLegacyMixinAp = false
}
} Is required to fix: Unfortunately, applying this diff and building will not give you a complete If you look at This should be resolved by: loom {
remapArchives = false
} however there is currently a bug in loom where that line is read to late and ends up doing nothing (FabricMC/fabric-loom#677). Once that loom bug is fixed, I can re look at what needs doing and hopefully it all works (tm) and I can add it as an example project. Also just so this is noted somewhere, the improvements you get from using Loom for Common are (Thank you modmuss for the info):
|
In case anyone wishes to compare, here is how I solved this myself a while back: |
Thank you @jaredlll08 for spending time on my issue. I got loom working in the common module thanks to it. I'm not concerned with the maven issue because I don't have a maven set up and don't plan to. As far as I understand it—while it's not a great solution—a mod that depends on my mod could just put the fabric jar into the common module using cursemaven and then only use common classes in the common module. Either way, I don't expect anyone to depend on my mod and they could always contact me if needed. I also made progress on my original plan of having a shared submodule library between mods, however I ran into some issues. I was able to have the shared library's classes relocate using shadow (to avoid class conflicts), however I ran into an issue with the mixin refmaps not respecting the package relocation. I have decided that it's too hacky of a solution for now and will not continue with it. I may try again in the future, but I think it's more likely that I'll simply make a separate library mod instead. I'm satisfied with closing this issue, but I'll leave it up to you whether you want to keep it open until the mentioned loom bug is fixed. Thanks again :D |
I believe your setup is basically the same as the setup I described here #17 (comment), including all the issues that comes with it.
I'm going to keep the issue open until that loom bug is fixed and until there is a version using loom for common with proper built jars |
I have not noticed most of the issues you describe with my setup. I am using the non-legacy mixin AP, and I have not had issues publishing common jars |
Where do you get the common jar from? When I pulled your repo and did a build, I didn't see a usable jar (only javadoc was there) in |
Mine's just in libs. Seems to be in Mojmaps and all |
Not sure what I did to get that to work though |
If you look at https://lukebemish/excavated_variants, that has this setup in 1.19 and it works fine, with the exception of the sources jar, which ends up in devlibs. However, I reference that one on its own when I publish to get around this. |
I've come up with a rather clever way to force usable jars to be generated with loom in common that I figured I should share here in case this is still relevant. Add the following somewhere after the dependency block in the common build.gradle: import net.fabricmc.loom.task.AbstractRemapJarTask
tasks.withType(AbstractRemapJarTask).each {
it.targetNamespace = "named"
} Instead of disabling remapping entirely, I just force loom to map from named to named. |
@jaredlll08 Do you know how to do this with As I get this when I apply plugins {
id 'java'
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'maven-publish'
}
archivesBaseName = 'blocksterhunter-platform-common'
loom {
shareCaches()
remapArchives = false
mixin {
useLegacyMixinAp = false
}
}
dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.layered(){
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
}
// compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
// implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'
}
|
The Loom bug is now fixed fyi, but the second point is something I'm unsure on. |
For future reference. https://gist.github.com/Witixin1512/bbb8484523ea6a0e8440f17621f89f95 |
Hello, I have attempted changing my common module to use fabric loom, but I get an error when running the game that I can't solve.
The TLDR of why I want to do this is two reasons. First, the supposed performance improvements. However more importantly, I want to create a new module which my fabric module would depend on that would itself depend on the fabric api. When trying to create this module, I get the same error.
Attempt
You can view my attempt here: dodogang@e4882ea
However, the only changes are in the
Common/build.gradle
However, this gives the following error when running both Fabric Client and Forge Client
The full build output is provided here, however it doesn't give much more information than what is above.
I have exhausted my knowledge of gradle today trying to figure out why this error is occurring. I expect there is a loom flag I don't know about that would solve this. Either way, if you have a lead on what can fix this error I'd love to here it :)
The text was updated successfully, but these errors were encountered: