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