Merge "Sync prebuilts for lmp-docs to commit c206cb304e2e334211838389c81d7766a0784068" into lmp-docs
diff --git a/templates/Wear/Wearable/build.gradle.ftl b/templates/Wear/Wearable/build.gradle.ftl
index ffbf74c..4c7f79d 100644
--- a/templates/Wear/Wearable/build.gradle.ftl
+++ b/templates/Wear/Wearable/build.gradle.ftl
@@ -36,7 +36,6 @@
     compile 'com.google.android.gms:play-services-wearable:5.0.+'
     compile 'com.android.support:support-v13:20.0.+'
     compile 'com.google.android.support:wearable:1.0.+'
-    compile project(':Shared')
 }
 
 // The sample build uses multiple directories to
diff --git a/templates/Wear/_MODULE_/build.gradle.ftl b/templates/Wear/_MODULE_/build.gradle.ftl
index 1ac578d..b67c840 100644
--- a/templates/Wear/_MODULE_/build.gradle.ftl
+++ b/templates/Wear/_MODULE_/build.gradle.ftl
@@ -45,7 +45,6 @@
     <#-- TODO: use sample variables to set these dependencies -->
     compile 'com.google.android.gms:play-services:5.0.+'
     compile 'com.android.support:support-v13:20.0.+'
-    compile project(':Shared')
     wearApp project(':Wearable')
 
 }
diff --git a/templates/Wear/settings.gradle.ftl b/templates/Wear/settings.gradle.ftl
index 13511d6..20220d2 100644
--- a/templates/Wear/settings.gradle.ftl
+++ b/templates/Wear/settings.gradle.ftl
@@ -14,4 +14,4 @@
         See the License for the specific language governing permissions and
         limitations under the License.
 -->
-include ':${meta.module}', ':Wearable', ':Shared'
+include ':${meta.module}', ':Wearable'
diff --git a/templates/WearPlusShared/README-wear.txt b/templates/WearPlusShared/README-wear.txt
new file mode 100644
index 0000000..17523d7
--- /dev/null
+++ b/templates/WearPlusShared/README-wear.txt
@@ -0,0 +1,30 @@
+<#--
+        Copyright 2014 The Android Open Source Project
+
+        Licensed under the Apache License, Version 2.0 (the "License");
+        you may not use this file except in compliance with the License.
+        You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+        Unless required by applicable law or agreed to in writing, software
+        distributed under the License is distributed on an "AS IS" BASIS,
+        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+        See the License for the specific language governing permissions and
+        limitations under the License.
+-->
+
+Steps to use Wear template on top of an existing sample:
+- In template-params.xml.ftl:
+    - Add the following template:
+        <template src="Wear"/>
+
+- Refresh your project (./gradlew refresh)
+- Add Wearable-specific code to Wearable directory
+- Add code to be shared among the main application and the wearable to Shared
+  directory
+
+Note that you still need the main application sample code. This is usually
+achieved by adding another template, like "base" for example.
+
+
diff --git a/templates/Wear/Shared/build.gradle.ftl b/templates/WearPlusShared/Shared/build.gradle.ftl
similarity index 100%
rename from templates/Wear/Shared/build.gradle.ftl
rename to templates/WearPlusShared/Shared/build.gradle.ftl
diff --git a/templates/WearPlusShared/Wearable/build.gradle.ftl b/templates/WearPlusShared/Wearable/build.gradle.ftl
new file mode 100644
index 0000000..172c1f2
--- /dev/null
+++ b/templates/WearPlusShared/Wearable/build.gradle.ftl
@@ -0,0 +1,100 @@
+<#--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+
+    dependencies {
+        classpath 'com.android.tools.build:gradle:0.12.+'
+    }
+}
+
+apply plugin: 'com.android.application'
+
+<#if sample.repository?has_content>
+repositories {
+<#list sample.repository as rep>
+    ${rep}
+</#list>
+}</#if>
+
+dependencies {
+    compile 'com.google.android.gms:play-services-wearable:5.0.+'
+    compile 'com.android.support:support-v13:20.0.+'
+    compile 'com.google.android.support:wearable:1.0.+'
+    compile project(':Shared')
+}
+
+// The sample build uses multiple directories to
+// keep boilerplate and common code separate from
+// the main sample code.
+List<String> dirs = [
+    'main',     // main sample code; look here for the interesting stuff.
+    'common',   // components that are reused by multiple samples
+    'template'] // boilerplate code that is generated by the sample template process
+
+android {
+     <#-- Note that target SDK is hardcoded in this template. We expect all samples
+          to always use the most current SDK as their target. -->
+    compileSdkVersion 'android-20'
+
+    buildToolsVersion '20'
+
+    buildTypes {
+        release {
+            runProguard false
+            proguardFiles getDefaultProguardFile('proguard-android.txt')
+        }
+    }
+    sourceSets {
+        main {
+            dirs.each { dir ->
+<#noparse>
+                java.srcDirs "src/${dir}/java"
+                res.srcDirs "src/${dir}/res"
+</#noparse>
+            }
+        }
+        androidTest.setRoot('tests')
+        androidTest.java.srcDirs = ['tests/src']
+
+<#if sample.defaultConfig?has_content>
+        defaultConfig {
+        ${sample.defaultConfig}
+        }
+<#else>
+</#if>
+    }
+}
+
+// BEGIN_EXCLUDE
+// Tasks below this line will be hidden from release output
+
+task preflight (dependsOn: parent.preflight) {
+    project.afterEvaluate {
+        // Inject a preflight task into each variant so we have a place to hook tasks
+        // that need to run before any of the android build tasks.
+        //
+        android.applicationVariants.each { variant ->
+        <#noparse>
+            tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
+        </#noparse>
+        }
+    }
+}
+
+// END_EXCLUDE
diff --git a/templates/WearPlusShared/_MODULE_/build.gradle.ftl b/templates/WearPlusShared/_MODULE_/build.gradle.ftl
new file mode 100644
index 0000000..a0b3e4f
--- /dev/null
+++ b/templates/WearPlusShared/_MODULE_/build.gradle.ftl
@@ -0,0 +1,103 @@
+<#--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+
+    dependencies {
+        classpath 'com.android.tools.build:gradle:0.12.+'
+    }
+}
+
+apply plugin: 'com.android.application'
+
+<#if sample.repository?has_content>
+repositories {
+<#list sample.repository as rep>
+    ${rep}
+</#list>
+}
+</#if>
+
+dependencies {
+
+<#list sample.dependency as dep>
+    compile "${dep}"
+</#list>
+<#list sample.dependency_external as dep>
+    compile files(${dep})
+</#list>
+
+    <#-- TODO: use sample variables to set these dependencies -->
+    compile 'com.google.android.gms:play-services:5.0.+'
+    compile 'com.android.support:support-v13:20.0.+'
+    compile project(':Shared')
+    wearApp project(':Wearable')
+
+}
+
+// The sample build uses multiple directories to
+// keep boilerplate and common code separate from
+// the main sample code.
+List<String> dirs = [
+    'main',     // main sample code; look here for the interesting stuff.
+    'common',   // components that are reused by multiple samples
+    'template'] // boilerplate code that is generated by the sample template process
+
+android {
+    compileSdkVersion 20
+
+    buildToolsVersion "20"
+
+    sourceSets {
+        main {
+            dirs.each { dir ->
+<#noparse>
+                java.srcDirs "src/${dir}/java"
+                res.srcDirs "src/${dir}/res"
+</#noparse>
+            }
+        }
+        androidTest.setRoot('tests')
+        androidTest.java.srcDirs = ['tests/src']
+
+<#if sample.defaultConfig?has_content>
+        defaultConfig {
+        ${sample.defaultConfig}
+        }
+<#else>
+</#if>
+    }
+
+}
+// BEGIN_EXCLUDE
+// Tasks below this line will be hidden from release output
+
+task preflight (dependsOn: parent.preflight) {
+    project.afterEvaluate {
+        // Inject a preflight task into each variant so we have a place to hook tasks
+        // that need to run before any of the android build tasks.
+        //
+        android.applicationVariants.each { variant ->
+        <#noparse>
+            tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
+        </#noparse>
+        }
+    }
+}
+
+// END_EXCLUDE
diff --git a/templates/WearPlusShared/settings.gradle.ftl b/templates/WearPlusShared/settings.gradle.ftl
new file mode 100644
index 0000000..13511d6
--- /dev/null
+++ b/templates/WearPlusShared/settings.gradle.ftl
@@ -0,0 +1,17 @@
+<#ftl>
+<#--
+        Copyright 2014 The Android Open Source Project
+
+        Licensed under the Apache License, Version 2.0 (the "License");
+        you may not use this file except in compliance with the License.
+        You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+        Unless required by applicable law or agreed to in writing, software
+        distributed under the License is distributed on an "AS IS" BASIS,
+        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+        See the License for the specific language governing permissions and
+        limitations under the License.
+-->
+include ':${meta.module}', ':Wearable', ':Shared'