diff --git a/build.gradle b/build.gradle index bfa6d11f65af4bf533b3689da4446b45df021ec3..1fb56b1b6507ea6b2384e4893c5240c44b04ade8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ buildscript { ext.gradle_version = '3.4.0-beta01' ext.studio_version = '26.4.0-beta01' - ext.kotlin_version = '1.3.11' + ext.kotlin_version = '1.3.20' repositories { google() jcenter() diff --git a/src/main/java/com/android/tools/metalava/Options.kt b/src/main/java/com/android/tools/metalava/Options.kt index a3e67939321d2873fe61b3144e348ee874bb87a8..539d7e5a9010decfc2100bb50207cac6308408a2 100644 --- a/src/main/java/com/android/tools/metalava/Options.kt +++ b/src/main/java/com/android/tools/metalava/Options.kt @@ -1249,18 +1249,19 @@ class Options( true else yesNo(arg.substring(ARG_INCLUDE_SIG_VERSION.length + 1)) } else if (arg.startsWith(ARG_FORMAT)) { - when (arg) { + outputFormat = when (arg) { "$ARG_FORMAT=v1" -> { - FileFormat.V1.configureOptions(this, compatibility) + FileFormat.V1 } "$ARG_FORMAT=v2" -> { - FileFormat.V2.configureOptions(this, compatibility) + FileFormat.V2 } "$ARG_FORMAT=v3" -> { - FileFormat.V3.configureOptions(this, compatibility) + FileFormat.V3 } else -> throw DriverException(stderr = "Unexpected signature format; expected v1, v2 or v3") } + outputFormat.configureOptions(this, compatibility) } else if (arg.startsWith("-")) { // Compatibility flag; map to mutable properties in the Compatibility // class and assign it @@ -1329,6 +1330,12 @@ class Options( apiLevelJars = findAndroidJars(androidJarPatterns!!, currentApiLevel, currentCodeName, currentJar) } + // outputKotlinStyleNulls implies format=v3 + if (outputKotlinStyleNulls) { + outputFormat = FileFormat.V3 + outputFormat.configureOptions(this, compatibility) + } + // If the caller has not explicitly requested that unannotated classes and // members should be shown in the output then only show them if no annotations were provided. if (!showUnannotated && showAnnotations.isEmpty()) { diff --git a/src/main/resources/version.properties b/src/main/resources/version.properties index 0e3b7f676ee6a72ba7c8b5120079798fdd601608..82254daf6b0abda134a44b1124916b63ede1603e 100644 --- a/src/main/resources/version.properties +++ b/src/main/resources/version.properties @@ -2,4 +2,4 @@ # Version definition # This file is read by gradle build scripts, but also packaged with metalava # as a resource for the Version classes to read. -metalavaVersion=1.2.6 +metalavaVersion=1.2.7 diff --git a/src/test/java/com/android/tools/metalava/ApiFileTest.kt b/src/test/java/com/android/tools/metalava/ApiFileTest.kt index 61bf8012fcb7cc1d1e15d5daa652a19f981df815..d80da35056339ddfb28913dac54e8ffaaea32b50 100644 --- a/src/test/java/com/android/tools/metalava/ApiFileTest.kt +++ b/src/test/java/com/android/tools/metalava/ApiFileTest.kt @@ -613,6 +613,7 @@ class ApiFileTest : DriverTest() { androidxNullableSource ), api = """ + // Signature format: 3.0 package androidx.util { public class NonNullableJavaPair<F, S> { ctor public NonNullableJavaPair(F, S); @@ -712,6 +713,7 @@ class ApiFileTest : DriverTest() { androidxNullableSource ), api = """ + // Signature format: 3.0 package test { public class MyClass { ctor public MyClass(); diff --git a/src/test/java/com/android/tools/metalava/ApiFromTextTest.kt b/src/test/java/com/android/tools/metalava/ApiFromTextTest.kt index bbc1439e528c29ed8cc7d5cf4d216b48173fdfe9..abbf5f1e3c1649260f99a5177528827b9823747e 100644 --- a/src/test/java/com/android/tools/metalava/ApiFromTextTest.kt +++ b/src/test/java/com/android/tools/metalava/ApiFromTextTest.kt @@ -653,6 +653,7 @@ class ApiFromTextTest : DriverTest() { @Test fun `Deprecated enum constant`() { val source = """ + // Signature format: 3.0 package androidx.annotation { @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.CLASS) @java.lang.annotation.Target({java.lang.annotation.ElementType.ANNOTATION_TYPE, java.lang.annotation.ElementType.TYPE, java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.CONSTRUCTOR, java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.PACKAGE}) public @interface RestrictTo { method public abstract androidx.annotation.RestrictTo.Scope[] value(); @@ -677,8 +678,9 @@ class ApiFromTextTest : DriverTest() { } @Test - fun `Type parameters in v2 format`() { + fun `Type parameters in v3 format`() { val source = """ + // Signature format: 3.0 package androidx.collection { public class Constants { field public static final String GOOD_IRI_CHAR = "a-zA-Z0-9\u00a0-\ud7ff\uf900-\ufdcf\ufdf0-\uffef"; diff --git a/src/test/java/com/android/tools/metalava/NullnessMigrationTest.kt b/src/test/java/com/android/tools/metalava/NullnessMigrationTest.kt index b74d384258fe858cd606224ebd0526ecd40215b5..a3ddfaf87021e7709380f4888138f80d4d7e3cd3 100644 --- a/src/test/java/com/android/tools/metalava/NullnessMigrationTest.kt +++ b/src/test/java/com/android/tools/metalava/NullnessMigrationTest.kt @@ -259,6 +259,7 @@ class NullnessMigrationTest : DriverTest() { } """, api = """ + // Signature format: 3.0 package test.pkg { public class MyTest { ctor public MyTest();