An error occurred while loading the file. Please try again.
-
v.tarantik authoreda3add3d4
build.gradle 14.23 KiB
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.tools.texturepacker.TexturePacker
buildscript {
repositories {
mavenCentral()
jcenter()
}
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 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");
ext {
assetsChecksumPattern = "\"=======ASSETS_CHECKSUM=======\""
assetsChecksum = [:]
assetsPackDir = new File("${rootProject.buildDir}/${assetsDirName}/pack/")
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = getVersionNameFromGit()
ext {
appName = 'Tablexia'
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'
mbassadorVersion = '1.2.0'
roboVMVersion = '1.2.0'
box2DLightsVersion = '1.3'
ashleyVersion = '1.3.1'
aiVersion = '1.4.0'
sqlDroidVersion = '1.0.3'
sqlLiteJdbcVersion = '3.8.10.1'
guavaVersion = '18.0'
jacksonVersion = '2.6.1'
}
repositories {
mavenCentral()
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}_" + 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, '.'))
}
}.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}_" + 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();
settings.pot = false;
settings.maxWidth = 2048;
settings.maxHeight = 2048;
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 ->
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()
// get last tag in current branch
exec {
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 getBranchNameFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--contains', '--all', 'HEAD'
standardOutput = stdout
}
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"
}
}
project(":android") {
apply plugin: 'android-sdk-manager'
apply plugin: "android"
apply plugin: "spoon"
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"
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(":html") {
apply plugin: "gwt"
apply plugin: "war"
dependencies {
compile project(":core")
compile "net.engio:mbassador:$mbassadorVersion"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
compile "net.dermetfan.libgdx-utils:libgdx-utils:$gdxUtilsVersion"
}
}
*/
project(":core") {
apply plugin: "java"
sourceSets.test.java.srcDirs = ["test/"]
tasks.processResources.dependsOn processAssets
dependencies {
compile project(":util:checksum")
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"
compile "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
compile "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
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"
}