Change the default of --api-overloaded-method-order from source to signature
Needed to match the behavior that AndroidX expects.
Bug: 285312164
Test: ./gradlew
m checkapi
Change-Id: I89289f949f73420418e54eb143f42ec123d79bd5
diff --git a/src/main/java/com/android/tools/metalava/Options.kt b/src/main/java/com/android/tools/metalava/Options.kt
index 635dd00..8718d6b 100644
--- a/src/main/java/com/android/tools/metalava/Options.kt
+++ b/src/main/java/com/android/tools/metalava/Options.kt
@@ -445,7 +445,7 @@
* Determines how overloaded methods, i.e. methods with the same name, are ordered in signature
* files.
*/
- var apiOverloadedMethodOrder: OverloadedMethodOrder = OverloadedMethodOrder.SOURCE
+ var apiOverloadedMethodOrder: OverloadedMethodOrder = OverloadedMethodOrder.SIGNATURE
/** Like [apiFile], but with JDiff xml format. */
var apiXmlFile: File? = null
@@ -2192,7 +2192,7 @@
"$ARG_DEX_API <file>", "Generate a DEX signature descriptor file listing the APIs",
"$ARG_REMOVED_API <file>", "Generate a signature descriptor file for APIs that have been removed",
"$ARG_API_OVERLOADED_METHOD_ORDER <source|signature>",
- "Specifies the order of overloaded methods in signature files (default `source`). " +
+ "Specifies the order of overloaded methods in signature files (default `signature`). " +
"Applies to the contents of the files specified on $ARG_API and $ARG_REMOVED_API. " +
"`$ARG_API_OVERLOADED_METHOD_ORDER source` will preserve the order in which they appear in the source files. " +
"`$ARG_API_OVERLOADED_METHOD_ORDER signature` will sort them based on their signature.",
diff --git a/src/test/java/com/android/tools/metalava/ApiFileTest.kt b/src/test/java/com/android/tools/metalava/ApiFileTest.kt
index 0b6ffa1..80670c2 100644
--- a/src/test/java/com/android/tools/metalava/ApiFileTest.kt
+++ b/src/test/java/com/android/tools/metalava/ApiFileTest.kt
@@ -3881,8 +3881,7 @@
check(
signatureSources = arrayOf(source1, source2),
api = expected,
- // Use the default overloaded method order when no command line option is supplied.
- overloadedMethodOrder = null,
+ overloadedMethodOrder = Options.OverloadedMethodOrder.SOURCE,
format = FileFormat.V2,
)
}
diff --git a/src/test/java/com/android/tools/metalava/OptionsTest.kt b/src/test/java/com/android/tools/metalava/OptionsTest.kt
index 1973436..480b868 100644
--- a/src/test/java/com/android/tools/metalava/OptionsTest.kt
+++ b/src/test/java/com/android/tools/metalava/OptionsTest.kt
@@ -188,7 +188,7 @@
Generate a signature descriptor file for APIs that have been removed
--api-overloaded-method-order <source|signature>
Specifies the order of overloaded methods in signature files (default
- `source`). Applies to the contents of the files specified on --api and
+ `signature`). Applies to the contents of the files specified on --api and
--removed-api. `--api-overloaded-method-order source` will preserve the
order in which they appear in the source files.
`--api-overloaded-method-order signature` will sort them based on their