aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks/src/com/android/ant/NewSetupTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'anttasks/src/com/android/ant/NewSetupTask.java')
-rw-r--r--anttasks/src/com/android/ant/NewSetupTask.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/anttasks/src/com/android/ant/NewSetupTask.java b/anttasks/src/com/android/ant/NewSetupTask.java
index c0e8d2a..45a18c3 100644
--- a/anttasks/src/com/android/ant/NewSetupTask.java
+++ b/anttasks/src/com/android/ant/NewSetupTask.java
@@ -82,6 +82,7 @@ public class NewSetupTask extends Task {
private String mProjectLibrariesPackageOut;
private String mProjectLibrariesJarsOut;
private String mProjectLibrariesLibsOut;
+ private String mTargetApiOut;
public void setProjectTypeOut(String projectTypeOut) {
mProjectTypeOut = projectTypeOut;
@@ -127,6 +128,10 @@ public class NewSetupTask extends Task {
mProjectLibrariesLibsOut = projectLibrariesLibsOut;
}
+ public void setTargetApiOut(String targetApiOut) {
+ mTargetApiOut = targetApiOut;
+ }
+
@Override
public void execute() throws BuildException {
if (mProjectTypeOut == null) {
@@ -162,6 +167,9 @@ public class NewSetupTask extends Task {
if (mProjectLibrariesLibsOut == null) {
throw new BuildException("Missing attribute projectLibrariesLibsOut");
}
+ if (mTargetApiOut == null) {
+ throw new BuildException("Missing attribute targetApiOut");
+ }
Project antProject = getProject();
@@ -377,6 +385,12 @@ public class NewSetupTask extends Task {
"For '%1$s' SDK Preview, attribute minSdkVersion in AndroidManifest.xml must be '%1$s'",
codeName));
}
+
+ // set the API level to the previous API level (which is actually the value in
+ // androidVersion.)
+ antProject.setProperty(mTargetApiOut,
+ Integer.toString(androidVersion.getApiLevel()));
+
} else if (value.length() > 0) {
// for normal platform, we'll only display warnings if the value is lower or higher
// than the target api level.
@@ -391,6 +405,9 @@ public class NewSetupTask extends Task {
AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION));
}
+ // set the target api to the value
+ antProject.setProperty(mTargetApiOut, value);
+
int projectApiLevel = androidVersion.getApiLevel();
if (minSdkValue < projectApiLevel) {
System.out.println(String.format(
@@ -407,6 +424,9 @@ public class NewSetupTask extends Task {
// no minSdkVersion? display a warning
System.out.println(
"WARNING: No minSdkVersion value set. Application will install on all Android versions.");
+
+ // set the target api to 1
+ antProject.setProperty(mTargetApiOut, "1");
}
} catch (XPathExpressionException e) {