Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 19, 2013 12:56 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Jan 18, 2012 7:51 pm 
Offline

Joined: Sun Oct 12, 2008 8:16 pm
Posts: 7
Gradle is a build tool mainly oriented towards the JVM world (Java, Groovy, Scala, etc.) but it has some C/C++ support. It contains Ant, Ivy, and Maven in their entirety, but is much more elegant to use than those other tools. For example, it has plugins that apply Maven-style conventions (such as expecting all Java source to be in ./src/main/java) but it lets you change those conventions, which is a feature that most Maven fans seem to be opposed to for some reason.

I've made something that basically compiles, and tested that a project using Slick can also compile from a JAR made by this process.

Get and install Gradle: http://www.gradle.org/

Make a file "settings.gradle"
[code]
rootProject.name = 'slick'
[/code]

Then, make a file "build.gradle"
[code]
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'

defaultTasks 'clean', 'copySlickData', 'build', 'javadoc', 'install'
/*
* If you want to make an Eclipse project, just run the task 'eclipse' as well
* The jar will appear as 'build/libs/slick-0.4.0.jar'
* The maven lookup info will be:
* group: "org.newdawn"
* artifact: "slick"
* version: "0.4.0"
* gradle should be able to look up the version with "0.4.+"
*/

group = 'org.newdawn'
version = '0.4.0'
description = 'Game library on top of lwjgl, by Kevin Glass.'

sourceCompatibility = '1.4'
targetCompatibility = '1.4'

repositories {
mavenCentral()
mavenLocal()
maven { url "http://b2s-repo.googlecode.com/svn/trunk/mvn-repo" }
maven { url "http://java.freehep.org/maven2" }
maven { url "http://download.java.net/maven/2" }
}

dependencies {
compile group: 'org.lwjgl.lwjgl', name: 'lwjgl', version: '2.+'
compile files('lib/ibxm.jar')
compile group: 'jcraft', name: 'jogg', version: '0.0.7'
compile group: 'jcraft', name: 'jorbis', version: '0.0.15'
compile group: 'javax.jnlp', name: 'jnlp', version: '1.2+'

// Need a more up-to-date maven repo for ibxm, so we can do away with the file dependency
// compile group: 'ibxm', name: 'ibxm', version: 'do not know'
}

sourceSets {
main {
java {
srcDir 'src'
}
}
test {
resources {
srcDir 'testdata'
}
}
}

task copySlickData(type: Copy, dependsOn: classes) {
from 'src/org/newdawn/slick/data'
into 'build/classes/main/org/newdawn/slick/data'
}

[/code]

_________________
"People are easily amused by quotes." - Some guy with a cool-sounding name


Last edited by ssfsx17 on Sun Apr 29, 2012 6:29 am, edited 3 times in total.

Top
 Profile  
 
PostPosted: Wed Jan 18, 2012 7:55 pm 
Offline

Joined: Sun Oct 12, 2008 8:16 pm
Posts: 7
Here's an example "build.gradle" for a full game.

[code]
defaultTasks 'clean', 'build', 'javadoc', 'unpackNatives', 'distZip', 'installApp'

apply plugin: 'groovy'
apply plugin: 'application'

// This thing is amazing for basic file operations
def ant = new groovy.util.AntBuilder()

mainClassName = "us.patrickwong.koie.KoieMain"

repositories {
mavenCentral()
maven { url "http://b2s-repo.googlecode.com/svn/trunk/mvn-repo" }
maven { url "http://java.freehep.org/maven2" }
maven { url "http://download.java.net/maven/2" }
}

dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy', version: '2.+'
compile group: 'org.lwjgl.lwjgl', name: 'lwjgl', version: '2.+'
compile group: 'ibxm', name: 'ibxm', version: 'alpha51'
compile group: 'jcraft', name: 'jogg', version: '0.0.7'
compile group: 'jcraft', name: 'jorbis', version: '0.0.15'
compile group: 'org.newdawn', name: 'slick', version: '0.4.+'
// compile files('libs/slick.jar')
}

task cleanOldNatives << {
ant.delete() {
fileset(dir:"src/dist") {
include(name:"**/*.so")
include(name:"**/*.dll")
include(name:"**/*.jnilib")
include(name:"**/*.dylib")
}
}
ant.delete(dir:"src/dist/bin/META-INF")
}

task unpackNatives(dependsOn: cleanOldNatives) << {
configurations.compile.files.each { file ->
if (file.name.matches(".*native.*")) {
logger.debug("Unpacking " + file.name + " into src/dist...")
// This destination is to work with the plugin conventions
ant.unzip(src:file, dest:"src/dist/bin", overwrite:"true")
}
}
ant.delete(dir:"src/dist/bin/META-INF")
}

// Ensure the source directory doesn't have natives in it, because we don't want to check those as source
task prepForSync(dependsOn: [clean, cleanOldNatives])

[/code]

_________________
"People are easily amused by quotes." - Some guy with a cool-sounding name


Last edited by ssfsx17 on Sun Apr 29, 2012 6:27 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed Jan 18, 2012 11:43 pm 
Offline

Joined: Sun Oct 12, 2008 8:16 pm
Posts: 7
Fixed the first build.gradle for those who tried it and discovered it didn't work at runtime. More fixes probably coming soon.

_________________
"People are easily amused by quotes." - Some guy with a cool-sounding name


Top
 Profile  
 
PostPosted: Sun Apr 29, 2012 6:22 am 
Offline

Joined: Sun Oct 12, 2008 8:16 pm
Posts: 7
I've tested this with the latest source in bitbucket and it seems to work so far.

If there's any demand for it, I will also demonstrate how to do signing and webstart support.

_________________
"People are easily amused by quotes." - Some guy with a cool-sounding name


Top
 Profile  
 
PostPosted: Thu Feb 07, 2013 2:16 pm 
Offline

Joined: Tue Jun 14, 2011 2:49 am
Posts: 4
I have not yet tried this since I am at work at the moment, but has this been kept up to date with the latest slick/lwjgl? I'd be interested to try it out.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group