Newer
Older
import com.badlogic.gdx.tools.texturepacker.TexturePacker
//mavenCentral()
jcenter{
url "http://jcenter.bintray.com/"
}
}
dependencies {
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'org.robovm:robovm-gradle-plugin:1.2.0'
classpath 'de.felixschulze.gradle:gradle-spoon-plugin:2.1'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'com.novoda:gradle-android-command-plugin:1.3.0'
classpath "com.badlogicgames.gdx:gdx-tools:1.6.1"
final assetsDirName = "assets"
final assetsSourceDirName = "src"
final assetsDestinationDirName = "dest"
final assetsGameDirectory = "game"
final assetsGameGlobalDirectory = "_global"
final assetsGameCommonDifficultyDirectory = "common"
final assetsGameExcludedDirectory = "excluded"
final String ASSETS_DOWNLOAD_URL = "https://www.tablexia.cz/static/assets/"
System.setProperty("javax.net.ssl.trustStore", new File("${project(":android").projectDir.absolutePath}/assets/keystore/tablexiaTrustKeystore").getAbsolutePath());
System.setProperty("javax.net.ssl.trustStorePassword", "tablexia");
assetsChecksumPattern = "\"=======ASSETS_CHECKSUM=======\""
assetsPackDir = new File("${rootProject.buildDir}/${assetsDirName}/pack/")
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = getVersionNameFromGit()
tablexiaVersionName = getVersionNameFromGit()
tablexiaVersionCode = getVersionCodeFromGit()
applicationIdRelease = 'cz.nic.tablexia'
applicationIdDebugSuffix = '.debug'
applicationIdDebug = applicationIdRelease + applicationIdDebugSuffix
applicationIdDevelSuffix = '.devel'
applicationIdDevel = applicationIdRelease + applicationIdDevelSuffix
gdxVersion = '1.6.1'
gdxUtilsVersion = '0.13.1'
roboVMVersion = '1.2.0'
box2DLightsVersion = '1.3'
ashleyVersion = '1.3.1'
aiVersion = '1.4.0'
sqlDroidVersion = '1.0.3'
sqlLiteJdbcVersion = '3.8.10.1'
androidSupportV4Version = '22.0.0'
googlePlayServicesVersion = '8.3.+'
jcenter {
url "http://jcenter.bintray.com/"
}
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
task clean << {
delete "${buildDir}"
}
task prepareAssets {
def sourceDir = new File(project(":core").projectDir.absolutePath + "/${assetsDirName}")
inputs.dir(sourceDir.absolutePath)
outputs.dir("${buildDir}/${assetsDirName}/${assetsSourceDirName}/")
doLast {
sourceDir.eachDir() { dir ->
if (!dir.name.equals('common')) {
String dirName = dir.getName()
String destDir = "${buildDir}/${assetsDirName}/${assetsSourceDirName}/${dirName}"
task("${name}_${dirName}", type: Copy) {
from sourceDir.absolutePath + "/common"
from dir.absolutePath
into destDir
}.execute()
}
}
}
}
task prepareSoundAssets(dependsOn: prepareAssets) {
def assetsDir = new File("${buildDir}/${assetsDirName}/")
inputs.dir("${assetsDir.absolutePath}/${assetsSourceDirName}/")
outputs.dir("${assetsDir.absolutePath}/${assetsDestinationDirName}/")
doLast {
new File("${assetsDir}/${assetsSourceDirName}/").eachDir() { langDir ->
langDir.eachDir() { sectionDir ->
sectionDir.eachDir() { atlasDir ->
task("${name}_" + sectionDir.name + "_" + atlasDir.name + "_" + langDir.name, type: Copy) {
from atlasDir
into "${buildDir}/${assetsDirName}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/"
include '**/*.mp3'
includeEmptyDirs false
eachFile { FileCopyDetails fcd ->
fcd.setPath(fcd.getRelativePath().toString().replace(File.separator, '.'))
}
Matyáš Latner
committed
outputs.upToDateWhen { false }
}.execute()
}
}
}
}
}
task prepareJsonAssets(dependsOn: prepareAssets) {
def assetsDir = new File("${buildDir}/${assetsDirName}/")
inputs.dir("${assetsDir.absolutePath}/${assetsSourceDirName}/")
outputs.dir("${assetsDir.absolutePath}/${assetsDestinationDirName}/")
doLast {
new File("${assetsDir}/${assetsSourceDirName}/").eachDir() { langDir ->
langDir.eachDir() { sectionDir ->
sectionDir.eachDir() { atlasDir ->
task("${name}_" + sectionDir.name + "_" + atlasDir.name + "_" + langDir.name, type: Copy) {
from atlasDir
into "${buildDir}/${assetsDirName}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/"
include '**/*.json'
includeEmptyDirs false
eachFile { FileCopyDetails fcd ->
fcd.setPath(fcd.getRelativePath().toString().replace(File.separator, '.'))
}
}.execute()
}
}
}
}
}
task prepareGraphicAssets(dependsOn: prepareAssets) {
def assetsDir = new File("${buildDir}/${assetsDirName}/")
inputs.dir("${assetsDir.absolutePath}/${assetsSourceDirName}/")
outputs.dir("${assetsDir.absolutePath}/${assetsDestinationDirName}/")
doLast {
TexturePacker.Settings settings = new TexturePacker.Settings();
Matyáš Latner
committed
settings.maxWidth = 1024;
settings.maxHeight = 1024;
settings.combineSubdirectories = true;
settings.filterMin = Texture.TextureFilter.Linear;
settings.filterMag = Texture.TextureFilter.Linear;
new File("${assetsDir.absolutePath}/${assetsSourceDirName}/").eachDir() { langDir ->
langDir.eachDir() { sectionDir ->
sectionDir.eachDir() { atlasDir ->
if (assetsGameDirectory.equals(sectionDir.name) && !assetsGameGlobalDirectory.equals(atlasDir.name)) {
atlasDir.eachDir() { difficultyDir ->
if (!assetsGameExcludedDirectory.equals(difficultyDir.name)) {
String packFileName = assetsGameCommonDifficultyDirectory.equals(difficultyDir.name) ? atlasDir.name : difficultyDir.name;
TexturePacker.process(settings,
"${difficultyDir}",
"${assetsDir.absolutePath}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/",
"${packFileName}")
} else {
task("${name}_" + sectionDir.name + "_" + langDir.name + "_" + atlasDir.name + "_" + difficultyDir.name, type: Copy) {
from difficultyDir
into "${buildDir}/${assetsDirName}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/${difficultyDir.name}"
include '**/*'
includeEmptyDirs false
outputs.upToDateWhen { false }
}.execute()
}
}
} else {
TexturePacker.process(settings,
"${atlasDir}",
"${assetsDir.absolutePath}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/",
"${atlasDir.name}")
}
task zipAssets(dependsOn: [prepareSoundAssets, prepareGraphicAssets, prepareJsonAssets]) {
doLast {
new File(project(":core").projectDir.absolutePath + "/${assetsDirName}").eachDir() { dir ->
if (!dir.name.equals('common')) {
task("${name}_${dir.name}", type: Zip) {
archiveName = dir.getName() + "_SNAPSHOT.zip"
destinationDir = rootProject.ext.assetsPackDir
from "${buildDir}/${assetsDirName}/${assetsDestinationDirName}/${dir.name}"
}.execute()
task processAssets(dependsOn: [':util:checksum:runChecksum', ':util:checksum:runAssetsArchivesChecksum']) {
doLast {
if (project.hasProperty('TABLEXIA_ASSETS_SERVER_USER') && project.hasProperty('TABLEXIA_ASSETS_SERVER_URL')) {
def data = new URL(ASSETS_DOWNLOAD_URL).getText()
rootProject.ext.assetsPackDir.eachFile() { file ->
String fileName = file.getName()
String[] fileNameParts = fileName.split("_SNAPSHOT\\.");
String packageName = "${fileNameParts[0]}_${assetsChecksum[fileNameParts[0]]}.${fileNameParts[1]}";
boolean isProductionVersion = project.hasProperty('TABLEXIA_ASSETS_UPLOAD_PRODUCTION') && Boolean.valueOf(TABLEXIA_ASSETS_UPLOAD_PRODUCTION).booleanValue()
String uploadFileName = isProductionVersion ? packageName : fileName
if (!isProductionVersion || !data.contains(packageName)) {
println "AssetsUploader: UPLOADING FILE: ${uploadFileName}"
task ("${name}_${packageName}", type:Exec) {
workingDir "${rootProject.projectDir}"
commandLine 'scp', file.getAbsolutePath(), "${TABLEXIA_ASSETS_SERVER_USER}@${TABLEXIA_ASSETS_SERVER_URL}/${uploadFileName}"
standardOutput = new ByteArrayOutputStream()
ext.output = {
return standardOutput.toString()
}
}.execute()
} else {
println "AssetsUploader: FILE: ${packageName} EXISTS ON SERVER -> SKIPPING UPLOAD"
}
}
}
}
}
def getVersionNameFromGit() {
def stdout = new ByteArrayOutputStream()
String branchName = getBranchNameFromGit()
commandLine 'git', 'describe', '--abbrev=0', '--tags'
standardOutput = stdout
}
String result = stdout.toString().trim();
// for non release branches add number of commits and branch name
if (!"master".equals(branchName)) {
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', "${result}..HEAD", '--count'
standardOutput = stdout
}
String numberOfCommits = stdout.toString().trim()
if ("devel".equals(branchName)) {
// add only number of commits for devel branch
result = "${result}-${numberOfCommits}"
} else {
// add branch name and number of commits
result = "${result}-${branchName}-${numberOfCommits}"
}
}
return result
def getVersionCodeFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--format=%at'
standardOutput = stdout
}
return stdout.toString().trim().toInteger()
}
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--contains', '--all', 'HEAD'
String branchString = stdout.toString().trim()
return branchString.contains("/") ? branchString.substring(branchString.lastIndexOf("/") + 1) : branchString
def getMapConvertedToString(Map map) {
String result = "";
map.each { key, value ->
if (result.size() > 0) result = result + ","
result = result + "$key:$value"
}
return result;
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.jcabi:jcabi-manifests:1.1"
compile "org.xerial:sqlite-jdbc:$sqlLiteJdbcVersion"
apply plugin: 'android-sdk-manager'
apply plugin: 'android-command'
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "net.engio:mbassador:$mbassadorVersion"
compile "org.sqldroid:sqldroid:$sqlDroidVersion"
compile "com.android.support:support-v4:$androidSupportV4Version"
compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
compile files('libs/FlurryAnalytics-6.1.0.jar')
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
testCompile 'org.robolectric:robolectric:2.3'
androidTestCompile "com.squareup.spoon:spoon-client:1.1.7"
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.3.1'
}
}
project(":ios") {
apply plugin: "java"
apply plugin: "robovm"
configurations { natives }
dependencies {
compile project(":core")
compile "org.robovm:robovm-rt:${roboVMVersion}"
compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
}
}
project(":core") {
apply plugin: "java"
sourceSets.test.java.srcDirs = ["test/"]
tasks.processResources.dependsOn processAssets
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "net.dermetfan.libgdx-utils:libgdx-utils:$gdxUtilsVersion"
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
compile "com.google.guava:guava:$guavaVersion"
testCompile "junit:junit:4.11"
testCompile "com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion"
testCompile "com.badlogicgames.gdx:gdx:$gdxVersion"
testCompile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
}
}
tasks.eclipse.doLast {
delete ".project"