Use {version:major.minor?} when generating api-versions.xml
Previously, `droidstubs` would pass Metalava `--android-jar-pattern`
options using `{version:level}` as the placeholder for the version.
That meant that Metalava would only use historical API version jars
that had a single integer version, e.g. `prebuilts/sdk/36`. While that
was sufficient in the past, it will not be sufficient in future when
Android starts supporting `major.minor` versions.
This change switches the pattern to use `{version:major.minor?}`. That
will match files without `.minor` so it will match all the files that
would have been matched by the existing `{version:level}`, It will also
match files with `.minor`, e.g. files like `prebuilts/sdk/37.1`.
Bug: 302189716
Test: # Before applying this change run:
tools/metalava/scripts/gather-android-metalava-artifacts.py before
# After applying this change run:
tools/metalava/scripts/gather-android-metalava-artifacts.py after
# Make sure that there are no differences.
meld before after
# Then create a major.minor version in prebuilts/sdk by running:
cp -r prebuilts/sdk/35 prebuilts/sdk/34.1
# Run the following
tools/metalava/scripts/gather-android-metalava-artifacts.py major-minor
# Make sure references to 35 in `api-versions.xml` and doc stubs have
# been replaced with 34.1.
meld before major-minor
Change-Id: I94167ae12f1059853e8e2253eb20442b61dfdebb
diff --git a/java/droidstubs.go b/java/droidstubs.go
index f2edd06..e0c2e63 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -657,7 +657,7 @@
for _, sdkDir := range sdkDirs {
for _, dir := range dirs {
addPattern := func(jarFilename string) {
- cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/{version:level}/%s/%s", dir, sdkDir, jarFilename))
+ cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/{version:major.minor?}/%s/%s", dir, sdkDir, jarFilename))
}
if sdkDir == "module-lib" || sdkDir == "system-server" {