-
Notifications
You must be signed in to change notification settings - Fork 114
Fluid Entity Gradle
The Fluid API is required to compile your main game logic, and the components are required to generate the Fluid API, so they cannot all be in the same gradle module.
You need to separate your components into a separate gradle module, and add the fluid plugin to your main game module.
- Fluid/Gradle quickstart - minimal 'hello world'. Just the essentials.
- Fluid/Gradle quickstart for libGDX - Gradle project generated with the libGDX tools, includes odb-contrib.
-
Start with a gradle project set up to compile artemis-odb.
-
Add the plugin to the buildscript dependencies.
(You might need to first add artemisVersion to gradle.properties.) dependencies { // lib for artemis-odb fluid. classpath "net.onedaybeard.artemis:artemis-fluid-gradle-plugin:$artemisVersion" }
-
Add a new module to your main
build.gradle
:project(":components") { apply plugin: "java" }
-
Include the new module in settings.gradle
-
Add any pre-existing components to
<project root>/components/src
directory. -
Create
<project root>/components/build.gradle
:apply plugin: "java" sourceCompatibility = 1.7 [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' sourceSets.main.java.srcDirs = ["src/"] eclipse.project { name = appName + "-components" }
-
Include the new component module as a dependency to whatever module is going to hold your game systems. If you are using libGDX's code generator, this is the
:core
module.project(":core") { apply plugin: "java" dependencies { compile project(":components")
-
Add the following to the gradle configuration for this core 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") }
-
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 an example
When compiling with gradlew fluid -i, the fluid plugin can be seen scanning loads of extra artifacts. To speed up compilation exclude artifacts using the following preference setting. Alternatively limit the supplied classpath.
fluid {
preferences.excludeFromClasspath += [
// speed up compilation by skipping dependencies without components.
"guava-",
"reflections-",
"commons-lang3-",
"javapoet-",
"fast-classpath-scanner-",
"commons-io-",
"javassist-",
]
- Overview
- Concepts
- Getting Started
- Using
- More guides
- Plugins
- Game Gallery
- Tools and Frameworks
- API reference