Skip to content

Fluid Entity Gradle

Daan van Yperen edited this page Sep 16, 2016 · 11 revisions

Fluid Entity API Gradle installation

Notice: since this uses an unreleased version of artemis, install the latest version of odb into your local repo first! mvn clean:install

Assuming a libGDX project that's already set up for artemis-odb. (see libgdx-artemis-quickstart)

  1. Add the plugin to the buildscript dependencies.

    dependencies {
        // lib for artemis-odb fluid.
        classpath "net.onedaybeard.artemis:artemis-fluid-gradle-plugin:$artemisVersion"
    }
    
  2. Add a module to your main build.gradle:

    project(":components") {
        apply plugin: "java"
    }
    
  3. Add it to settings.gradle as well

  4. Create components/build.gradle, example:

    apply plugin: "java"
    
    sourceCompatibility = 1.7
    [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
    sourceSets.main.java.srcDirs = ["src/"]
    eclipse.project {
        name = appName + "-components"
    }
  5. Add the new components as a dependency to your system module in main build.gradle

    project(":core") {
        apply plugin: "java"
    
        dependencies {
            compile project(":components")
  6. Move your components over to the new module.

  7. Add the following to your system module (example: core/build.gradle)

    apply plugin: "artemis-fluid"
    
    ext {
        fluidOutputDir = file("$buildDir/generated-sources/fluid/")
    }
    
    // Replace existing line.
    sourceSets.main.java.srcDirs = ["src/",fluidOutputDir]
    
    fluid {
         generatedSourcesDirectory = fluidOutputDir
         classpath = sourceSets.main.compileClasspath
    
         // optional parameters. Uncomment to activate.
         // preferences.prefixComponentGetter = "_" // prefix for E::[get]pos()
         // preferences.prefixComponentCreate = "" // prefix for E::[]pos()
         // preferences.prefixComponentHas = "has" // prefix for E::[has]Pos()
         // preferences.prefixComponentRemove = "remove" // prefix for E::[remove]Pos()
         // preferences.generateTagMethods = true // add tag convenience methods.
         // preferences.generateGroupMethods = true // add group convenience methods.
         // preferences.generateBooleanComponentAccessors = true // Generate boolean accessors for flag components?
         // preferences.swallowGettersWithParameters = false // global setting. overridden by @Fluid annotation.
    }
    compileJava.dependsOn fluid
    
    // Help intellIJ pick up the generated classes.
    idea.module {
        excludeDirs -= file("$buildDir")
        excludeDirs += file("$buildDir/classes")
        excludeDirs += file("$buildDir/dependency-cache")
        excludeDirs += file("$buildDir/libs")
        excludeDirs += file("$buildDir/tmp")
    }
  8. Run gradle core:compile. If it worked you should find generated source in (core module)/build/generated-sources/fluid/.

See https://github.com/DaanVanYperen/libgdx-artemis-quickstart/commit/11dc6631bc7ce4e79dee6ff93018c8a94ecc7918 for a

Clone this wiki locally