BUG 2040986 : SDK Updater, platform dependency on tools
This commit is contained in:
@@ -34,9 +34,28 @@ 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_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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,10 +36,26 @@ 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_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,19 +129,34 @@ 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}. */
|
||||
@Override
|
||||
public String getLongDescription() {
|
||||
|
||||
@@ -62,6 +62,8 @@ public class SdkRepository {
|
||||
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$
|
||||
/** 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$
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -38,11 +38,13 @@ import org.eclipse.swt.events.ControlAdapter;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
@@ -105,18 +107,6 @@ public class RemotePackagesPage extends Composite implements ISdkListener {
|
||||
mColumnSource.setWidth(289);
|
||||
mColumnSource.setText("Sources, Packages and Archives");
|
||||
|
||||
Composite composite = new Composite(parent, SWT.NONE);
|
||||
composite.setLayoutData(
|
||||
new GridData(SWT.FILL, SWT.BEGINNING, false, false, 5, 1));
|
||||
GridLayout gl;
|
||||
composite.setLayout(gl = new GridLayout(2, false));
|
||||
gl.marginHeight = gl.marginWidth = 0;
|
||||
// add an empty composite
|
||||
Composite spacer = new Composite(composite, SWT.NONE);
|
||||
GridData gd;
|
||||
spacer.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
|
||||
gd.heightHint = 0;
|
||||
|
||||
mDescriptionContainer = new Group(parent, SWT.NONE);
|
||||
mDescriptionContainer.setLayout(new GridLayout(1, false));
|
||||
mDescriptionContainer.setText("Description");
|
||||
|
||||
Reference in New Issue
Block a user