aboutsummaryrefslogtreecommitdiffstats
path: root/templates/projects/NewAndroidApplication
diff options
context:
space:
mode:
authorScott Barta <sbarta@google.com>2013-04-15 12:42:56 -0700
committerScott Barta <sbarta@google.com>2013-04-26 15:14:32 -0700
commit5afb360a339d083d0edc7b78c04f2dcfbd2a7f41 (patch)
tree477b9bcff9eafa3e5bb8d3bb1139c0f9fd2b21aa /templates/projects/NewAndroidApplication
parent31baa1d95b494108670d0033b4724ef78f41ef85 (diff)
downloadsdk-5afb360a339d083d0edc7b78c04f2dcfbd2a7f41.zip
sdk-5afb360a339d083d0edc7b78c04f2dcfbd2a7f41.tar.gz
sdk-5afb360a339d083d0edc7b78c04f2dcfbd2a7f41.tar.bz2
Modified templates for Gradle projects
Modifies the existing templates to output Gradle build files with a new multi-level directory structure. The templates continue to work the old way that Eclipse expects, and the new behavior is only enabled if the "isGradle" global is set to "true". Files to configure the Gradle wrapper are placed in the SDK at tools/templates/gradle/wrapper. This CL changes all file copies and merges to go to fully-qualified directories set up via global variables. Things go to the old locations for non-Gradle builds based on how the globals are set up, but Gradle builds can override output directory variables to reflect the new directory structure. This CL also adds NewAndroidLibrary and NewJavaLibrary project templates, which will be used in the future. The current NewAndroidApplication template also can output a library, which is redundant and confusing; this will likely be fixed somehow in the future. Change-Id: Ieb830bdfba1797d87a218326ebd37c99d254758e
Diffstat (limited to 'templates/projects/NewAndroidApplication')
-rw-r--r--templates/projects/NewAndroidApplication/globals.xml.ftl6
-rw-r--r--templates/projects/NewAndroidApplication/recipe.xml.ftl28
-rw-r--r--templates/projects/NewAndroidApplication/root/build.gradle.ftl24
-rw-r--r--templates/projects/NewAndroidApplication/root/settings.gradle.ftl1
4 files changed, 51 insertions, 8 deletions
diff --git a/templates/projects/NewAndroidApplication/globals.xml.ftl b/templates/projects/NewAndroidApplication/globals.xml.ftl
index bfc27eb..2565dcd 100644
--- a/templates/projects/NewAndroidApplication/globals.xml.ftl
+++ b/templates/projects/NewAndroidApplication/globals.xml.ftl
@@ -1,4 +1,10 @@
<?xml version="1.0"?>
<globals>
+ <global id="isGradle" value="false" />
+ <global id="topOut" value="." />
+ <global id="projectOut" value="." />
+ <global id="manifestOut" value="." />
<global id="srcOut" value="src/${slashedPackageName(packageName)}" />
+ <global id="resOut" value="res" />
+ <global id="mavenUrl" value="" />
</globals>
diff --git a/templates/projects/NewAndroidApplication/recipe.xml.ftl b/templates/projects/NewAndroidApplication/recipe.xml.ftl
index bc8f02e..79210a9 100644
--- a/templates/projects/NewAndroidApplication/recipe.xml.ftl
+++ b/templates/projects/NewAndroidApplication/recipe.xml.ftl
@@ -1,21 +1,33 @@
<?xml version="1.0"?>
<recipe>
- <instantiate from="AndroidManifest.xml.ftl" />
+<#if isGradle == "true">
+ <merge from="settings.gradle.ftl"
+ to="${topOut}/settings.gradle" />
+ <instantiate from="build.gradle.ftl"
+ to="${projectOut}/build.gradle" />
+</#if>
+ <instantiate from="AndroidManifest.xml.ftl"
+ to="${manifestOut}/AndroidManifest.xml" />
<#if copyIcons>
- <copy from="res/drawable-hdpi" />
- <copy from="res/drawable-mdpi" />
- <copy from="res/drawable-xhdpi" />
+ <copy from="res/drawable-hdpi"
+ to="${resOut}/drawable-hdpi" />
+ <copy from="res/drawable-mdpi"
+ to="${resOut}/drawable-mdpi" />
+ <copy from="res/drawable-xhdpi"
+ to="${resOut}/drawable-xhdpi" />
</#if>
- <instantiate from="res/values/styles.xml.ftl" />
+ <instantiate from="res/values/styles.xml.ftl"
+ to="${resOut}/values/styles.xml" />
<#if buildApi gte 11 && baseTheme != "none">
<instantiate from="res/values-v11/styles_hc.xml.ftl"
- to="res/values-v11/styles.xml" />
+ to="${resOut}/values-v11/styles.xml" />
</#if>
<#if buildApi gte 14 && baseTheme?contains("darkactionbar")>
<copy from="res/values-v14/styles_ics.xml"
- to="res/values-v14/styles.xml" />
+ to="${resOut}/values-v14/styles.xml" />
</#if>
- <instantiate from="res/values/strings.xml.ftl" />
+ <instantiate from="res/values/strings.xml.ftl"
+ to="${resOut}/values/strings.xml" />
</recipe>
diff --git a/templates/projects/NewAndroidApplication/root/build.gradle.ftl b/templates/projects/NewAndroidApplication/root/build.gradle.ftl
new file mode 100644
index 0000000..0232c7e
--- /dev/null
+++ b/templates/projects/NewAndroidApplication/root/build.gradle.ftl
@@ -0,0 +1,24 @@
+buildscript {
+ repositories {
+ maven { url '${mavenUrl}/prebuilts-repo' }
+ maven { url '${mavenUrl}/tools-repo' }
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.4-SNAPSHOT'
+ }
+}
+apply plugin: 'android'
+
+dependencies {
+ compile files('libs/android-support-v4.jar')
+}
+
+android {
+ compileSdkVersion ${buildApi}
+ buildToolsVersion "${buildApi}"
+
+ defaultConfig {
+ minSdkVersion ${minApi}
+ targetSdkVersion ${targetApi}
+ }
+}
diff --git a/templates/projects/NewAndroidApplication/root/settings.gradle.ftl b/templates/projects/NewAndroidApplication/root/settings.gradle.ftl
new file mode 100644
index 0000000..b12004b
--- /dev/null
+++ b/templates/projects/NewAndroidApplication/root/settings.gradle.ftl
@@ -0,0 +1 @@
+include ':${projectName}'