blob: 04a3f96b98cf103c02907f94a10a498b9c05d97a [file] [log] [blame]
Liz Kammere09e20e2023-10-16 15:07:54 -04001// 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",
Liz Kammere09e20e2023-10-16 15:07:54 -040026
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 Kammere09e20e2023-10-16 15:07:54 -040051 }
52
53 MetalavaAnnotationsWarningsFlags = strings.Join(metalavaAnnotationsWarningsFlags, " ")
Liz Kammere09e20e2023-10-16 15:07:54 -040054)
55
56const (
57 MetalavaAddOpens = "-J--add-opens=java.base/java.util=ALL-UNNAMED"
58)
59
60func init() {
Cole Faust8982b1c2024-04-08 16:54:45 -070061 pctx.StaticVariable("MetalavaAnnotationsFlags", strings.Join(metalavaAnnotationsFlags, " "))
Liz Kammere09e20e2023-10-16 15:07:54 -040062
Cole Faust8982b1c2024-04-08 16:54:45 -070063 pctx.StaticVariable("MetalavaAnnotationWarningsFlags", strings.Join(metalavaAnnotationsWarningsFlags, " "))
Liz Kammere09e20e2023-10-16 15:07:54 -040064}