Sponge Build: 1395 (API 4.1)
Forge Build: 1902
Java Version: JDK 1.8.0_91
My plugin works (with an error message about mcmod.info) on SpongeVanilla, but fails to load on SpongeForge. As far as I understand, the file should be generated automatically, with the gradle configuration template in the sponge docs. This doesn’t work for me, and I’ve tried for several hours to get it to work with no avail. It’s probably something obvious, but I can’t figure it out.
You are missing the sponge task, here is an example of what you could use:
sponge {
plugin {
meta {
id = "com.example.plugin"
name = "Example"
version = "1.0.0"
description = "Some desc"
}
}
}
@MarkehMe
I have no such task, in fact, I don’t even have sponge gradle registered as a plugin, and my mcmod.info file generates flawlessly every time. It’s something else.
That shouldn’t matter. None of my plugins have the Sponge task either and mcmod.info generates correctly for me
Oh I kind of miss-read, I blame the clock for being 1am.
Couple possibilities are manually compiling instead of building with gradle, or project not correctly setup. Location of src is important here.
Plugins should always also load without an mcmod.info
file on both implementations (though the warning will be displayed), so there is likely something else wrong with your plugin too.
@MarkehMe Thanks for the suggestion, but as others have pointed out, it doesn’t seem to be necessary. Plugin annotation is supposed to take care it.
@TrenTech I’m not very familiar with gradle, but feel free to take a look at my source location. Project is setup exactly as the docs state (double checked this).
@Minecrell Hmmm, interesting. I don’t know what could be wrong with the plugin. So far it just prints a message to the console.
Are you using gradle to compile the project? If not that would be why no mcmod.info is generating.
I’m pretty sure it’s using gradle to compile the project, as the jar’s filename always includes the version I input in build.gradle.
Your mcmod.info is generating but not being added to the jar. I imported your project and ran gradle and this is the message I received
:compileJavaNote: Reading extra plugin metadata from /Users/MonroeTT/Downloads/PopCraft-master/build/tmp/compileJava/mcmod6230262023345669701.info
Note: Writing plugin metadata to /Users/MonroeTT/Downloads/PopCraft-master/build/tmp/compileJava/mcmod.info
@Minecrell You know what’s the deal? I don’t know enough to give a informed response
EDIT: This works
plugins {
id 'java'
id 'maven'
}
group 'org.popcraft.plugin'
version '2.0.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name 'Sponge API'
url 'http://repo.spongepowered.org/maven'
}
}
dependencies {
compile 'org.spongepowered:spongeapi:4.1.0'
}
The problem is that you’re building two different JARs - the main (compiled) JAR and a JAR with the Java source files in it, however you have given both files the same name. If you look closely into the built JAR file you will see that it does not actually contain any class
files but rather just your java
source files.
If you want to build a source JAR additionally you need to give the sourceJar
task an additional classifier so the two files don’t conflict.
Here is an example how to configure the classifier for your source JAR (this will result in an additional -sources.jar
):
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
@TrenTech Oh, wow, that works. I swear that’s exactly what I had before. I guess I’ve just been fiddling around needlessly this whole time. Thank you!
@Minecrell You’re completely right, it looks like having the task was overwriting it. I had added it because before now, I was unable to so much as get a jar output. Also, I completely overlooked the fact that the decompiled jar contains a java, and not a class file. Thanks for pointing that out!
Please note that removing SpongeGradle will also disable the Gradle integration for Sponge plugins which automatically handles setting the plugin version in the mcmod.info
to the version defined in the Gradle build script.
For example, using SpongeGradle you can have the version defined in your build.gradle
and completely remove it from your @Plugin
annotation - when building your plugin it will be automatically set. That allows you to have the version only in one place so you don’t forget to update it in one of them.
So I know this is a little off topic but out of curiosity figured I’d give SpongeGradle a go and this happens
FAILURE: Build failed with an exception.
* What went wrong:
java.lang.NoClassDefFoundError: org/codehaus/groovy/vmplugin/v7/IndyInterface
> org/codehaus/groovy/vmplugin/v7/IndyInterface
I’ve never seen this error but my first guess would be that you’re using an outdated Gradle version.