diff options
author | Xavier Ducrohet <xav@android.com> | 2011-10-18 15:17:47 -0700 |
---|---|---|
committer | Xavier Ducrohet <xav@android.com> | 2011-11-09 17:30:45 -0800 |
commit | 3056c8e00f7c36d022cc00f227c22d53d6113733 (patch) | |
tree | 2204a1d644765fd93e544850b509c120c4494aeb /anttasks | |
parent | 38a09054d6e5bb8b9138ae28ebe113130050a066 (diff) | |
download | sdk-3056c8e00f7c36d022cc00f227c22d53d6113733.zip sdk-3056c8e00f7c36d022cc00f227c22d53d6113733.tar.gz sdk-3056c8e00f7c36d022cc00f227c22d53d6113733.tar.bz2 |
Add support for BuildConfig class to ADT.
Change-Id: I17d4eae699e55e41c26c6125175b893a3012699e
Diffstat (limited to 'anttasks')
-rw-r--r-- | anttasks/src/com/android/ant/BuildConfigTask.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/anttasks/src/com/android/ant/BuildConfigTask.java b/anttasks/src/com/android/ant/BuildConfigTask.java index 08f91e9..4fee80c 100644 --- a/anttasks/src/com/android/ant/BuildConfigTask.java +++ b/anttasks/src/com/android/ant/BuildConfigTask.java @@ -21,6 +21,7 @@ import com.android.sdklib.internal.build.BuildConfigGenerator; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.Path; +import java.io.File; import java.io.IOException; public class BuildConfigTask extends BuildTypedTask { @@ -46,15 +47,22 @@ public class BuildConfigTask extends BuildTypedTask { throw new BuildException("Missing attribute package"); } - if (hasBuildTypeChanged()) { + BuildConfigGenerator generator = new BuildConfigGenerator( + mGenFolder, mAppPackage, + Boolean.parseBoolean(getBuildType())); + + // first check if the file is missing. + File buildConfigFile = generator.getBuildConfigFile(); + boolean missingFile = buildConfigFile.exists() == false; + + if (missingFile || hasBuildTypeChanged()) { if (isNewBuild()) { System.out.println("Generating BuildConfig class."); + } else if (missingFile) { + System.out.println("BuildConfig class missing: Generating new BuildConfig class."); } else { System.out.println("Build type changed: Generating new BuildConfig class."); } - BuildConfigGenerator generator = new BuildConfigGenerator( - mGenFolder, mAppPackage, - Boolean.parseBoolean(getBuildType())); try { generator.generate(); |