Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TIMOB-10752] Final touches on the module create command.
- Loading branch information
Showing
25 changed files
with
271 additions
and
138 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
android/templates/module/default/hooks/android-module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/** | ||
* @overview | ||
* Hook that performa Android specific functions when creating an Android module. | ||
* | ||
* @copyright | ||
* Copyright (c) 2014 by Appcelerator, Inc. All Rights Reserved. | ||
* | ||
* @license | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
|
||
var fs = require('fs'), | ||
path = require('path'), | ||
wrench = require('wrench'); | ||
|
||
exports.cliVersion = '>=3.2'; | ||
|
||
exports.init = function (logger, config, cli, appc) { | ||
var __ = appc.i18n(__dirname).__; | ||
|
||
cli.on('create.copyFiles.platform.android', { | ||
pre: function (data, callback) { | ||
// create the build/.apt_generated directory | ||
var aptgenDir = path.join(this.projectDir, 'android', 'build', '.apt_generated'); | ||
fs.existsSync(aptgenDir) || wrench.mkdirSyncRecursive(aptgenDir); | ||
|
||
// determine the minimum supported Android SDK version | ||
var packageJsonFile = (function scan(dir) { | ||
var file = path.join(dir, 'package.json'); | ||
if (fs.existsSync(file)) { | ||
return file; | ||
} | ||
dir = path.dirname(dir); | ||
return dir != '/' && scan(dir); | ||
}(__dirname)), | ||
packageJson = require(packageJsonFile), | ||
minAndroidAPILevel = parseInt(appc.version.parseMin(packageJson.vendorDependencies['android sdk'])); | ||
|
||
var android = require('titanium-sdk/lib/android'); | ||
logger.debug(__('Detecting Android environment...')); | ||
android.detect(this.config, null, function (results) { | ||
// find all targets that satisify the minimum supported Android SDK, prefer versions with Google APIs | ||
var apis = {}; | ||
Object.keys(results.targets).forEach(function (idx) { | ||
var target = results.targets[idx], | ||
apiLevel = target['based-on'] && target['based-on']['api-level'] ? ~~target['based-on']['api-level'] : ~~target['api-level'], | ||
gapi = target.type == 'add-on' && /google/i.test(target.name); | ||
|
||
if (apiLevel >= minAndroidAPILevel && (target.type == 'platform' || gapi)) { | ||
apis[apiLevel] || (apis[apiLevel] = {}); | ||
if (typeof apis[apiLevel].idx == 'undefined' || gapi) { | ||
apis[apiLevel].idx = idx; | ||
} | ||
|
||
if (gapi) { | ||
apis[apiLevel].googleAPIPath = target.path; | ||
} else { | ||
apis[apiLevel].platformPath = target.path; | ||
} | ||
} | ||
}); | ||
|
||
var libs = [], | ||
targetAPILevel = Object.keys(apis).sort().shift(), | ||
api = targetAPILevel && apis[targetAPILevel], | ||
target = api && results.targets[api.idx]; | ||
|
||
// add the android.jar | ||
if (target && target.androidJar) { | ||
libs.push(target.androidJar); | ||
} | ||
|
||
// add the maps.jar if we have Google APIs | ||
if (target && target.libraries && target.libraries['com.google.android.maps']) { | ||
libs.push(path.join(target.path, 'libs', target.libraries['com.google.android.maps'].jar)); | ||
} | ||
|
||
// add the Titanium specific jars | ||
libs.push( | ||
path.join(this.sdk.path, 'android', 'titanium.jar'), | ||
path.join(this.sdk.path, 'android', 'kroll-common.jar'), | ||
path.join(this.sdk.path, 'android', 'kroll-apt.jar') | ||
); | ||
|
||
// update the variables | ||
var variables = data.args[0]; | ||
|
||
// build the classpath | ||
variables.classpath = libs.map(function (lib) { | ||
return '<classpathentry kind="lib" path="' + lib + '"/>'; | ||
}).join('\n\t'); | ||
|
||
// set the Android platform path | ||
variables.androidPlatformPath = api && api.platformPath || ''; | ||
|
||
// set the Google APIs path | ||
variables.googleAPIPath = api && api.googleAPIPath || ''; | ||
|
||
// set the Titanium Android platform path | ||
variables.tisdkAndroidPath = path.join(data.args[0].tisdkPath, 'android'); | ||
|
||
callback(); | ||
}.bind(this)); | ||
} | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...id/templates/module/default/template/android/.settings/org.eclipse.jdt.apt.core.prefs.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#Thu Sep 02 15:18:34 CDT 2010 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.apt.aptEnabled=true | ||
org.eclipse.jdt.apt.genSrcDir=.apt_generated | ||
org.eclipse.jdt.apt.reconcileEnabled=true | ||
|
||
org.eclipse.jdt.apt.processorOptions/kroll.jsonFile=<%- moduleName %>.json |
3 changes: 3 additions & 0 deletions
3
android/templates/module/default/template/android/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Thu Sep 02 15:18:34 CDT 2010 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.processAnnotations=enabled |
6 changes: 3 additions & 3 deletions
6
android/templates/module/default/template/android/build.properties.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
titanium.platform=__SDK_ANDROID__ | ||
android.platform=___ANDROID_PLATFORM___ | ||
google.apis=___GOOGLE_APIS___ | ||
titanium.platform=<%- tisdkAndroidPath %> | ||
android.platform=<%- androidPlatformPath %> | ||
google.apis=<%- googleAPIPath %> |
32 changes: 30 additions & 2 deletions
32
android/templates/module/default/template/android/build.xml.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
<project name="__PROJECT_SHORT_NAME_LOWER__" default="dist"> | ||
<project name="<%- moduleName.toLowerCase() %>" default="dist"> | ||
<description> | ||
Ant build script for Titanium Android module __PROJECT_SHORT_NAME__ | ||
Ant build script for Titanium Android module <%- moduleName %> | ||
</description> | ||
|
||
<property name="ti.module.root" location="${basedir}"/> | ||
<property file="build.properties" /> | ||
|
||
<!-- Copy documentation subdirectories --> | ||
<mkdir dir="${basedir}/documentation"/> | ||
<copy todir="${basedir}/documentation"> | ||
<fileset dir="${basedir}/../documentation"/> | ||
</copy> | ||
|
||
<!-- Copy example subdirectories --> | ||
<mkdir dir="${basedir}/example"/> | ||
<copy todir="${basedir}/example"> | ||
<fileset dir="${basedir}/../example"/> | ||
</copy> | ||
|
||
<!-- Copy assets subdirectories --> | ||
<mkdir dir="${basedir}/assets"/> | ||
<copy todir="${basedir}/assets"> | ||
<fileset dir="${basedir}/../assets"/> | ||
</copy> | ||
|
||
<!-- Copy license --> | ||
<copy todir="${basedir}" file="${basedir}/../LICENSE"/> | ||
|
||
<target name="cleancopy" description="Delete old copies"> | ||
<delete dir="${basedir}/documentation"/> | ||
<delete dir="${basedir}/example"/> | ||
<delete dir="${basedir}/assets"/> | ||
<delete file="${basedir}/LICENSE"/> | ||
</target> | ||
|
||
<import file="${titanium.platform}/../module/android/build.xml"/> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.