blob: 7029fee06277d2ca9bc98308057154b30a64c012 [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",
26 "--hide InvalidNullabilityOverride",
Liz Kammere09e20e2023-10-16 15:07:54 -040027
28 // Force metalava to ignore classes on the classpath when an API file contains missing classes.
29 // See b/285140653 for more information.
30 "--api-class-resolution api",
31
32 // Force metalava to sort overloaded methods by their order in the source code.
33 // See b/285312164 for more information.
34 // And add concrete overrides of abstract methods, see b/299366704 for more
35 // information.
36 "--format-defaults overloaded-method-order=source,add-additional-overrides=yes",
37 }
38
39 MetalavaFlags = strings.Join(metalavaFlags, " ")
40
41 metalavaAnnotationsFlags = []string{
42 "--include-annotations",
43 "--exclude-annotation androidx.annotation.RequiresApi",
44 }
45
46 MetalavaAnnotationsFlags = strings.Join(metalavaAnnotationsFlags, " ")
47
48 metalavaAnnotationsWarningsFlags = []string{
49 // TODO(tnorbye): find owners to fix these warnings when annotation was enabled.
50 "--hide HiddenTypedefConstant",
51 "--hide SuperfluousPrefix",
52 "--hide AnnotationExtraction",
53 // b/222738070
54 "--hide BannedThrow",
Liz Kammere09e20e2023-10-16 15:07:54 -040055 }
56
57 MetalavaAnnotationsWarningsFlags = strings.Join(metalavaAnnotationsWarningsFlags, " ")
58
59 metalavaHideFlaggedApis = []string{
Paul Duffin7ac943f2023-12-12 23:13:57 +000060 "--revert-annotation",
Liz Kammere09e20e2023-10-16 15:07:54 -040061 "android.annotation.FlaggedApi",
62 }
63
64 MetalavaHideFlaggedApis = strings.Join(metalavaHideFlaggedApis, " ")
65)
66
67const (
68 MetalavaAddOpens = "-J--add-opens=java.base/java.util=ALL-UNNAMED"
69)
70
71func init() {
72 exportedVars.ExportStringList("MetalavaFlags", metalavaFlags)
73
74 exportedVars.ExportString("MetalavaAddOpens", MetalavaAddOpens)
75
76 exportedVars.ExportStringList("MetalavaHideFlaggedApis", metalavaHideFlaggedApis)
77
78 exportedVars.ExportStringListStaticVariable("MetalavaAnnotationsFlags", metalavaAnnotationsFlags)
79
80 exportedVars.ExportStringListStaticVariable("MetalavaAnnotationWarningsFlags", metalavaAnnotationsWarningsFlags)
81}