1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tools.metalava 18 19 import com.android.tools.metalava.doclava1.Errors 20 import com.android.tools.metalava.model.ErrorConfiguration 21 22 enum class ReleaseType(val flagName: String, private val displayName: String = flagName) { 23 DEV("current", "development") { 24 /** 25 * Customization of the severities to apply when doing compatibility checking against the 26 * current version of the API. Corresponds to the same flags passed into doclava's error 27 * check this way: 28 * args: "-error 2 -error 3 -error 4 -error 5 -error 6 " + 29 * "-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 " + 30 * "-error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 " + 31 * "-error 25 -error 26 -error 27", 32 */ getErrorConfigurationnull33 override fun getErrorConfiguration(): ErrorConfiguration { 34 return super.getErrorConfiguration().apply { 35 error(Errors.ADDED_CLASS) 36 error(Errors.ADDED_FIELD) 37 error(Errors.ADDED_FINAL_UNINSTANTIABLE) 38 error(Errors.ADDED_INTERFACE) 39 error(Errors.ADDED_METHOD) 40 error(Errors.ADDED_PACKAGE) 41 error(Errors.CHANGED_ABSTRACT) 42 error(Errors.CHANGED_CLASS) 43 error(Errors.CHANGED_DEPRECATED) 44 error(Errors.CHANGED_SCOPE) 45 error(Errors.CHANGED_SYNCHRONIZED) 46 error(Errors.CHANGED_THROWS) 47 error(Errors.REMOVED_FINAL) 48 } 49 } 50 }, 51 52 RELEASED("released", "released") { 53 /** 54 * Customization of the severities to apply when doing compatibility checking against the 55 * previously released stable version of the API. Corresponds to the same flags passed into 56 * doclava's error check this way: 57 * args: "-hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 " + 58 * "-error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 " + 59 * "-error 16 -error 17 -error 18 -error 31", 60 */ getErrorConfigurationnull61 override fun getErrorConfiguration(): ErrorConfiguration { 62 return super.getErrorConfiguration().apply { 63 error(Errors.ADDED_ABSTRACT_METHOD) 64 hide(Errors.ADDED_CLASS) 65 hide(Errors.ADDED_FIELD) 66 hide(Errors.ADDED_FINAL_UNINSTANTIABLE) 67 hide(Errors.ADDED_INTERFACE) 68 hide(Errors.ADDED_METHOD) 69 hide(Errors.ADDED_PACKAGE) 70 hide(Errors.CHANGED_DEPRECATED) 71 hide(Errors.CHANGED_SYNCHRONIZED) 72 hide(Errors.REMOVED_FINAL) 73 } 74 } 75 }; 76 77 /** Returns the error configuration to use for the given release type */ getErrorConfigurationnull78 open fun getErrorConfiguration(): ErrorConfiguration { 79 return ErrorConfiguration().apply { 80 error(Errors.ADDED_FINAL) 81 error(Errors.CHANGED_STATIC) 82 error(Errors.CHANGED_SUPERCLASS) 83 error(Errors.CHANGED_TRANSIENT) 84 error(Errors.CHANGED_TYPE) 85 error(Errors.CHANGED_VALUE) 86 error(Errors.CHANGED_VOLATILE) 87 error(Errors.REMOVED_CLASS) 88 error(Errors.REMOVED_FIELD) 89 error(Errors.REMOVED_INTERFACE) 90 error(Errors.REMOVED_METHOD) 91 error(Errors.REMOVED_PACKAGE) 92 error(Errors.ADDED_REIFIED) 93 } 94 } 95 toStringnull96 override fun toString(): String = displayName 97 }