Which Sponge to use?

if you use gradle, first follow this

followed by the Adding Plugin to Sponge classpath section here

https://docs.spongepowered.org/en/plugin/debugging.html

I actually build my sponge plugins though java project. If you have ever built for bukkit-plugins it’s just like that only instead of importing bukkit you import sponge. If you haven’t then look up bukkit java project environment setup and change the bukkit.jar to sponge.jar

I don’t know where you got that idea from but its not true. They both use two different APIs and plugins are consequently not cross compatible.

2 Likes

I think he referred to SpongeForge and SpongeVanilla. Cauldron is obviously not compatible to Sponge as its using another API

1 Like

I was talking about spongeforge and spongevanilla, not cauldron

1 Like

Oh ok. I heard that you couldn’t do Java Project.

I think you misunderstand what Sponge and Bukkit are. They are APIs (and of course they have implementation counterparts) built using the Java programming language. When you use Sponge, you are already programming in Java, you’re simply just using the libraries you’ve downloaded in addition.

This is what the JRE consists of (src):

The Java Runtime Environment (JRE) is what you get when you download Java software. The JRE consists of the Java Virtual Machine (JVM), Java platform core classes, and supporting Java platform libraries. The JRE is the runtime portion of Java software, which is all you need to run it in your Web browser.

all my sponge java projects work (when sponge didnt have the boot issue) so i know it works. Something i forgot to mention was you also need a file guava.jar in your inject librey even though you dont use it on the server. Sponge uses this program to get the

Optional<Object>

object. So happy programming :wink:

That will be changing, see: "There's a Java update available!"

it maybe changing but currently we still need it

I would recommend using a build-tool such as maven or gradle. They would make dependencies much easier.

2 Likes

I am aware that they are APIs. I was under the impression that with Sponge, you had to build using either Maven or Gradle. I was not aware that you were able to build with Sponge simply by adding the .jar as an API like you can with Bukkit.

Technically, you cannot just use one of the API jars, you must use the shaded jar which is available somewhere. But using maven or gradle is better in the long run. It makes it easier for others to contribute.

You’re actually mentioning what’s called classpath, which is to my understanding how classes are loaded/found etc within the environment (I a have no expertise in this field so those who are please do correct me if I am wrong).

Maven and Gradle are both build automation tools (amongst other things) that make creating and managing Java (and other language) projects (not Eclipse projects) and their binaries easier.

Noteworthy: Here are some software build automation tools laid out.

Just dropping this all here to help you understand that those are different ways of doing the same thing (ie: using Maven/Gradle/Ant. As well as using Eclipse/IntelliJ/NetBeans IDEs with or without the automation tools to manage dependencies).

FYI, if you do NOT want to use a build tool, we do provide a shaded jar that does bundle all the dependencies for SpongeAPI.

2 Likes

Little addition:
There’s no support from staff for the shaded jar. Use at your own risk :wink:
Using Maven or Gradle is recommended.

How would you go about doing so? I am using Maven. Also, once the plugin has been tested and debugged, how do I export it as a .jar file?

Refer to the documentation here: https://docs.spongepowered.org/en/plugin/workspace/dependencies.html

EDIT
/On how to use maven as a dependency/, I might of misunderstood what you meant in your first question.

1 Like

export it the same way you would a bukkit plugin

I use the M2Eclipse plugin for eclipse. It allows me to import maven projects into eclipse. Once I got it as a project in eclipse, the instructions for debugging from the Docs apply, since your maven project can be treated by eclipse just as a regular Java project is.

To export the plugin as a .jar file I run maven with the “package” target. It will then compile, run tests etc and generate whatever .jars your pom.xml specifies - if it does not specify any, just a .jar of the compiled source code is generated.