How to setup maven with sponge!

So, is there a good, basic Gradle & Eclipse tutorial somewhere? I haven’t used Maven or any other tool like this before.

Well basicly, if you understand how maven works. Gradle shouldn’t be so hard.

The reason why I use maven is because gradle lacks rules. For example if you want to deploy a jar to a maven repo with gradle. If the properties aren’t set correctly it wouldn’t work. These properties are groupId and Version. Gradle doesn’t care if these are left empty. Maven will definitely complain about that. It can be that I misunderstood how gradle works … .

Example of missing properties in existing projects (@MrMysteri0us this isn’t meant offensive):

Thomas, I think you misread me: I have ZERO knowledge of Gradle AND Maven. So am really looking for a Gradle 101 tutorial.

1 Like

Well I have almost no knowledge of gradle xD. But I am learning it at this moment. This is where I start for learning gradle: http://www.gradle.org/docs/current/userguide/userguide.html.

Also I use IDEA to help me with it. Their is no reason why you should start from scratch.

I’m using your repo for my projects (using gradle). keep it updated :wink:

1 Like

Thomas, the Gradle User Guide is 66 chapters and several hundred pages long. Not really a place to start learning a tool like this.

Ctr + f is such a wonderful tool :smiley:. But anyway I ditched gradle for so far. flyway and jooq don’t work good with it (or I don’t understand how I can make it work).

That flyway? http://flywaydb.org/ Just take a close look at the page…
http://flywaydb.org/getstarted/firststeps/gradle.html

Yeah I did that but the way I set it up is like this:

  1. flyway inits database
  2. jooq generates code
  3. Builds plugin (succeeded)

How gradle does it:

  1. generates jooq
  2. builds plugin (fails)
  3. flyway inits database

Off course that doesn’t work out good.

Could you show me how you set it up (build.gradle)? Also, what commandline command are you running.

This is my build.gradle Setup.

Oh, sorry, i meant @thomas15v

@TBotV63
This is the build.gradle I eventually ended with.
http://hastebin.com/vepoxameyo.vbs

Thanks. And then you run gradle build?

Ehm, I did that. But like I told before. It tries to generate jooq code before the database has been initialized. I am pretty sure its because jooq doesn’t has an official plugin yet. And mostly supports maven.
Btw the script runs from this source:

Turns out the flyway plugin for gradle is rather poorly coded…

1 Like

Just for the record, fixed a bug with the CI server. The jar on the maven repo is up to date :wink:. Also invested in ma server because sponge simply doesn’t compile on 200mb (amount of ram that as left with jenkins and artifactory running) ram XDDD.

It seems like there is an official repository now: http://repo.spongepowered.org/Sponge/maven/
According to this.

2 Likes

Nice :smiley:. I Update this tuto.

Edit: updated with official repo.

Hi there, I found this guide when searching how to port my plugin to Sponge, I followed the steps but received this error:

 WebSandboxMC $ mvn package
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building WebSandboxMC 1.6.0
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.spongepowered.org/Sponge/maven/org/spigotmc/spigot-api/1.11-R0.1-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT/maven-metadata.xml from/to sponge-repo (https://repo.spongepowered.org/Sponge/maven/): Failed to transfer file: https://repo.spongepowered.org/Sponge/maven/org/spigotmc/spigot-api/1.11-R0.1-SNAPSHOT/maven-metadata.xml. Return code is: 308 , ReasonPhrase:Permanent Redirect.
[WARNING] Failure to transfer org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT/maven-metadata.xml from https://repo.spongepowered.org/Sponge/maven/ was cached in the local repository, resolution will not be reattempted until the update interval of sponge-repo has elapsed or updates are forced. Original error: Could not transfer metadata org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT/maven-metadata.xml from/to sponge-repo (https://repo.spongepowered.org/Sponge/maven/): Failed to transfer file: https://repo.spongepowered.org/Sponge/maven/org/spigotmc/spigot-api/1.11-R0.1-SNAPSHOT/maven-metadata.xml. Return code is: 308 , ReasonPhrase:Permanent Redirect.
Downloading: https://repo.spongepowered.org/Sponge/maven/net/md-5/bungeecord-chat/1.10-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata net.md-5:bungeecord-chat:1.10-SNAPSHOT/maven-metadata.xml from/to sponge-repo (https://repo.spongepowered.org/Sponge/maven/): Failed to transfer file: https://repo.spongepowered.org/Sponge/maven/net/md-5/bungeecord-chat/1.10-SNAPSHOT/maven-metadata.xml. Return code is: 308 , ReasonPhrase:Permanent Redirect.
[WARNING] Failure to transfer net.md-5:bungeecord-chat:1.10-SNAPSHOT/maven-metadata.xml from https://repo.spongepowered.org/Sponge/maven/ was cached in the local repository, resolution will not be reattempted until the update interval of sponge-repo has elapsed or updates are forced. Original error: Could not transfer metadata net.md-5:bungeecord-chat:1.10-SNAPSHOT/maven-metadata.xml from/to sponge-repo (https://repo.spongepowered.org/Sponge/maven/): Failed to transfer file: https://repo.spongepowered.org/Sponge/maven/net/md-5/bungeecord-chat/1.10-SNAPSHOT/maven-metadata.xml. Return code is: 308 , ReasonPhrase:Permanent Redirect.
Downloading: https://repo.spongepowered.org/Sponge/maven/net/md-5/bungeecord-parent/1.10-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata net.md-5:bungeecord-parent:1.10-SNAPSHOT/maven-metadata.xml from/to sponge-repo (https://repo.spongepowered.org/Sponge/maven/): Failed to transfer file: https://repo.spongepowered.org/Sponge/maven/net/md-5/bungeecord-parent/1.10-SNAPSHOT/maven-metadata.xml. Return code is: 308 , ReasonPhrase:Permanent Redirect.
Downloading: https://repo.spongepowered.org/Sponge/maven/org/spongepowered/spongeapi/6.0.0/spongeapi-6.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.881 s
[INFO] Finished at: 2017-05-20T22:37:22-07:00
[INFO] Final Memory: 11M/258M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project WebSandboxMC: Could not resolve dependencies for project io.github.satoshinm:WebSandboxMC:jar:1.6.0: Failed to collect dependencies at org.spongepowered:spongeapi:jar:6.0.0: Failed to read artifact descriptor for org.spongepowered:spongeapi:jar:6.0.0: Could not transfer artifact org.spongepowered:spongeapi:pom:6.0.0 from/to sponge-repo (https://repo.spongepowered.org/Sponge/maven/): Failed to transfer file: https://repo.spongepowered.org/Sponge/maven/org/spongepowered/spongeapi/6.0.0/spongeapi-6.0.0.pom. Return code is: 308 , ReasonPhrase:Permanent Redirect. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

In case anyone else runs into this same problem from the same steps, the error is caused by “https://repo.spongepowered.org/Sponge/maven/org/spongepowered/spongeapi/6.0.0/spongeapi-6.0.0.pom. Return code is: 308 , ReasonPhrase:Permanent Redirect. → [Help 1]”. This URL cannot be loaded even by Apache Maven 3.5.0, even though it can be downloaded in your web browser (or at least mine) without error.

The solution is simple, change the pom.xml as follows, removing Sponge from the path:

     <repository>
       <id>sponge-repo</id>
-      <url>https://repo.spongepowered.org/Sponge/maven/</url>
+      <url>https://repo.spongepowered.org/maven/</url>
     </repository>

After making this fix, the Sponge API dependency is able to be located and built against within Maven successfully.