aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2010-11-03 14:12:47 -0700
committerRaphael Moll <ralf@android.com>2010-11-03 14:12:47 -0700
commit4b4d81f5840bd7991e08c2c0ec5eb128b6c9563f (patch)
tree7b6250c2018c03441e04a0e711b66a5d28ddafad
parent669dfddc94d425643238aaa048195c2d6df6ca9e (diff)
downloadsdk-4b4d81f5840bd7991e08c2c0ec5eb128b6c9563f.zip
sdk-4b4d81f5840bd7991e08c2c0ec5eb128b6c9563f.tar.gz
sdk-4b4d81f5840bd7991e08c2c0ec5eb128b6c9563f.tar.bz2
SDK Repo Schema: <vendor> for <extra> elements.
Change-Id: I8fa13d28b787e3ecb8bd96896e6410313e2a66a9
-rw-r--r--sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java1
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java3
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java51
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java1
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java13
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-1.xsd65
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-3.xsd89
-rwxr-xr-xsdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkAddonSourceTest.java17
-rwxr-xr-xsdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkRepoSourceTest.java86
-rwxr-xr-xsdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/addon_sample_1.xml2
-rwxr-xr-xsdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_3.xml2
11 files changed, 249 insertions, 81 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java
index 61c59c7..2a22d0a 100644
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/PlatformTarget.java
@@ -54,6 +54,7 @@ final class PlatformTarget implements IAndroidTarget {
* @param versionName the version name of the platform.
* @param revision the revision of the platform component.
*/
+ @SuppressWarnings("deprecation")
PlatformTarget(String sdkOsPath, String platformOSPath, Map<String, String> properties,
int apiLevel, String codeName, String versionName, int revision) {
if (platformOSPath.endsWith(File.separator) == false) {
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
index 10e6424..2bab0b5 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/Archive.java
@@ -18,6 +18,7 @@ package com.android.sdklib.internal.repository;
import com.android.sdklib.SdkConstants;
import com.android.sdklib.SdkManager;
+import com.android.sdklib.repository.RepoConstants;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
@@ -1032,7 +1033,7 @@ public class Archive implements IDescription, Comparable<Archive> {
* This folder is always at osBasePath/temp.
*/
private File getTempFolder(String osBasePath) {
- File baseTempFolder = new File(osBasePath, "temp"); //$NON-NLS-1$
+ File baseTempFolder = new File(osBasePath, RepoConstants.FD_TEMP);
return baseTempFolder;
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java
index 622b8ba..d3f3a9b 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/ExtraPackage.java
@@ -20,6 +20,7 @@ import com.android.sdklib.SdkConstants;
import com.android.sdklib.SdkManager;
import com.android.sdklib.internal.repository.Archive.Arch;
import com.android.sdklib.internal.repository.Archive.Os;
+import com.android.sdklib.repository.RepoConstants;
import com.android.sdklib.repository.SdkRepoConstants;
import org.w3c.dom.Node;
@@ -35,14 +36,22 @@ public class ExtraPackage extends MinToolsPackage
implements IMinApiLevelDependency {
private static final String PROP_PATH = "Extra.Path"; //$NON-NLS-1$
+ private static final String PROP_VENDOR = "Extra.Vendor"; //$NON-NLS-1$
private static final String PROP_MIN_API_LEVEL = "Extra.MinApiLevel"; //$NON-NLS-1$
/**
- * The install folder name. It must be a single-segment path.
- * The paths "add-ons", "platforms", "tools" and "docs" are reserved and cannot be used.
+ * The vendor folder name. It must be a non-empty single-segment path.
+ * <p/>
+ * The paths "add-ons", "platforms", "platform-tools", "tools" and "docs" are reserved and
+ * cannot be used.
* This limitation cannot be written in the XML Schema and must be enforced here by using
* the method {@link #isPathValid()} *before* installing the package.
*/
+ private final String mVendor;
+
+ /**
+ * The sub-folder name. It must be a non-empty single-segment path.
+ */
private final String mPath;
/**
@@ -64,7 +73,8 @@ public class ExtraPackage extends MinToolsPackage
ExtraPackage(SdkSource source, Node packageNode, String nsUri, Map<String,String> licenses) {
super(source, packageNode, nsUri, licenses);
- mPath = XmlParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_PATH);
+ mPath = XmlParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_PATH);
+ mVendor = XmlParserUtils.getXmlString(packageNode, SdkRepoConstants.NODE_VENDOR);
mMinApiLevel = XmlParserUtils.getXmlInt(packageNode, SdkRepoConstants.NODE_MIN_API_LEVEL,
MIN_API_LEVEL_NOT_SPECIFIED);
@@ -79,6 +89,7 @@ public class ExtraPackage extends MinToolsPackage
*/
ExtraPackage(SdkSource source,
Properties props,
+ String vendor,
String path,
int revision,
String license,
@@ -97,8 +108,14 @@ public class ExtraPackage extends MinToolsPackage
archiveArch,
archiveOsPath);
+ // The vendor argument is not supposed to be empty. However this attribute did not
+ // exist prior to schema repo-v3 and tools r8, which means we need to cope with a
+ // lack of it when reading back old local repositories. In this case we allow an
+ // empty string.
+ mVendor = vendor != null ? vendor : getProperty(props, PROP_VENDOR, "");
+
// The path argument comes before whatever could be in the properties
- mPath = path != null ? path : getProperty(props, PROP_PATH, path);
+ mPath = path != null ? path : getProperty(props, PROP_PATH, path);
mMinApiLevel = Integer.parseInt(
getProperty(props, PROP_MIN_API_LEVEL, Integer.toString(MIN_API_LEVEL_NOT_SPECIFIED)));
@@ -113,6 +130,9 @@ public class ExtraPackage extends MinToolsPackage
super.saveProperties(props);
props.setProperty(PROP_PATH, mPath);
+ if (mVendor != null) {
+ props.setProperty(PROP_PATH, mVendor);
+ }
if (getMinApiLevel() != MIN_API_LEVEL_NOT_SPECIFIED) {
props.setProperty(PROP_MIN_API_LEVEL, Integer.toString(getMinApiLevel()));
@@ -133,21 +153,38 @@ public class ExtraPackage extends MinToolsPackage
public boolean isPathValid() {
if (SdkConstants.FD_ADDONS.equals(mPath) ||
SdkConstants.FD_PLATFORMS.equals(mPath) ||
+ SdkConstants.FD_PLATFORM_TOOLS.equals(mPath) ||
SdkConstants.FD_TOOLS.equals(mPath) ||
- SdkConstants.FD_DOCS.equals(mPath)) {
+ SdkConstants.FD_DOCS.equals(mPath) ||
+ RepoConstants.FD_TEMP.equals(mPath)) {
return false;
}
return mPath != null && mPath.indexOf('/') == -1 && mPath.indexOf('\\') == -1;
}
/**
- * The install folder name. It must be a single-segment path.
+ * The install folder name. It is a single-segment path.
+ * <p/>
* The paths "add-ons", "platforms", "tools" and "docs" are reserved and cannot be used.
* This limitation cannot be written in the XML Schema and must be enforced here by using
* the method {@link #isPathValid()} *before* installing the package.
*/
public String getPath() {
- return mPath;
+ String path = mPath;
+
+ if (mVendor != null && mVendor.length() > 0) {
+ path = mVendor + "-" + mPath; //$NON-NLS-1$
+ }
+
+ int h = path.hashCode();
+
+ // Sanitize the path
+ path = path.replaceAll("[^a-zA-Z0-9-]+", "_"); //$NON-NLS-1$
+ if (path.length() == 0) {
+ path = String.format("unknown_extra%08x", h); //$NON-NLS-1$
+ }
+
+ return path;
}
/** Returns a short description for an {@link IDescription}. */
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
index 8d79ced..915a8e6 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/repository/LocalSdkParser.java
@@ -170,6 +170,7 @@ public class LocalSdkParser {
ExtraPackage pkg = new ExtraPackage(
null, //source
props, //properties
+ null, //vendor
dir.getName(), //path
0, //revision
null, //license
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java
index 58a2c83..61a67bd 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/RepoConstants.java
@@ -56,7 +56,7 @@ public class RepoConstants {
public static final String NODE_API_LEVEL = "api-level"; //$NON-NLS-1$
/** The codename, a string, for platform packages. */
public static final String NODE_CODENAME = "codename"; //$NON-NLS-1$
- /** The vendor, a string, for add-on packages. */
+ /** The vendor, a string, for add-on and extra packages. */
public static final String NODE_VENDOR = "vendor"; //$NON-NLS-1$
/** The name, a string, for add-on packages or for libraries. */
public static final String NODE_NAME = "name"; //$NON-NLS-1$
@@ -66,8 +66,8 @@ public class RepoConstants {
/** A lib element in a libs container. */
public static final String NODE_LIB = "lib"; //$NON-NLS-1$
- /** The path, a string, for extra packages. */
- public static final String NODE_PATH = "path"; //$NON-NLS-1$
+ /** The path segment, a string, for extra packages. */
+ public static final String NODE_PATH = "path"; //$NON-NLS-1$
/** The archives container, for all packages. */
public static final String NODE_ARCHIVES = "archives"; //$NON-NLS-1$
@@ -99,4 +99,11 @@ public class RepoConstants {
/** Length of a string representing a SHA1 checksum; always 40 characters long. */
public static final int SHA1_CHECKSUM_LEN = 40;
+ /**
+ * Temporary folder used to hold downloads and extract archives during installation.
+ * This folder will be located in the SDK.
+ */
+ public static final String FD_TEMP = "temp"; //$NON-NLS-1$
+
+
}
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-1.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-1.xsd
index 041a038..8d84205 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-1.xsd
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-addon-1.xsd
@@ -17,7 +17,7 @@
<xsd:schema
targetNamespace="http://schemas.android.com/sdk/android/addon/1"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:sa1="http://schemas.android.com/sdk/android/addon/1"
+ xmlns:sdk="http://schemas.android.com/sdk/android/addon/1"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1">
@@ -35,7 +35,7 @@
<extra> packages.
-->
- <xsd:element name="sdk-addon" type="sa1:repositoryType" />
+ <xsd:element name="sdk-addon" type="sdk:repositoryType" />
<xsd:complexType name="repositoryType">
<xsd:annotation>
@@ -44,9 +44,9 @@
</xsd:documentation>
</xsd:annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element name="add-on" type="sa1:addonType" />
- <xsd:element name="extra" type="sa1:extraType" />
- <xsd:element name="license" type="sa1:licenseType" />
+ <xsd:element name="add-on" type="sdk:addonType" />
+ <xsd:element name="extra" type="sdk:extraType" />
+ <xsd:element name="license" type="sdk:licenseType" />
</xsd:choice>
</xsd:complexType>
@@ -71,7 +71,7 @@
<xsd:element name="revision" type="xsd:positiveInteger" />
<!-- The optional license of this package. If present, users will have
to agree to it before downloading. -->
- <xsd:element name="uses-license" type="sa1:usesLicenseType" minOccurs="0" />
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
<!-- The optional description of this package. -->
<xsd:element name="description" type="xsd:string" minOccurs="0" />
<!-- The optional description URL of this package -->
@@ -81,7 +81,7 @@
<!-- The optional release note URL of this package -->
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
- <xsd:element name="archives" type="sa1:archivesType" />
+ <xsd:element name="archives" type="sdk:archivesType" />
<!-- An optional element indicating the package is obsolete.
The string content is however currently not defined and ignored. -->
@@ -110,39 +110,33 @@
<!-- The definition of an SDK extra package. This kind of package is for
- "free" content and specifies in which fixed root directory it must be
- installed.
+ "free" content. Such packages are installed in SDK/vendor/path.
-->
<xsd:complexType name="extraType" >
<xsd:annotation>
<xsd:documentation>
- An SDK extra package. This kind of package is for "free"
- content and specifies in which fixed root directory it must be
- installed.
- The paths "add-ons", "platforms", "tools" and "docs" are
- reserved and cannot be used.
+ An SDK extra package. This kind of package is for "free" content.
+ Such packages are installed in SDK/vendor/path.
</xsd:documentation>
</xsd:annotation>
<xsd:all>
- <!-- The install folder name. It must be a single-segment path.
- The paths "add-ons", "platforms", "tools" and "docs" are
- reserved and cannot be used.
+
+ <!-- The install path top folder name. It must not be empty.
+ The segments "add-ons", "docs", "platforms", "platform-tools", "temp"
+ and "tools" are reserved and cannot be used.
-->
- <xsd:element name="path">
- <xsd:simpleType>
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[^/\\]+"/>
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
+ <xsd:element name="vendor" type="sdk:segmentType" />
+
+ <!-- The install path sub-folder name. It must not be empty. -->
+ <xsd:element name="path" type="sdk:segmentType" />
<!-- The revision, an int > 0, incremented each time a new
package is generated. -->
<xsd:element name="revision" type="xsd:positiveInteger" />
<!-- The optional license of this package. If present, users will have
to agree to it before downloading. -->
- <xsd:element name="uses-license" type="sa1:usesLicenseType" minOccurs="0" />
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
<!-- The optional description of this package. -->
<xsd:element name="description" type="xsd:string" minOccurs="0" />
<!-- The optional description URL of this package -->
@@ -152,7 +146,7 @@
<!-- The optional release note URL of this package -->
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
- <xsd:element name="archives" type="sa1:archivesType" />
+ <xsd:element name="archives" type="sdk:archivesType" />
<!-- The minimal revision of tools required by this package.
Optional. If present, must be an int > 0. -->
<xsd:element name="min-tools-rev" type="xsd:positiveInteger" minOccurs="0" />
@@ -167,6 +161,21 @@
</xsd:complexType>
+ <!-- The definition of a path segment used by the extra element. -->
+
+ <xsd:simpleType name="segmentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ One path segment for the install path of an extra element.
+ It must be a single-segment path. It must not be empty.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:pattern value="[a-zA-Z0-9_]+"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
<!-- The definition of a license to be referenced by the uses-license element. -->
<xsd:complexType name="licenseType">
@@ -228,7 +237,7 @@
<!-- The size in bytes of the archive to download. -->
<xsd:element name="size" type="xsd:positiveInteger" />
<!-- The checksum of the archive file. -->
- <xsd:element name="checksum" type="sa1:checksumType" />
+ <xsd:element name="checksum" type="sdk:checksumType" />
<!-- The URL is an absolute URL if it starts with http://, https://
or ftp://. Otherwise it is relative to the parent directory that
contains this repository.xml -->
@@ -278,7 +287,7 @@
<xsd:documentation>A file checksum, currently only SHA1.</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
- <xsd:extension base="sa1:sha1Number">
+ <xsd:extension base="sdk:sha1Number">
<xsd:attribute name="type" type="xsd:token" fixed="sha1" />
</xsd:extension>
</xsd:simpleContent>
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-3.xsd b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-3.xsd
index 89c74d2..75d8541 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-3.xsd
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/repository/sdk-repository-3.xsd
@@ -17,7 +17,7 @@
<xsd:schema
targetNamespace="http://schemas.android.com/sdk/android/repository/3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:sr3="http://schemas.android.com/sdk/android/repository/3"
+ xmlns:sdk="http://schemas.android.com/sdk/android/repository/3"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
version="1">
@@ -49,7 +49,7 @@
- It removes the <addon> repository type, which is now in its own XML Schema.
-->
- <xsd:element name="sdk-repository" type="sr3:repositoryType" />
+ <xsd:element name="sdk-repository" type="sdk:repositoryType" />
<xsd:complexType name="repositoryType">
<xsd:annotation>
@@ -58,13 +58,13 @@
</xsd:documentation>
</xsd:annotation>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element name="platform" type="sr3:platformType" />
- <xsd:element name="tool" type="sr3:toolType" />
- <xsd:element name="platform-tool" type="sr3:platformToolType" />
- <xsd:element name="doc" type="sr3:docType" />
- <xsd:element name="sample" type="sr3:sampleType" />
- <xsd:element name="extra" type="sr3:extraType" />
- <xsd:element name="license" type="sr3:licenseType" />
+ <xsd:element name="platform" type="sdk:platformType" />
+ <xsd:element name="tool" type="sdk:toolType" />
+ <xsd:element name="platform-tool" type="sdk:platformToolType" />
+ <xsd:element name="doc" type="sdk:docType" />
+ <xsd:element name="sample" type="sdk:sampleType" />
+ <xsd:element name="extra" type="sdk:extraType" />
+ <xsd:element name="license" type="sdk:licenseType" />
</xsd:choice>
</xsd:complexType>
@@ -87,7 +87,7 @@
<xsd:element name="revision" type="xsd:positiveInteger" />
<!-- The optional license of this package. If present, users will have
to agree to it before downloading. -->
- <xsd:element name="uses-license" type="sr3:usesLicenseType" minOccurs="0" />
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
<!-- The optional description of this package. -->
<xsd:element name="description" type="xsd:string" minOccurs="0" />
<!-- The optional description URL of this package -->
@@ -97,7 +97,7 @@
<!-- The optional release note URL of this package -->
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
- <xsd:element name="archives" type="sr3:archivesType" />
+ <xsd:element name="archives" type="sdk:archivesType" />
<!-- The minimal revision of tools required by this package.
Optional. If present, must be an int > 0. -->
<xsd:element name="min-tools-rev" type="xsd:positiveInteger" minOccurs="0" />
@@ -121,7 +121,7 @@
<xsd:element name="revision" type="xsd:positiveInteger" />
<!-- The optional license of this package. If present, users will have
to agree to it before downloading. -->
- <xsd:element name="uses-license" type="sr3:usesLicenseType" minOccurs="0" />
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
<!-- The optional description of this package. -->
<xsd:element name="description" type="xsd:string" minOccurs="0" />
<!-- The optional description URL of this package -->
@@ -131,7 +131,7 @@
<!-- The optional release note URL of this package -->
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
- <xsd:element name="archives" type="sr3:archivesType" />
+ <xsd:element name="archives" type="sdk:archivesType" />
<!-- An optional element indicating the package is obsolete.
The string content is however currently not defined and ignored. -->
<xsd:element name="obsolete" type="xsd:string" minOccurs="0" />
@@ -155,7 +155,7 @@
<xsd:element name="revision" type="xsd:positiveInteger" />
<!-- The optional license of this package. If present, users will have
to agree to it before downloading. -->
- <xsd:element name="uses-license" type="sr3:usesLicenseType" minOccurs="0" />
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
<!-- The optional description of this package. -->
<xsd:element name="description" type="xsd:string" minOccurs="0" />
<!-- The optional description URL of this package -->
@@ -165,7 +165,7 @@
<!-- The optional release note URL of this package -->
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
- <xsd:element name="archives" type="sr3:archivesType" />
+ <xsd:element name="archives" type="sdk:archivesType" />
<!-- An optional element indicating the package is obsolete.
The string content is however currently not defined and ignored. -->
@@ -191,7 +191,7 @@
<xsd:element name="revision" type="xsd:positiveInteger" />
<!-- The optional license of this package. If present, users will have
to agree to it before downloading. -->
- <xsd:element name="uses-license" type="sr3:usesLicenseType" minOccurs="0" />
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
<!-- The optional description of this package. -->
<xsd:element name="description" type="xsd:string" minOccurs="0" />
<!-- The optional description URL of this package -->
@@ -201,7 +201,7 @@
<!-- The optional release note URL of this package -->
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
- <xsd:element name="archives" type="sr3:archivesType" />
+ <xsd:element name="archives" type="sdk:archivesType" />
<!-- An optional element indicating the package is obsolete.
The string content is however currently not defined and ignored. -->
@@ -227,7 +227,7 @@
<xsd:element name="revision" type="xsd:positiveInteger" />
<!-- The optional license of this package. If present, users will have
to agree to it before downloading. -->
- <xsd:element name="uses-license" type="sr3:usesLicenseType" minOccurs="0" />
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
<!-- The optional description of this package. -->
<xsd:element name="description" type="xsd:string" minOccurs="0" />
<!-- The optional description URL of this package -->
@@ -237,7 +237,7 @@
<!-- The optional release note URL of this package -->
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
- <xsd:element name="archives" type="sr3:archivesType" />
+ <xsd:element name="archives" type="sdk:archivesType" />
<!-- The minimal revision of tools required by this package.
Optional. If present, must be an int > 0. -->
<xsd:element name="min-tools-rev" type="xsd:positiveInteger" minOccurs="0" />
@@ -250,39 +250,33 @@
<!-- The definition of an SDK extra package. This kind of package is for
- "free" content and specifies in which fixed root directory it must be
- installed.
+ "free" content. Such packages are installed in SDK/vendor/path.
-->
<xsd:complexType name="extraType" >
<xsd:annotation>
<xsd:documentation>
- An SDK extra package. This kind of package is for "free"
- content and specifies in which fixed root directory it must be
- installed.
- Path names matching existing package types here (e.g. "add-ons",
- "platforms", "tools", "docs", etc.) are reserved and cannot be used.
+ An SDK extra package. This kind of package is for "free" content.
+ Such packages are installed in SDK/vendor/path.
</xsd:documentation>
</xsd:annotation>
<xsd:all>
- <!-- The install folder name. It must be a single-segment path.
- The paths "add-ons", "platforms", "tools" and "docs" are
- reserved and cannot be used.
+
+ <!-- The install path top folder name.
+ The segments "add-ons", "docs", "platforms", "platform-tools", "temp"
+ and "tools" are reserved and cannot be used.
-->
- <xsd:element name="path">
- <xsd:simpleType>
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[^/\\]+"/>
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
+ <xsd:element name="vendor" type="sdk:segmentType" />
+
+ <!-- The install path sub-folder name. -->
+ <xsd:element name="path" type="sdk:segmentType" />
<!-- The revision, an int > 0, incremented each time a new
package is generated. -->
<xsd:element name="revision" type="xsd:positiveInteger" />
<!-- The optional license of this package. If present, users will have
to agree to it before downloading. -->
- <xsd:element name="uses-license" type="sr3:usesLicenseType" minOccurs="0" />
+ <xsd:element name="uses-license" type="sdk:usesLicenseType" minOccurs="0" />
<!-- The optional description of this package. -->
<xsd:element name="description" type="xsd:string" minOccurs="0" />
<!-- The optional description URL of this package -->
@@ -292,7 +286,7 @@
<!-- The optional release note URL of this package -->
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
- <xsd:element name="archives" type="sr3:archivesType" />
+ <xsd:element name="archives" type="sdk:archivesType" />
<!-- The minimal revision of tools required by this package.
Optional. If present, must be an int > 0. -->
<xsd:element name="min-tools-rev" type="xsd:positiveInteger" minOccurs="0" />
@@ -307,6 +301,21 @@
</xsd:complexType>
+ <!-- The definition of a path segment used by the extra element. -->
+
+ <xsd:simpleType name="segmentType">
+ <xsd:annotation>
+ <xsd:documentation>
+ One path segment for the install path of an extra element.
+ It must be a single-segment path.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:pattern value="[a-zA-Z0-9_]+"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
<!-- The definition of a license to be referenced by the uses-license element. -->
<xsd:complexType name="licenseType">
@@ -368,7 +377,7 @@
<!-- The size in bytes of the archive to download. -->
<xsd:element name="size" type="xsd:positiveInteger" />
<!-- The checksum of the archive file. -->
- <xsd:element name="checksum" type="sr3:checksumType" />
+ <xsd:element name="checksum" type="sdk:checksumType" />
<!-- The URL is an absolute URL if it starts with http://, https://
or ftp://. Otherwise it is relative to the parent directory that
contains this repository.xml -->
@@ -418,7 +427,7 @@
<xsd:documentation>A file checksum, currently only SHA1.</xsd:documentation>
</xsd:annotation>
<xsd:simpleContent>
- <xsd:extension base="sr3:sha1Number">
+ <xsd:extension base="sdk:sha1Number">
<xsd:attribute name="type" type="xsd:token" fixed="sha1" />
</xsd:extension>
</xsd:simpleContent>
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkAddonSourceTest.java b/sdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkAddonSourceTest.java
index d05c967..9e152d5 100755
--- a/sdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkAddonSourceTest.java
+++ b/sdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkAddonSourceTest.java
@@ -24,6 +24,8 @@ import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
import junit.framework.TestCase;
@@ -169,8 +171,8 @@ public class SdkAddonSourceTest extends TestCase {
assertEquals("Found My First add-on by John Doe, Android API 1, revision 1\n" +
"Found My Second add-on by John Deer, Android API 2, revision 42\n" +
"Found This add-on has no libraries by Joe Bar, Android API 4, revision 3\n" +
- "Found Usb Driver package, revision 43 (Obsolete)\n" +
- "Found Extra Api Dep package, revision 2 (Obsolete)\n",
+ "Found A Usb Driver package, revision 43 (Obsolete)\n" +
+ "Found Android Vendor Extra Api Dep package, revision 2 (Obsolete)\n",
monitor.getCapturedDescriptions());
assertEquals("", monitor.getCapturedResults());
@@ -181,6 +183,17 @@ public class SdkAddonSourceTest extends TestCase {
for (Package p : pkgs) {
assertTrue(p.getArchives().length >= 1);
}
+
+ // Check the extra packages path
+ ArrayList<String> extraPaths = new ArrayList<String>();
+ for (Package p : pkgs) {
+ if (p instanceof ExtraPackage) {
+ extraPaths.add(((ExtraPackage) p).getPath());
+ }
+ }
+ assertEquals(
+ "[a-usb_driver, android_vendor-extra_api_dep]",
+ Arrays.toString(extraPaths.toArray()));
}
/**
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkRepoSourceTest.java b/sdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
index c6d6eb3..c92acde 100755
--- a/sdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
+++ b/sdkmanager/libs/sdklib/tests/com/android/sdklib/internal/repository/SdkRepoSourceTest.java
@@ -24,6 +24,8 @@ import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
import junit.framework.TestCase;
@@ -205,6 +207,17 @@ public class SdkRepoSourceTest extends TestCase {
for (Package p : pkgs) {
assertTrue(p.getArchives().length >= 1);
}
+
+ // Check the extra packages path
+ ArrayList<String> extraPaths = new ArrayList<String>();
+ for (Package p : pkgs) {
+ if (p instanceof ExtraPackage) {
+ extraPaths.add(((ExtraPackage) p).getPath());
+ }
+ }
+ assertEquals(
+ "[usb_driver]",
+ Arrays.toString(extraPaths.toArray()));
}
/**
@@ -258,6 +271,79 @@ public class SdkRepoSourceTest extends TestCase {
for (Package p : pkgs) {
assertTrue(p.getArchives().length >= 1);
}
+
+ // Check the extra packages path
+ ArrayList<String> extraPaths = new ArrayList<String>();
+ for (Package p : pkgs) {
+ if (p instanceof ExtraPackage) {
+ extraPaths.add(((ExtraPackage) p).getPath());
+ }
+ }
+ assertEquals(
+ "[usb_driver, extra_api_dep]",
+ Arrays.toString(extraPaths.toArray()));
+ }
+
+ /**
+ * Validate what we can load from repository in schema version 3
+ */
+ public void testLoadXml_3() throws Exception {
+ InputStream xmlStream = getTestResource(
+ "/com/android/sdklib/testdata/repository_sample_3.xml");
+
+ // guess the version from the XML document
+ int version = mSource._getXmlSchemaVersion(xmlStream);
+ assertEquals(3, version);
+
+ Boolean[] validatorFound = new Boolean[] { Boolean.FALSE };
+ String[] validationError = new String[] { null };
+ String url = "not-a-valid-url://" + SdkRepoConstants.URL_DEFAULT_FILENAME;
+
+ String uri = mSource._validateXml(xmlStream, url, version, validationError, validatorFound);
+ assertEquals(Boolean.TRUE, validatorFound[0]);
+ assertEquals(null, validationError[0]);
+ assertEquals(SdkRepoConstants.getSchemaUri(3), uri);
+
+ // Validation was successful, load the document
+ MockMonitor monitor = new MockMonitor();
+ Document doc = mSource._getDocument(xmlStream, monitor);
+ assertNotNull(doc);
+
+ // Get the packages
+ assertTrue(mSource._parsePackages(doc, uri, monitor));
+
+ assertEquals("Found SDK Platform Android 1.0, API 1, revision 3\n" +
+ "Found Documentation for Android SDK, API 1, revision 1\n" +
+ "Found SDK Platform Android 1.1, API 2, revision 12\n" +
+ "Found SDK Platform Android Pastry Preview, revision 3\n" +
+ "Found Android SDK Tools, revision 1\n" +
+ "Found Documentation for Android SDK, API 2, revision 42\n" +
+ "Found Android SDK Tools, revision 42\n" +
+ "Found Android SDK Platform-tools, revision 3\n" +
+ "Found A Usb Driver package, revision 43 (Obsolete)\n" +
+ "Found Android Vendor Extra Api Dep package, revision 2 (Obsolete)\n" +
+ "Found Samples for SDK API 14, revision 24 (Obsolete)\n",
+ monitor.getCapturedDescriptions());
+ assertEquals("", monitor.getCapturedResults());
+
+ // check the packages we found... we expected to find 13 packages with each at least
+ // one archive.
+ Package[] pkgs = mSource.getPackages();
+ assertEquals(11, pkgs.length);
+ for (Package p : pkgs) {
+ assertTrue(p.getArchives().length >= 1);
+ }
+
+ // Check the extra packages path
+ ArrayList<String> extraPaths = new ArrayList<String>();
+ for (Package p : pkgs) {
+ if (p instanceof ExtraPackage) {
+ extraPaths.add(((ExtraPackage) p).getPath());
+ }
+ }
+ assertEquals(
+ "[a-usb_driver, android_vendor-extra_api_dep]",
+ Arrays.toString(extraPaths.toArray()));
}
/**
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/addon_sample_1.xml b/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/addon_sample_1.xml
index 8ebafac..4e3f750 100755
--- a/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/addon_sample_1.xml
+++ b/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/addon_sample_1.xml
@@ -106,6 +106,7 @@
</sdk:add-on>
<sdk:extra>
+ <sdk:vendor>a</sdk:vendor>
<sdk:path>usb_driver</sdk:path>
<sdk:uses-license ref="license2" />
<sdk:revision>43</sdk:revision>
@@ -123,6 +124,7 @@
</sdk:extra>
<sdk:extra>
+ <sdk:vendor>android_vendor</sdk:vendor>
<sdk:path>extra_api_dep</sdk:path>
<sdk:uses-license ref="license2" />
<sdk:revision>2</sdk:revision>
diff --git a/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_3.xml b/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_3.xml
index 5da497a..05a9c79 100755
--- a/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_3.xml
+++ b/sdkmanager/libs/sdklib/tests/com/android/sdklib/testdata/repository_sample_3.xml
@@ -206,6 +206,7 @@
</sdk:platform-tool>
<sdk:extra>
+ <sdk:vendor>a</sdk:vendor>
<sdk:path>usb_driver</sdk:path>
<sdk:uses-license ref="license2" />
<sdk:revision>43</sdk:revision>
@@ -223,6 +224,7 @@
</sdk:extra>
<sdk:extra>
+ <sdk:vendor>android_vendor</sdk:vendor>
<sdk:path>extra_api_dep</sdk:path>
<sdk:uses-license ref="license2" />
<sdk:revision>2</sdk:revision>