Commit 7ca380ef authored by Matyáš Latner's avatar Matyáš Latner

#1 Automatic build of iOS Tablexia version

 * Tablexia iOS version automatic build
 * automatic creation of debug and release build types
 * different application ID for debug and release build types
parent 9e794ce2
......@@ -64,3 +64,6 @@ build/
## OS Specific
.DS_Store
## iOS
ios/robovm.properties
......@@ -15,8 +15,8 @@ android {
}
defaultConfig {
versionName version
versionCode getVersionCodeFromGit()
versionName tablexiaVersionName
versionCode tablexiaVersionCode
applicationId rootProject.applicationIdRelease
}
......@@ -32,7 +32,7 @@ android {
applicationVariants.all { variant ->
variant.outputs.each { output ->
def file = output.outputFile
output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk").replace("android", appName))
output.outputFile = new File(file.parent, file.name.replace(".apk", "-" + tablexiaVersionName + ".apk").replace("android", appName))
}
}
......@@ -55,15 +55,6 @@ android {
}
}
def getVersionCodeFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--format=%at'
standardOutput = stdout
}
return stdout.toString().trim().toInteger()
}
// needed to add JNI shared libraries to APK when compiling on CLI
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniFolders = new HashSet<File>()
......
......@@ -15,12 +15,15 @@ allprojects {
apply plugin: "idea"
version = getVersionNameFromGit()
project.extensions.add("applicationIdRelease", "cz.nic.tablexia")
project.extensions.add("applicationIdDebugSuffix", ".debug")
project.extensions.add("applicationIdDebug", applicationIdRelease + applicationIdDebugSuffix)
ext {
appName = 'Tablexia'
tablexiaVersionName = getVersionNameFromGit()
tablexiaVersionCode = getVersionCodeFromGit()
applicationIdRelease = 'cz.nic.tablexia'
applicationIdDebugSuffix = '.debug'
applicationIdDebug = applicationIdRelease + applicationIdDebugSuffix
gdxVersion = '1.5.2'
gdxUtilsVersion = '0.9.1'
mbassadorVersion = '1.2.0'
......@@ -46,6 +49,15 @@ def getVersionNameFromGit() {
return stdout.toString().trim()
}
def getVersionCodeFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '-1', '--format=%at'
standardOutput = stdout
}
return stdout.toString().trim().toInteger()
}
task zipAssets(type:Zip) {
new File(project(":core").projectDir.absolutePath + "/assets").eachDir() { dir ->
......
......@@ -24,7 +24,7 @@ task debugJar(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
attributes 'Build-Type': 'debug'
attributes 'Version-Name': version
attributes 'Version-Name': tablexiaVersionName
attributes 'Application-Id': rootProject.applicationIdDebug
}
}
......@@ -39,7 +39,7 @@ task releaseJar(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
attributes 'Build-Type': 'release'
attributes 'Version-Name': version
attributes 'Version-Name': tablexiaVersionName
attributes 'Application-Id': rootProject.applicationIdRelease
}
}
......
......@@ -22,6 +22,8 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>${app.build}</string>
<key>cz.nic.tablexia.BuildType</key>
<string>${app.buildtype}</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
......
......@@ -7,6 +7,27 @@ ext {
mainClassName = "cz.nic.tablexia.IOSLauncher"
}
// Updates or create a robovm.properties file.
def updateRoboVMProperties(String buildType, String applicationId) {
Properties props = new Properties()
def propsFile = file('robovm.properties')
if (!propsFile.exists()) {
propsFile.createNewFile();
}
props.load(propsFile.newDataInputStream())
props.setProperty('app.name', appName)
props.setProperty('app.id', applicationId)
props.setProperty('app.mainclass', mainClassName)
props.setProperty('app.version', tablexiaVersionName)
props.setProperty('app.buildtype', buildType)
props.setProperty('app.build', '' + tablexiaVersionCode)
props.setProperty('app.executable', appName + '-' + buildType + '-' + tablexiaVersionName)
props.store(propsFile.newDataOutputStream(), '')
}
// Extracts native libs (*.a) from the native-ios.jar and places them
// under build/libs/ios/.
task copyNatives << {
......@@ -49,8 +70,26 @@ task updateRoboVMXML << {
printer.print(config)
}
tasks.create(name: "createDebugIPA", type: org.robovm.gradle.tasks.CreateIPATask) {
doFirst {
updateRoboVMProperties("debug", applicationIdDebug)
}
}
tasks.create(name: "createReleaseIPA", type: org.robovm.gradle.tasks.CreateIPATask) {
doFirst {
updateRoboVMProperties("release", applicationIdRelease)
}
}
task createIPAFiles() {
dependsOn createDebugIPA
dependsOn createReleaseIPA
}
updateRoboVMXML.dependsOn copyNatives
build.dependsOn updateRoboVMXML
build.dependsOn createDebugIPA
build.dependsOn createReleaseIPA
tasks.eclipse.dependsOn updateRoboVMXML
launchIPhoneSimulator.dependsOn build
......@@ -58,6 +97,8 @@ launchIPadSimulator.dependsOn build
launchIOSDevice.dependsOn build
createIPA.dependsOn build
createDebugIPA.dependsOn updateRoboVMXML
createReleaseIPA.dependsOn updateRoboVMXML
eclipse.project {
name = appName + "-ios"
......
......@@ -34,8 +34,8 @@
</forceLinkClasses>
<libs>
<lib>build/libs/ios/libgdx-freetype.a</lib>
<lib>build/libs/ios/libObjectAL.a</lib>
<lib>build/libs/ios/libgdx.a</lib>
<lib>build/libs/ios/libObjectAL.a</lib>
</libs>
<frameworks>
<framework>UIKit</framework>
......
package cz.nic.tablexia;
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.uikit.UIApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import java.util.Locale;
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.foundation.NSBundle;
import org.robovm.apple.foundation.NSDictionary;
import org.robovm.apple.foundation.NSString;
import org.robovm.apple.uikit.UIApplication;
import cz.nic.tablexia.Tablexia;
import java.util.Locale;
public class IOSLauncher extends IOSApplication.Delegate {
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
return new IOSApplication(new Tablexia(null, Locale.getDefault(), null, null), config);
NSDictionary infoDictionary = NSBundle.getMainBundle().getInfoDictionary();
String buildType = infoDictionary.get(new NSString("cz.nic.tablexia.BuildType")).toString();
String versionName = infoDictionary.get(new NSString("CFBundleShortVersionString")).toString();
String applicationId = infoDictionary.get(new NSString("CFBundleIdentifier")).toString();
return new IOSApplication(new Tablexia(buildType, Locale.getDefault(), versionName, applicationId), config);
}
public static void main(String[] argv) {
......
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