0

I have a repo at http://www.github.com/kourbou/HyperQuest. I have a git submodule to a project called SpongeAPI. I would like to add the compiled jar of the subproject to the Eclipse project automatically but I have failed at doing so. I have added this to my gradle.build :

dependencies 
{
    jar project('SpongeAPI')
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

But the build fails and this happens:

A problem occurred evaluating root project 'HyperQuest'.
> Could not find method jar() for arguments [project ':SpongeAPI'] on root project 'HyperQuest'.

Could someone give me an example or write a gist of a build.gradle that works? Thanks.

Ryan Leach
  • 4,262
  • 5
  • 34
  • 71
divx
  • 87
  • 9

2 Answers2

3

Either set up multi-project build or publish the output of SpongeAPI into some repository and consume it from that place.

Multi-project build is described in http://www.gradle.org/docs/current/userguide/tutorial_java_projects.html#sec:examples - you will add settings.gradle that will include SpongeAPI and then the dependency is like compile project(':SpongeAPI').

The publish approach means that you will upload the artifact from SpongeAPI build into a repository and your build will add this repository (like you add mavenCentral() or jcenter()) and refer to your artifact using common notation. Again there is a documentation to help you with that - http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html#N10669

Radim
  • 4,721
  • 1
  • 22
  • 25
0

I know you posted this early on in SpongeAPI's development, but I'll add this here for future readers.

By including SpongeAPI as a git-submodule, you are potentially tying your plugin to a specific, in development version of the API.

Instead, we provide a maven repository that you should use at https://repo.spongepowered.org/maven/

When using a version of SpongeAPI you MUST stick to released API versions, and not snapshots.

Otherwise your plugin has the potential to break on dev releases of the API.

You can read up to date information on how to set up a Sponge Plugin project here: https://docs.spongepowered.org/stable/en/plugin/project/index.html

Ryan Leach
  • 4,262
  • 5
  • 34
  • 71