BUG 2040986 : SDK Updater, platform dependency on tools

This commit is contained in:
Raphael
2009-08-12 18:12:33 -07:00
parent f9775cae58
commit 3d4dec9184
6 changed files with 122 additions and 30 deletions

View File

@@ -33,10 +33,29 @@ import java.util.Properties;
*/
public class ExtraPackage extends Package {
private static final String PROP_PATH = "Extra.Path"; //$NON-NLS-1$
private static final String PROP_PATH = "Extra.Path"; //$NON-NLS-1$
private static final String PROP_MIN_TOOLS_REV = "Extra.MinToolsRev"; //$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.
* 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 mPath;
/**
* The minimal revision of the tools package required by this extra package, if > 0,
* or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
*/
private final int mMinToolsRevision;
/**
* The value of {@link #mMinToolsRevision} when the {@link SdkRepository#NODE_MIN_TOOLS_REV}
* was not specified in the XML source.
*/
public static final int MIN_TOOLS_REV_NOT_SPECIFIED = 0;
/**
* Creates a new tool package from the attributes and elements of the given XML node.
* <p/>
@@ -45,6 +64,8 @@ public class ExtraPackage extends Package {
ExtraPackage(RepoSource source, Node packageNode, Map<String,String> licenses) {
super(source, packageNode, licenses);
mPath = XmlParserUtils.getXmlString(packageNode, SdkRepository.NODE_PATH);
mMinToolsRevision = XmlParserUtils.getXmlInt(packageNode, SdkRepository.NODE_MIN_TOOLS_REV,
MIN_TOOLS_REV_NOT_SPECIFIED);
}
/**
@@ -73,6 +94,9 @@ public class ExtraPackage extends Package {
archiveOsPath);
// The path argument comes before whatever could be in the properties
mPath = path != null ? path : getProperty(props, PROP_PATH, path);
mMinToolsRevision = Integer.parseInt(getProperty(props, PROP_MIN_TOOLS_REV,
Integer.toString(MIN_TOOLS_REV_NOT_SPECIFIED)));
}
/**
@@ -84,6 +108,10 @@ public class ExtraPackage extends Package {
super.saveProperties(props);
props.setProperty(PROP_PATH, mPath);
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
props.setProperty(PROP_MIN_TOOLS_REV, Integer.toString(mMinToolsRevision));
}
}
/**
@@ -109,6 +137,14 @@ public class ExtraPackage extends Package {
return mPath;
}
/**
* The minimal revision of the tools package required by this extra package, if > 0,
* or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
*/
public int getMinToolsRevision() {
return mMinToolsRevision;
}
/** Returns a short description for an {@link IDescription}. */
@Override
public String getShortDescription() {
@@ -134,18 +170,32 @@ public class ExtraPackage extends Package {
}
}
return String.format("%1$s package, revision %2$d",
String s = String.format("%1$s package, revision %2$d",
name,
getRevision());
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
s += String.format(" (tools rev: %1$d)", mMinToolsRevision);
}
return s;
}
/** Returns a long description for an {@link IDescription}. */
@Override
public String getLongDescription() {
return String.format("Extra %1$s package, revision %2$d.\n%3$s",
String s = String.format("Extra %1$s package, revision %2$d",
getPath(),
getRevision(),
super.getLongDescription());
getRevision());
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
s += String.format(" (min tools rev.: %1$d)", mMinToolsRevision);
}
s += ".\n";
s += super.getLongDescription();
return s;
}
/**

View File

@@ -35,11 +35,27 @@ import java.util.Properties;
*/
public class PlatformPackage extends Package {
private static final String PROP_VERSION = "Platform.Version"; //$NON-NLS-1$
private static final String PROP_VERSION = "Platform.Version"; //$NON-NLS-1$
private static final String PROP_MIN_TOOLS_REV = "Platform.MinToolsRev"; //$NON-NLS-1$
/** The package version, for platform, add-on and doc packages. */
private final AndroidVersion mVersion;
/** The version, a string, for platform packages. */
private final String mVersionName;
/**
* The minimal revision of the tools package required by this extra package, if > 0,
* or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
*/
private final int mMinToolsRevision;
/**
* The value of {@link #mMinToolsRevision} when the {@link SdkRepository#NODE_MIN_TOOLS_REV}
* was not specified in the XML source.
*/
public static final int MIN_TOOLS_REV_NOT_SPECIFIED = 0;
/**
* Creates a new platform package from the attributes and elements of the given XML node.
* <p/>
@@ -54,6 +70,9 @@ public class PlatformPackage extends Package {
codeName = null;
}
mVersion = new AndroidVersion(apiLevel, codeName);
mMinToolsRevision = XmlParserUtils.getXmlInt(packageNode, SdkRepository.NODE_MIN_TOOLS_REV,
MIN_TOOLS_REV_NOT_SPECIFIED);
}
/**
@@ -76,6 +95,9 @@ public class PlatformPackage extends Package {
mVersion = target.getVersion();
mVersionName = target.getVersionName();
mMinToolsRevision = Integer.parseInt(getProperty(props, PROP_MIN_TOOLS_REV,
Integer.toString(MIN_TOOLS_REV_NOT_SPECIFIED)));
}
/**
@@ -87,9 +109,14 @@ public class PlatformPackage extends Package {
super.saveProperties(props);
mVersion.saveProperties(props);
if (mVersionName != null) {
props.setProperty(PROP_VERSION, mVersionName);
}
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
props.setProperty(PROP_MIN_TOOLS_REV, Integer.toString(mMinToolsRevision));
}
}
/** Returns the version, a string, for platform packages. */
@@ -102,17 +129,32 @@ public class PlatformPackage extends Package {
return mVersion;
}
/**
* The minimal revision of the tools package required by this extra package, if > 0,
* or {@link #MIN_TOOLS_REV_NOT_SPECIFIED} if there is no such requirement.
*/
public int getMinToolsRevision() {
return mMinToolsRevision;
}
/** Returns a short description for an {@link IDescription}. */
@Override
public String getShortDescription() {
if (mVersion.isPreview()) {
return String.format("SDK Platform Android %1$s (Preview)",
getVersionName());
}
String s;
return String.format("SDK Platform Android %1$s, API %2$d",
if (mVersion.isPreview()) {
s = String.format("SDK Platform Android %1$s (Preview)", getVersionName());
} else {
s = String.format("SDK Platform Android %1$s, API %2$d",
getVersionName(),
mVersion.getApiLevel());
}
if (mMinToolsRevision != MIN_TOOLS_REV_NOT_SPECIFIED) {
s += String.format(" (tools rev: %1$d)", mMinToolsRevision);
}
return s;
}
/** Returns a long description for an {@link IDescription}. */

View File

@@ -49,19 +49,21 @@ public class SdkRepository {
public static final String NODE_EXTRA = "extra"; //$NON-NLS-1$
/** The license definition. */
public static final String NODE_LICENSE = "license"; //$NON-NLS-1$
public static final String NODE_LICENSE = "license"; //$NON-NLS-1$
/** The optional uses-license for all packages (platform, add-on, tool, doc) or for a lib. */
public static final String NODE_USES_LICENSE = "uses-license"; //$NON-NLS-1$
public static final String NODE_USES_LICENSE = "uses-license"; //$NON-NLS-1$
/** The revision, an int > 0, for all packages (platform, add-on, tool, doc). */
public static final String NODE_REVISION = "revision"; //$NON-NLS-1$
public static final String NODE_REVISION = "revision"; //$NON-NLS-1$
/** The optional description for all packages (platform, add-on, tool, doc) or for a lib. */
public static final String NODE_DESCRIPTION = "description"; //$NON-NLS-1$
public static final String NODE_DESCRIPTION = "description"; //$NON-NLS-1$
/** The optional description URL for all packages (platform, add-on, tool, doc). */
public static final String NODE_DESC_URL = "desc-url"; //$NON-NLS-1$
public static final String NODE_DESC_URL = "desc-url"; //$NON-NLS-1$
/** The optional release note for all packages (platform, add-on, tool, doc). */
public static final String NODE_RELEASE_NOTE = "release-note"; //$NON-NLS-1$
public static final String NODE_RELEASE_NOTE = "release-note"; //$NON-NLS-1$
/** The optional release note URL for all packages (platform, add-on, tool, doc). */
public static final String NODE_RELEASE_URL = "release-url"; //$NON-NLS-1$
public static final String NODE_RELEASE_URL = "release-url"; //$NON-NLS-1$
/** The optional minimal tools revision required by platform & extra packages. */
public static final String NODE_MIN_TOOLS_REV = "min-tools-rev"; //$NON-NLS-1$
/** The version, a string, for platform packages. */
public static final String NODE_VERSION = "version"; //$NON-NLS-1$

View File

@@ -71,6 +71,9 @@
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
<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" />
</xsd:all>
</xsd:complexType>
</xsd:element>
@@ -241,6 +244,9 @@
<xsd:element name="release-url" type="xsd:token" minOccurs="0" />
<!-- A list of file archives for this package. -->
<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" />
</xsd:all>
</xsd:complexType>
</xsd:element>

View File

@@ -43,6 +43,7 @@
for this package. It's a free multi-line text.
</sdk:release-note>
<sdk:release-url>http://some/url/for/the/release/note.html</sdk:release-url>
<sdk:min-tools-rev>2</sdk:min-tools-rev>
<!-- The archives node is mandatory and it cannot be empty. -->
<sdk:archives>
<sdk:archive os="any">
@@ -268,6 +269,7 @@
</sdk:archives>
<sdk:description>An Extra package for the USB driver, it will install in $SDK/usb_driver</sdk:description>
<sdk:desc-url>http://www.example.com/extra.html</sdk:desc-url>
<sdk:min-tools-rev>3</sdk:min-tools-rev>
</sdk:extra>
</sdk:sdk-repository>