| Liz Kammer | e09e20e | 2023-10-16 15:07:54 -0400 | [diff] [blame] | 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 |  | 
|  | 15 | package config | 
|  | 16 |  | 
|  | 17 | import "strings" | 
|  | 18 |  | 
|  | 19 | var ( | 
|  | 20 | metalavaFlags = []string{ | 
|  | 21 | "--color", | 
|  | 22 | "--quiet", | 
|  | 23 | "--format=v2", | 
|  | 24 | "--repeat-errors-max 10", | 
|  | 25 | "--hide UnresolvedImport", | 
| Liz Kammer | e09e20e | 2023-10-16 15:07:54 -0400 | [diff] [blame] | 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", | 
| Liz Kammer | e09e20e | 2023-10-16 15:07:54 -0400 | [diff] [blame] | 51 | } | 
|  | 52 |  | 
|  | 53 | MetalavaAnnotationsWarningsFlags = strings.Join(metalavaAnnotationsWarningsFlags, " ") | 
| Liz Kammer | e09e20e | 2023-10-16 15:07:54 -0400 | [diff] [blame] | 54 | ) | 
|  | 55 |  | 
|  | 56 | const ( | 
|  | 57 | MetalavaAddOpens = "-J--add-opens=java.base/java.util=ALL-UNNAMED" | 
|  | 58 | ) | 
|  | 59 |  | 
|  | 60 | func init() { | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 61 | pctx.StaticVariable("MetalavaAnnotationsFlags", strings.Join(metalavaAnnotationsFlags, " ")) | 
| Liz Kammer | e09e20e | 2023-10-16 15:07:54 -0400 | [diff] [blame] | 62 |  | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 63 | pctx.StaticVariable("MetalavaAnnotationWarningsFlags", strings.Join(metalavaAnnotationsWarningsFlags, " ")) | 
| Liz Kammer | e09e20e | 2023-10-16 15:07:54 -0400 | [diff] [blame] | 64 | } |