Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: STEP 1 ::
- // GFrameEngine Project Directory
- src
- GFrameEngine
- GFrame.java
- GameResource.java
- build.gradle
- // Game Engine's project build.gradle file contains
- apply plugin : "java"
- sourceSets{
- main.java.srcDir "src"
- }
- // After running Engine's build.gradle, the src folder is compiled into GFrameEngine.jar
- :: STEP 2 ::
- Now I'll place the GFrameEngine.jar into Game Project's library(lib) directory
- // Game project directory structure
- lib
- GFrameEngine.jar
- src
- MyGamePkg
- MyGame.java
- MyGameResource.java
- build.gradle
- // Game project build.gradle file contains
- apply plugin : "java"
- dependencies {
- compile fileTree(dir: 'lib', include: ['*.jar'])
- }
- sourceSets{
- main.java.srcDir "src"
- }
- jar {
- from configurations.compile.collect { zipTree it }
- manifest.attributes "Main-Class":"MyGamePkg.MyGame"
- }
- // After you run the game project build.gradle, it combines the engine jar and game project into one single jar.
- // and the finally created jar file is a standalone executable file
- YEEE!
- :: Next STEPS ::
- Upload GFrameEninge to a Github repo.
- And then adding the remote repository as a dependency in my local game project. Game project's build.gradle file would always fetch the latest engine's code from github and import it as jar using jitpack.io
- The reason I moved from Apache Ant to Gradle is the easy of maintaining remote dependency.
- Q : Is it compiling the engine source and game source into one single monolithic jar file?
- A : Yes.
- Q : Isn't it bad practice?
- A : Depends. Mostly yes, but since the engine source and game source is small enough - currently it's easier that way. Right now ~ 400 LoC is only taking up 6KB using default compression specified in Gradle.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement