1a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets/* 2a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * Copyright 2018 The Android Open Source Project 3a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * 4a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * Licensed under the Apache License, Version 2.0 (the "License"); 5a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * you may not use this file except in compliance with the License. 6a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * You may obtain a copy of the License at 7a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * 8a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * http://www.apache.org/licenses/LICENSE-2.0 9a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * 10a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * Unless required by applicable law or agreed to in writing, software 11a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * distributed under the License is distributed on an "AS IS" BASIS, 12a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * See the License for the specific language governing permissions and 14a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * limitations under the License. 15a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets */ 16a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets 17a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinetspackage androidx.build.doclava 18a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets 19a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinetsimport java.io.Serializable 20a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets 21a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinetsdata class ChecksConfig( 22a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets /** 23a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * List of Doclava error codes to treat as errors. 24a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * <p> 25a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * See {@link com.google.doclava.Errors} for a complete list of error codes. 26a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets */ 27a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets val errors: List<Int>, 28a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets /** 29a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * List of Doclava error codes to treat as warnings. 30a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * <p> 31a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * See {@link com.google.doclava.Errors} for a complete list of error codes. 32a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets */ 33a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets val warnings: List<Int>, 34a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets /** 35a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * List of Doclava error codes to ignore. 36a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * <p> 37a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets * See {@link com.google.doclava.Errors} for a complete list of error codes. 38a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets */ 39a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets val hidden: List<Int>, 40a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets /** Message to display on check failure. */ 41a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets val onFailMessage: String? = null 42a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets) : Serializable 43a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets 44a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinetsprivate const val MSG_HIDE_API = 45a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "If you are adding APIs that should be excluded from the public API surface,\n" + 46a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "consider using package or private visibility. If the API must have public\n" + 47a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "visibility, you may exclude it from public API by using the @hide javadoc\n" + 48a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "annotation paired with the @RestrictTo(LIBRARY_GROUP) code annotation." 49a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets 50a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinetsval CHECK_API_CONFIG_RELEASE = ChecksConfig( 51a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets onFailMessage = 52a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "Compatibility with previously released public APIs has been broken. Please\n" + 53a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "verify your change with Support API Council and provide error output,\n" + 54a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "including the error messages and associated SHAs.\n" + 55a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "\n" + 56a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "If you are removing APIs, they must be deprecated first before being removed\n" + 57a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "in a subsequent release.\n" + 58a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "\n" + MSG_HIDE_API, 59a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets errors = (7..18).toList(), 60a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets warnings = emptyList(), 61a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets hidden = (2..6) + (19..30) 62a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets) 63a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets 64a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets// Check that the API we're building hasn't changed from the development 65a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets// version. These types of changes require an explicit API file update. 66a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinetsval CHECK_API_CONFIG_DEVELOP = ChecksConfig( 67a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets onFailMessage = 68a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "Public API definition has changed. Please run ./gradlew updateApi to confirm\n" + 69a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "these changes are intentional by updating the public API definition.\n" + 70a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "\n" + MSG_HIDE_API, 71a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets errors = (2..30) - listOf(22), 72a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets warnings = emptyList(), 73a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets hidden = listOf(22) 74a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets) 75a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets 76a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets// This is a patch or finalized release. Check that the API we're building 77a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets// hasn't changed from the current. 78a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinetsval CHECK_API_CONFIG_PATCH = CHECK_API_CONFIG_DEVELOP.copy( 79a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets onFailMessage = "Public API definition may not change in finalized or patch releases.\n" + 80a14b834943469c91933a93da68c81f0ebc0a5719Sergey Vasilinets "\n" + MSG_HIDE_API) 81