Sample template generator--work in progress.
Placed template outputs in src/template instead of src/main
Placed common files into src/common
Added src/common and src/template to .gitignore
Updated to Android tools .0.5.+
Fixed <common> tag handling
In this patch set: the promised refactoring. All templating logic is now in
separate plugin classes and all of the spaghetti and duplicate naming has been
eliminated. No additional functionality or templates, sorry. However, it should
be quite trivial to add extra templates.
Instructions:
1. Run developers/samples/android/common/build/sample-create <path to new sample>
2. Load new sample in Android Studio, let gradle do its thing
3. Edit SampleManifest.xml -- you at least need to add another <template> tag for the specific template you want.
4. Rebuild and add classes as necessary to fix compile errors.
To add your own template(s): Put code and/or Freemarker script into
a subdirectory of developers/samples/android/common/build/templates.
Change-Id: I43abbd337957b2eae5ffb844e411a5d3c91d6f44
diff --git a/sampleSamples/BaseSample/BaseSampleSample/build.gradle b/sampleSamples/BaseSample/BaseSampleSample/build.gradle
new file mode 100644
index 0000000..7f993fa
--- /dev/null
+++ b/sampleSamples/BaseSample/BaseSampleSample/build.gradle
@@ -0,0 +1,34 @@
+
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.4.2'
+ }
+}
+
+apply plugin: 'android'
+
+
+android {
+ compileSdkVersion 17
+ buildToolsVersion "17.0.0"
+
+ defaultConfig {
+ minSdkVersion 4
+ targetSdkVersion 17
+ }
+}
+
+task preflight (dependsOn: parent.preflight) {}
+
+// 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 ->
+ tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
+}
+
+
+
diff --git a/sampleSamples/BaseSample/BaseSampleSample/proguard-project.txt b/sampleSamples/BaseSample/BaseSampleSample/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/sampleSamples/BaseSample/BaseSampleSample/proguard-project.txt
@@ -0,0 +1,20 @@
+ To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/sampleSamples/BaseSample/BaseSampleSample/src/main/AndroidManifest.xml b/sampleSamples/BaseSample/BaseSampleSample/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..456eecf
--- /dev/null
+++ b/sampleSamples/BaseSample/BaseSampleSample/src/main/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2013 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.basesample"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="17" />
+
+ <application android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@style/AppTheme">
+
+ <activity android:name=".MainActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+
+</manifest>
diff --git a/sampleSamples/BaseSample/build.gradle b/sampleSamples/BaseSample/build.gradle
new file mode 100644
index 0000000..bf09c05
--- /dev/null
+++ b/sampleSamples/BaseSample/build.gradle
@@ -0,0 +1,6 @@
+// BEGIN_EXCLUDE
+apply from: "../../common/build/build.gradle"
+samplegen {
+pathToSamplesCommon "../../common"
+}
+// END_EXCLUDE
\ No newline at end of file
diff --git a/sampleSamples/BaseSample/buildSrc/build.gradle b/sampleSamples/BaseSample/buildSrc/build.gradle
new file mode 100644
index 0000000..b2978f5
--- /dev/null
+++ b/sampleSamples/BaseSample/buildSrc/build.gradle
@@ -0,0 +1,15 @@
+repositories {
+ mavenCentral()
+}
+dependencies {
+ compile 'org.freemarker:freemarker:2.3.20'
+}
+
+sourceSets {
+ main {
+ groovy {
+ srcDir new File(rootDir, "../../../common/build/buildSrc/src/main/groovy")
+ }
+ }
+}
+
diff --git a/sampleSamples/BaseSample/template-params.xml b/sampleSamples/BaseSample/template-params.xml
new file mode 100644
index 0000000..6cd6ee9
--- /dev/null
+++ b/sampleSamples/BaseSample/template-params.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2013 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.
+-->
+<sample>
+ <name>BaseSample</name>
+ <package>com.example.android.basesample</package>
+
+
+ <!--TODO: change minSdk if needed-->
+ <minSdk>4</minSdk>
+
+
+ <template src="base"/>
+
+ <common src="logger"/>
+
+ <strings>
+ <intro>
+ <![CDATA[
+ Introductory text that explains what the sample is intended to demonstrate. Edit
+ in TemplateData.xml.
+ ]]>
+ </intro>
+ </strings>
+</sample>