What's Changed?

So it’s been a long while since I’ve built plugins and I have seen some people mention something called, “Maven”. This leads me to believe that the way you create plugins has changed. Having said that, could someone please catch me up on what’s going on with plugin dev and/or link me to a page describing how maven works.

NOTE: I am not asking when Sponge will be ready or how to develop Sponge plugins.

It’s pretty basic and just covers basic setup & including dependencies. Is there something specific you’re wanting to learn how to do with maven? You can do quite a bit with it.

btw, Sponge itself is going to be using gradle (a newer build tool). You’ll probably get people posting here saying to use that instead, so you may want to look at tutorials on both and see which you like better. Gradle uses groovy-ish for config so it may feel more natural compared to maven’s XML configs.

1 Like

Maven? That’s what we used yesterday :wink:

Gradle is the System sponge uses. You only need it if you Want to publish the code of your plugin, it downloads dependencies for people who download your plugin code automatically.

Could you please tell me how to set it up? I tried and got the following stacktrace:

C:\Users\PinkSlime>gradle eclipse --stacktrace

FAILURE: Build failed with an exception.

* What went wrong:
Task 'eclipse' not found in root project 'PinkSlime'.

* Try:
Run gradle tasks to get a list of available tasks. Run with --info or --debug option to g
et more log output.

* Exception is:
org.gradle.execution.TaskSelectionException: Task 'eclipse' not found in root project 'Pi
nkSlime'.
        at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:101)
        at org.gradle.execution.TaskSelector.getSelection(TaskSelector.java:76)
        at org.gradle.execution.commandline.CommandLineTaskParser.parseTasks(CommandLineT
askParser.java:42)
        at org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskN
ameResolvingBuildConfigurationAction.java:44)
        at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:
42)
        at org.gradle.execution.DefaultBuildExecuter.access$100(DefaultBuildExecuter.java
:23)
        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:
48)
        at org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(E
xcludedTaskFilteringBuildConfigurationAction.java:47)
        at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:
42)
        at org.gradle.execution.DefaultBuildExecuter.access$100(DefaultBuildExecuter.java
:23)
        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:
48)
        at org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBu
ildExecutionAction.java:44)
        at org.gradle.execution.DefaultBuildExecuter.configure(DefaultBuildExecuter.java:
42)
        at org.gradle.execution.DefaultBuildExecuter.select(DefaultBuildExecuter.java:35)

        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLau
ncher.java:142)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.
java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java
:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.r
un(InProcessBuildActionExecuter.java:80)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildAc
tionExecuter.java:36)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildAc
tionExecuter.java:26)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(C
ommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(C
ommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidat
ionAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidat
ionAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLi
neActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLi
neActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAct
ion.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAct
ion.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java
:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)


BUILD FAILED

Total time: 2.803 secs

You should try apply plugin: 'eclipse'

if that’s not the case can you post your build.gradle

What @LordIllyohs said. Also, do you happen to have a git repo? Those things can be quite helpful :wink:

I figured out what I was doing wrong. I fixed the gradle situation but why would I need a git repo? I’ve always got the git lingo wrong so excuse me if I say something stupid, I have a Github account.

Well, do you have a repository on github for the project you are working on? If so, could you provide a link?

My Github is mainly for my useless Javascript projects but there are a couple of my plugins on there from Bukkit days. Feel free to look here.

You can use the Gradle Eclipse plugin and the EGit plugin (Git GUI for eclipse).

Go To Help > Eclipse Marketplace, search for ‘gradle’. The plugin is called ‘Gradle Integration for Eclipse 4.4’.

You can also install EGit using the marketplace.

To setup a project hosted on GitHub:

  1. Create a new empty repository on GitHub
  2. Open the EGit ‘Git Repositories’ view. You may have to enable it using Window > Customize Perspective...
  3. Clone your GitHub repository using the https URL
  4. Import the (empty) project using File > Import..., choose ‘Gradle Project’, select the folder of the Project (usually …/[user-folder]/git/[project-name]), click ‘Build Model’ and ‘Finish’.
  5. Create the ‘build.gradle’ file in your new project root folder

Example ‘build.gradle’:

apply plugin: 'java'
apply plugin: 'eclipse'

//java version
sourceCompatibility = 1.7

//version of your plugin
version = '1.0.0'

repositories {
    maven {
        url "http://repo.thomas15v.net/plugins" //unofficial sponge repository
    }    
}

dependencies {
    compile group: 'org.spongepowered', name: 'spongeapi', version: '1.0.0-SNAPSHOT' //adds sponge to your dependencies
}

Now you can use gradle to download your dependencies, and push the changes you made to your GitHub repository.
The first file you should place in your project root folder is a .gitignore file, so that git only uploads your source folders and not the binary folder:

1 Like