Hey,
I’m using the SpongeAPI from GitHub, but I can’t access to @Inject or the Logger. When I try to build my plugin with the server, I get an error (java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList).
What I should do?
I had this issue a lot. Am I right in assuming you’re using IntelliJ 14+? If so, I simply had to open the module’s settings and go to libraries and add slf4j and guava. You should then be able to import them.
I’m using NetBeans, but I know how to import libraries. Thank you!
You have to use Guice instead of Guava!
You can also use a build system to make this easier, Gradle is the build tool that sponge uses to resolve dependencies, Maven is another popular tool that Bukkit used to use.
I’m not sure which one integrates better with NetBeans, but luckily there is instructions for both!
https://docs.spongepowered.org/en/plugin/basics/workspace/netbeans.html
Following these instructions, or these for IntelliJ will cause the dependencies to be automatically downloaded if found. If configured to it can also download the latest sponge-API for you to build against, so you don’t need to continually download dev builds of sponge.
Oops! Must have mixed the two up xD
You will need both.
Sometimes i ask myself: “Am i the only person in the world (except the big projects) that uses Maven or Gradle?”
What i wanted to say, why don’t you use Maven or Gradle? It’s well integrated in every IDE (AFAIK) and saves you alot of trouble and headaches. For basic Maven or Gradle usage, you don’t even need to learn alot, just a code-snippet that you drop in and voila.
I’m using Gradle now. Thanks!