aboutsummaryrefslogtreecommitdiffstats
path: root/anttasks/src
diff options
context:
space:
mode:
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;