1// Copyright 2023 Google Inc. All rights reserved. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package config 16 17import "strings" 18 19var ( 20 metalavaFlags = []string{ 21 "--color", 22 "--quiet", 23 "--format=v2", 24 "--repeat-errors-max 10", 25 "--hide UnresolvedImport", 26 27 // Force metalava to ignore classes on the classpath when an API file contains missing classes. 28 // See b/285140653 for more information. 29 "--api-class-resolution api", 30 31 // Force metalava to sort overloaded methods by their order in the source code. 32 // See b/285312164 for more information. 33 // And add concrete overrides of abstract methods, see b/299366704 for more 34 // information. 35 "--format-defaults overloaded-method-order=source,add-additional-overrides=yes", 36 } 37 38 MetalavaFlags = strings.Join(metalavaFlags, " ") 39 40 metalavaAnnotationsFlags = []string{ 41 "--include-annotations", 42 "--exclude-annotation androidx.annotation.RequiresApi", 43 } 44 45 MetalavaAnnotationsFlags = strings.Join(metalavaAnnotationsFlags, " ") 46 47 metalavaAnnotationsWarningsFlags = []string{ 48 // TODO(tnorbye): find owners to fix these warnings when annotation was enabled. 49 "--hide HiddenTypedefConstant", 50 "--hide SuperfluousPrefix", 51 } 52 53 MetalavaAnnotationsWarningsFlags = strings.Join(metalavaAnnotationsWarningsFlags, " ") 54) 55 56const ( 57 MetalavaAddOpens = "-J--add-opens=java.base/java.util=ALL-UNNAMED" 58) 59 60func init() { 61 pctx.StaticVariable("MetalavaAnnotationsFlags", strings.Join(metalavaAnnotationsFlags, " ")) 62 63 pctx.StaticVariable("MetalavaAnnotationWarningsFlags", strings.Join(metalavaAnnotationsWarningsFlags, " ")) 64} 65