aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks/src
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2009-09-25 15:52:52 -0700
committerXavier Ducrohet <xav@android.com>2009-09-27 18:08:00 -0700
commiteefd90971184e89ff892bcf10598a2990bb05657 (patch)
treea839515ea6799de57d1bf9ebb39ab38bfbdbc434 /anttasks/src
parent9e4ffa58b7164e49c304f54d25a0e7e8822a450e (diff)
downloadsdk-eefd90971184e89ff892bcf10598a2990bb05657.zip
sdk-eefd90971184e89ff892bcf10598a2990bb05657.tar.gz
sdk-eefd90971184e89ff892bcf10598a2990bb05657.tar.bz2
Update the project creation (from the command line):
- Make the distinction between the activity class name, manifest entry, fully-qualified name, and tested activity for the template place-holders. Test activity names now directly contain the full name (including the "Test" prefix) instead of the template adding it. This is required by the new 'create test-project' - New action: create test-project This requires a path to the main project. It reads the package, activity name and target from the main project. The activity is read from the manifest and can be in a more complex form than previously expected (for instance .subpackage.MyClass, instead of simply MyClass). This is what required the re-work the activity related template place holders. Options: -m --main Location path of the project to test, relative to the new project [required] -n --name Project name -p --path Location path of the new project [required] Example: for 2 projects MyProject and MyTests located in the same folder, calling from their parent folder. android create test-project -p MyTests -m ../MyProject - build.properties now only gets application.package for older targets as the new one get it directly from XPath - Remove AndroidXPathFactory from the anttasks project as it was already in sdklib which is a dependency. - Removed IntelliJ templates for the SDK. We haven't supported them for a while, and now that IntelliJ has built-in support for Android, it's not that useful anymore. While there is the command line parameters for 'update test-project' it's not yet implemented. Change-Id: I663d4cb7f439bb2abfe866f893e58f4d13aff975
Diffstat (limited to 'anttasks/src')
-rw-r--r--anttasks/src/com/android/ant/AndroidXPathFactory.java89
-rw-r--r--anttasks/src/com/android/ant/SetupTask.java17
-rw-r--r--anttasks/src/com/android/ant/XPathTask.java2
3 files changed, 11 insertions, 97 deletions
diff --git a/anttasks/src/com/android/ant/AndroidXPathFactory.java b/anttasks/src/com/android/ant/AndroidXPathFactory.java
deleted file mode 100644
index 45ccf42..0000000
--- a/anttasks/src/com/android/ant/AndroidXPathFactory.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2009 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.
- */
-
-package com.android.ant;
-
-import com.android.sdklib.SdkConstants;
-
-import java.util.Iterator;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathFactory;
-
-/**
- * XPath factory with automatic support for the android namespace.
- */
-class AndroidXPathFactory {
- public final static String DEFAULT_NS_PREFIX = "android"; //$NON-NLS-1$
-
- private final static XPathFactory sFactory = XPathFactory.newInstance();
-
- /** Namespace context for Android resource XML files. */
- private static class AndroidNamespaceContext implements NamespaceContext {
- private String mAndroidPrefix;
-
- /**
- * Construct the context with the prefix associated with the android namespace.
- * @param androidPrefix the Prefix
- */
- public AndroidNamespaceContext(String androidPrefix) {
- mAndroidPrefix = androidPrefix;
- }
-
- public String getNamespaceURI(String prefix) {
- if (prefix != null) {
- if (prefix.equals(mAndroidPrefix)) {
- return SdkConstants.NS_RESOURCES;
- }
- }
-
- return XMLConstants.NULL_NS_URI;
- }
-
- public String getPrefix(String namespaceURI) {
- // This isn't necessary for our use.
- assert false;
- return null;
- }
-
- public Iterator<?> getPrefixes(String namespaceURI) {
- // This isn't necessary for our use.
- assert false;
- return null;
- }
- }
-
- /**
- * Creates a new XPath object, specifying which prefix in the query is used for the
- * android namespace.
- * @param androidPrefix The namespace prefix.
- */
- public static XPath newXPath(String androidPrefix) {
- XPath xpath = sFactory.newXPath();
- xpath.setNamespaceContext(new AndroidNamespaceContext(androidPrefix));
- return xpath;
- }
-
- /**
- * Creates a new XPath object using the default prefix for the android namespace.
- * @see #DEFAULT_NS_PREFIX
- */
- public static XPath newXPath() {
- return newXPath(DEFAULT_NS_PREFIX);
- }
-}
diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java
index 1201108..f13cccd 100644
--- a/anttasks/src/com/android/ant/SetupTask.java
+++ b/anttasks/src/com/android/ant/SetupTask.java
@@ -23,7 +23,7 @@ import com.android.sdklib.SdkManager;
import com.android.sdklib.IAndroidTarget.IOptionalLibrary;
import com.android.sdklib.internal.project.ProjectProperties;
import com.android.sdklib.xml.AndroidXPathFactory;
-import com.android.sdklib.xml.ManifestConstants;
+import com.android.sdklib.xml.AndroidManifest;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -264,10 +264,11 @@ public final class SetupTask extends ImportTask {
XPath xPath = AndroidXPathFactory.newXPath();
- String value = xPath.evaluate("/" + ManifestConstants.NODE_MANIFEST +"/" +
- ManifestConstants.NODE_USES_SDK + "/@" +
- AndroidXPathFactory.DEFAULT_NS_PREFIX + ":" +
- ManifestConstants.ATTRIBUTE_MIN_SDK_VERSION,
+ String value = xPath.evaluate(
+ "/" + AndroidManifest.NODE_MANIFEST +
+ "/" + AndroidManifest.NODE_USES_SDK +
+ "/@" + AndroidXPathFactory.DEFAULT_NS_PREFIX + ":" +
+ AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION,
new InputSource(new FileInputStream(manifest)));
if (androidVersion.isPreview()) {
@@ -290,19 +291,19 @@ public final class SetupTask extends ImportTask {
// looks like it's not a number: error!
throw new BuildException(String.format(
"Attribute %1$s in AndroidManifest.xml must be an Integer!",
- ManifestConstants.ATTRIBUTE_MIN_SDK_VERSION));
+ AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION));
}
int projectApiLevel = androidVersion.getApiLevel();
if (minSdkValue < projectApiLevel) {
System.out.println(String.format(
"WARNING: Attribute %1$s in AndroidManifest.xml (%2$d) is lower than the project target API level (%3$d)",
- ManifestConstants.ATTRIBUTE_MIN_SDK_VERSION,
+ AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION,
minSdkValue, projectApiLevel));
} else if (minSdkValue > androidVersion.getApiLevel()) {
System.out.println(String.format(
"WARNING: Attribute %1$s in AndroidManifest.xml (%2$d) is higher than the project target API level (%3$d)",
- ManifestConstants.ATTRIBUTE_MIN_SDK_VERSION,
+ AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION,
minSdkValue, projectApiLevel));
}
} else {
diff --git a/anttasks/src/com/android/ant/XPathTask.java b/anttasks/src/com/android/ant/XPathTask.java
index 73cf86a..b9cfb71 100644
--- a/anttasks/src/com/android/ant/XPathTask.java
+++ b/anttasks/src/com/android/ant/XPathTask.java
@@ -16,6 +16,8 @@
package com.android.ant;
+import com.android.sdklib.xml.AndroidXPathFactory;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Path;