Commit b82086eb authored by Vitaliy Vashchenko's avatar Vitaliy Vashchenko

#884 fixed hd checksum task being executed when hd assets are not needed. Added new HD assets

parent 6a4704a4
...@@ -201,29 +201,35 @@ task prepareJsonAssets(dependsOn: prepareAssets) { ...@@ -201,29 +201,35 @@ task prepareJsonAssets(dependsOn: prepareAssets) {
} }
} }
task copyDefaulAssets(){
} task prepareHdAssets(dependsOn: prepareAssets) {
task prepareHdAssets(dependsOn: [prepareAssets, prepareSoundAssets, prepareJsonAssets]) {
def sourceDir = new File("${buildDir}/${assetsDirName}/src/") def sourceDir = new File("${buildDir}/${assetsDirName}/src/")
def assetsDir = new File("${buildDir}/${assetsDirName}/")
def hdSourceDir = new File(project(":desktop").projectDir.absolutePath + "/${assetsDirName}/${assetsHdDirName}") def hdSourceDir = new File(project(":desktop").projectDir.absolutePath + "/${assetsDirName}/${assetsHdDirName}")
inputs.dir(sourceDir.absolutePath) inputs.dir(hdSourceDir.absolutePath)
outputs.dir("${buildDir}/${assetsDirName}/${assetsHdDirName}/${assetsSourceDirName}/") outputs.dir("${buildDir}/${assetsDirName}/${assetsHdDirName}/${assetsSourceDirName}/")
outputs.upToDateWhen { false }
doLast { doLast {
if (project.hasProperty('TABLEXIA_HD_ASSETS') && Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) { if (project.hasProperty('TABLEXIA_HD_ASSETS') && Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) {
new File("${assetsDir}/${assetsSourceDirName}/").eachDir() { langDir ->
task("copyingDefaultDest", type: Copy) { langDir.eachDir() { sectionDir ->
from buildDir.absolutePath + "/${assetsDirName}/${assetsDestinationDirName}/" sectionDir.eachDir() { atlasDir ->
into buildDir.absolutePath + "/${assetsDirName}/${assetsHdDirName}/${assetsDestinationDirName}/" task("${name}_sounds_" + sectionDir.name + "_" + atlasDir.name + "_" + langDir.name, type: Copy) {
}.execute() from atlasDir
into "${buildDir}/${assetsDirName}/${assetsHdDirName}/${assetsDestinationDirName}/${langDir.name}/${sectionDir.name}/${atlasDir.name}/"
include '**/*.mp3', '**/*.json'
includeEmptyDirs false
eachFile { FileCopyDetails fcd ->
fcd.setPath(fcd.getRelativePath().toString().replace('/', '.'))
}
outputs.upToDateWhen { false }
}.execute()
}
}
}
sourceDir.eachDir() { dir -> sourceDir.eachDir() { dir ->
...@@ -328,9 +334,8 @@ task zipAssets(dependsOn: [prepareSoundAssets, prepareGraphicAssets, prepareJson ...@@ -328,9 +334,8 @@ task zipAssets(dependsOn: [prepareSoundAssets, prepareGraphicAssets, prepareJson
task prepareHdGraphicAssets(dependsOn: prepareHdAssets) { task prepareHdGraphicAssets(dependsOn: prepareHdAssets) {
def assetsDir = new File("${buildDir}/${assetsDirName}/${assetsHdDirName}/") def assetsDir = new File("${buildDir}/${assetsDirName}/${assetsHdDirName}/")
inputs.dir("${assetsDir.absolutePath}/${assetsHdDirName}/${assetsSourceDirName}/") inputs.dir("${assetsDir.absolutePath}/${assetsSourceDirName}/")
outputs.dir("${assetsDir.absolutePath}/${assetsHdDirName}/${assetsDestinationDirName}/") outputs.dir("${assetsDir.absolutePath}/${assetsDestinationDirName}/")
outputs.upToDateWhen { false }
doLast { doLast {
if (project.hasProperty('TABLEXIA_HD_ASSETS') && Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) { if (project.hasProperty('TABLEXIA_HD_ASSETS') && Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) {
...@@ -390,13 +395,6 @@ task prepareHdGraphicAssets(dependsOn: prepareHdAssets) { ...@@ -390,13 +395,6 @@ task prepareHdGraphicAssets(dependsOn: prepareHdAssets) {
} }
task zipHdAssets(dependsOn: prepareHdGraphicAssets) { task zipHdAssets(dependsOn: prepareHdGraphicAssets) {
def assetsDir = new File("${buildDir}/${assetsDirName}/")
inputs.dir("${assetsDir.absolutePath}/${assetsHdDirName}/${assetsSourceDirName}/")
outputs.dir("${assetsDir.absolutePath}/${assetsHdDirName}/${assetsDestinationDirName}/")
outputs.upToDateWhen { false }
doLast { doLast {
if (project.hasProperty('TABLEXIA_HD_ASSETS') && Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) { if (project.hasProperty('TABLEXIA_HD_ASSETS') && Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) {
new File(project(":core").projectDir.absolutePath + "/${assetsDirName}/").eachDir() { dir -> new File(project(":core").projectDir.absolutePath + "/${assetsDirName}/").eachDir() { dir ->
...@@ -448,17 +446,23 @@ task processAssets(dependsOn: [':util:checksum:runChecksum', ':util:checksum:run ...@@ -448,17 +446,23 @@ task processAssets(dependsOn: [':util:checksum:runChecksum', ':util:checksum:run
task prepareHdPack(dependsOn: [':util:checksum:runHdChecksum', ':util:checksum:runHdAssetsArchivesChecksum']) { task prepareHdPack(dependsOn: [':util:checksum:runHdChecksum', ':util:checksum:runHdAssetsArchivesChecksum']) {
doLast { doLast {
//prepare and upload hd packs //prepare and upload hd packs
if (project.hasProperty('TABLEXIA_HD_ASSETS_UPLOAD_USER') && project.hasProperty('TABLEXIA_ASSETS_UPLOAD_URL') && project.hasProperty('TABLEXIA_ASSETS_UPLOAD') && Boolean.valueOf(TABLEXIA_ASSETS_UPLOAD).booleanValue()) { if (project.hasProperty('TABLEXIA_HD_ASSETS') &&
project.hasProperty('TABLEXIA_ASSETS_UPLOAD_USER') &&
project.hasProperty('TABLEXIA_ASSETS_UPLOAD_URL') &&
project.hasProperty('TABLEXIA_ASSETS_UPLOAD') &&
Boolean.valueOf(TABLEXIA_ASSETS_UPLOAD).booleanValue() &&
Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) {
def data = new URL(project.assetsDownloadUrl).getText() def data = new URL(project.assetsDownloadUrl).getText()
rootProject.ext.assetsHdPackDir.eachFile() { file -> rootProject.ext.assetsHdPackDir.eachFile() { file ->
String fileName = file.getName() String fileName = file.getName()
String[] fileNameParts = fileName.split("_SNAPSHOT\\."); String[] fileNameParts = fileName.split("_SNAPSHOT");
String packageName = "${fileNameParts[0]}_${assetsHdChecksum[fileNameParts[0]]}.${fileNameParts[1]}"; String packageName = "${fileNameParts[0]}_${assetsHdChecksum[fileNameParts[0]]}${fileNameParts[1]}";
if (!data.contains(packageName)) { if (!data.contains(packageName)) {
String assetsUploadPath = "${project.assetsUploadURL}${packageName}" String assetsUploadPath = "${project.assetsDebugURLPart}${packageName}"
println "AssetsUploader: UPLOADING FILE: ${project.assetsDebugURLPart}${packageName}" println "AssetsUploader: UPLOADING FILE: ${project.assetsDebugURLPart}${packageName}"
task ("${name}_${packageName}", type:Exec) { task("${name}_${packageName}", type: Exec) {
workingDir "${rootProject.projectDir}" workingDir "${rootProject.projectDir}"
commandLine 'scp', file.getAbsolutePath(), assetsUploadPath commandLine 'scp', file.getAbsolutePath(), assetsUploadPath
standardOutput = new ByteArrayOutputStream() standardOutput = new ByteArrayOutputStream()
...@@ -571,6 +575,7 @@ def getMapConvertedToString(Map map) { ...@@ -571,6 +575,7 @@ def getMapConvertedToString(Map map) {
project(":desktop") { project(":desktop") {
apply plugin: "java" apply plugin: "java"
tasks.processResources.dependsOn prepareHdPack
dependencies { dependencies {
compile project(":core") compile project(":core")
...@@ -623,7 +628,6 @@ project(":core") { ...@@ -623,7 +628,6 @@ project(":core") {
sourceSets.test.java.srcDirs = ["test/"] sourceSets.test.java.srcDirs = ["test/"]
tasks.processResources.dependsOn processAssets tasks.processResources.dependsOn processAssets
tasks.processResources.dependsOn prepareHdPack
dependencies { dependencies {
compile project(":util:checksum") compile project(":util:checksum")
......
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.tools.texturepacker.TexturePacker
import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask import edu.sc.seis.launch4j.tasks.Launch4jLibraryTask
import groovy.io.FileType import groovy.io.FileType
import org.apache.tools.ant.filters.ReplaceTokens import org.apache.tools.ant.filters.ReplaceTokens
......
...@@ -66,43 +66,47 @@ task runAssetsArchivesChecksum(dependsOn: [classes, rootProject.tasks.zipAssets] ...@@ -66,43 +66,47 @@ task runAssetsArchivesChecksum(dependsOn: [classes, rootProject.tasks.zipAssets]
task runHdChecksum(dependsOn: [classes, rootProject.tasks.prepareHdGraphicAssets]) { task runHdChecksum(dependsOn: [classes, rootProject.tasks.prepareHdGraphicAssets]) {
doLast { doLast {
def sourceDir = new File("${rootProject.buildDir}/assets/hd/dest/") if (project.hasProperty("TABLEXIA_HD_ASSETS") && Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) {
sourceDir.eachDir() { dir -> def sourceDir = new File("${rootProject.buildDir}/assets/hd/dest/")
String dirName = dir.getName() sourceDir.eachDir() { dir ->
task("${name}_${dirName}", type: JavaExec) { String dirName = dir.getName()
main = MAIN_CLASS task("${name}_${dirName}", type: JavaExec) {
args = [dir]
classpath sourceSets.main.output.classesDir
classpath += sourceSets.main.runtimeClasspath
def stdout = new ByteArrayOutputStream()
standardOutput = stdout
doLast {
rootProject.ext.assetsHdChecksum[dirName] = stdout.toString().trim()
}
}.execute()
}
}
}
task runHdAssetsArchivesChecksum(dependsOn: [classes, rootProject.tasks.zipHdAssets]) {
doLast {
rootProject.ext.assetsHdPackDir.eachFile() { file ->
String fileName = file.getName()
if (fileName.endsWith(".zip")) {
task("${name}_${fileName}", type: JavaExec) {
main = MAIN_CLASS main = MAIN_CLASS
args = [file] args = [dir]
classpath sourceSets.main.output.classesDir classpath sourceSets.main.output.classesDir
classpath += sourceSets.main.runtimeClasspath classpath += sourceSets.main.runtimeClasspath
def stdout = new ByteArrayOutputStream() def stdout = new ByteArrayOutputStream()
standardOutput = stdout standardOutput = stdout
doLast { doLast {
(new File("${assetsHdPackDir.getAbsolutePath()}/${fileName.split("\\.")[0]}.checksum")).write(stdout.toString().trim()); rootProject.ext.assetsHdChecksum[dirName] = stdout.toString().trim()
} }
}.execute() }.execute()
} }
} }
} }
}
task runHdAssetsArchivesChecksum(dependsOn: [classes, rootProject.tasks.zipHdAssets]) {
doLast {
if (project.hasProperty("TABLEXIA_HD_ASSETS") && Boolean.valueOf(TABLEXIA_HD_ASSETS).booleanValue()) {
rootProject.ext.assetsHdPackDir.eachFile() { file ->
String fileName = file.getName()
if (fileName.endsWith(".zip")) {
task("${name}_${fileName}", type: JavaExec) {
main = MAIN_CLASS
args = [file]
classpath sourceSets.main.output.classesDir
classpath += sourceSets.main.runtimeClasspath
def stdout = new ByteArrayOutputStream()
standardOutput = stdout
doLast {
(new File("${assetsHdPackDir.getAbsolutePath()}/${fileName.split("\\.")[0]}.checksum")).write(stdout.toString().trim());
}
}.execute()
}
}
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment