Fix some issues:
- Module name being used instead of package name
- compile SDK version breaking on sample creation
Change-Id: Ie503d237f311e8a84da3a28cf29860ee2af36f8d
diff --git a/build.gradle b/build.gradle
index 70a538b..220840c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -29,7 +29,7 @@
}
task emitAnt(type:Copy) {
- def outputPath = "build/ant"
+ def outputPath = "${samplegen.pathToBuild}/ant"
def inputPath = "${project.projectDir}/${samplegen.targetSampleModule()}"
mkdir outputPath
into outputPath
@@ -46,8 +46,8 @@
from("${inputPath}/src/template") { include "project.properties" }
}
-task emitBrowsable(type:Copy) {
- def outputPath = "build/browsable"
+task emitBrowseable(type:Copy) {
+ def outputPath = "${samplegen.pathToBuild}/browsable"
def inputPath = "${project.projectDir}/${samplegen.targetSampleModule()}"
mkdir outputPath
into outputPath
diff --git a/buildSrc/src/main/groovy/com/example/android/samples/build/SampleGenProperties.groovy b/buildSrc/src/main/groovy/com/example/android/samples/build/SampleGenProperties.groovy
index 5a81108..f1420cd 100644
--- a/buildSrc/src/main/groovy/com/example/android/samples/build/SampleGenProperties.groovy
+++ b/buildSrc/src/main/groovy/com/example/android/samples/build/SampleGenProperties.groovy
@@ -157,7 +157,7 @@
String outputPath = relativeInputPath
outputPath = outputPath.replaceAll('_PROJECT_', targetSampleName())
outputPath = outputPath.replaceAll('_MODULE_', targetSampleModule())
- outputPath = outputPath.replaceAll('_PACKAGE_', packageAsPath(targetSampleModule()))
+ outputPath = outputPath.replaceAll('_PACKAGE_', packageAsPath(targetSamplePackage))
// This is kind of a hack; IntelliJ picks up any and all subdirectories named .idea, so
// named them ._IDE_ instead. TODO: remove when generating .idea projects is no longer necessary.
diff --git a/templates/create/_MODULE_/build.gradle.ftl b/templates/create/_MODULE_/build.gradle.ftl
index 19a71d9..2cb3c6a 100644
--- a/templates/create/_MODULE_/build.gradle.ftl
+++ b/templates/create/_MODULE_/build.gradle.ftl
@@ -35,13 +35,8 @@
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 17
- buildToolsVersion "17.0.0"
-
- defaultConfig {
- minSdkVersion ${sample.minSdk}
- targetSdkVersion 17
- }
+ compileSdkVersion ${compile_sdk}
+ buildToolsVersion ${build_tools_version}
}
task preflight (dependsOn: parent.preflight) {
diff --git a/templates/include/common.ftl b/templates/include/common.ftl
index 0a19973..e08fef1 100644
--- a/templates/include/common.ftl
+++ b/templates/include/common.ftl
@@ -25,10 +25,18 @@
the version can be either a number or a string (e.g. KeyLimePie) so we need to test
both to see if the variable is empty.
-->
-<#if (sample.compileSdkVersion)?is_number >
- <#assign compile_sdk = sample.compileSdkVersion>
-<#elseif (sample.compileSdkVersion)?is_string>
- <#assign compile_sdk = "sample.compileSdkVersion">
+<#if (sample.compileSdkVersion)??>
+ <#if (sample.compileSdkVersion)?is_number >
+ <#assign compile_sdk = sample.compileSdkVersion/>
+ <#elseif (sample.compileSdkVersion)?is_string>
+ <#assign compile_sdk = "sample.compileSdkVersion"/>
+ <#else>
+ <#assign compile_sdk = 18/>
+ </#if>
<#else>
- <#assign compile_sdk = 18>
+ <#assign compile_sdk = 18/>
</#if>
+
+
+<#-- Set the global build tools version -->
+<#assign build_tools_version='"18.0.1"'/>