1// Copyright 2018 The Android Open Source Project
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// Set of error prone rules to ensure code quality
16// PackageLocation check requires the androidCompatible=false otherwise it does not do anything.
17java_defaults {
18  name: "tradefed_errorprone_defaults",
19  errorprone: {
20    javacflags: [
21      "-XDandroidCompatible=false",
22      "-Xep:ArrayToString:ERROR",
23      "-Xep:BoxedPrimitiveConstructor:ERROR",
24      "-Xep:CatchFail:ERROR",
25      "-Xep:ConstantField:ERROR",
26      "-Xep:DeadException:ERROR",
27      "-Xep:EqualsIncompatibleType:ERROR",
28      "-Xep:ExtendingJUnitAssert:ERROR",
29      "-Xep:FormatString:ERROR",
30      "-Xep:GetClassOnClass:ERROR",
31      "-Xep:IdentityBinaryExpression:ERROR",
32      "-Xep:JUnit3TestNotRun:ERROR",
33      "-Xep:JUnit4TestNotRun:ERROR",
34      "-Xep:JUnit4ClassUsedInJUnit3:ERROR",
35      "-Xep:JUnitAmbiguousTestClass:ERROR",
36      "-Xep:MissingFail:ERROR",
37      "-Xep:MissingOverride:ERROR",
38      "-Xep:ModifiedButNotUsed:ERROR",
39      "-Xep:MustBeClosedChecker:ERROR",
40      "-Xep:Overrides:ERROR",
41      "-Xep:PackageLocation:ERROR",
42      "-Xep:ParameterName:ERROR",
43      "-Xep:ReferenceEquality:ERROR",
44      "-Xep:RemoveUnusedImports:ERROR",
45      "-Xep:ReturnValueIgnored:ERROR",
46      "-Xep:SelfEquals:ERROR",
47      "-Xep:SizeGreaterThanOrEqualsZero:ERROR",
48      "-Xep:TryFailThrowable:ERROR",
49      "-Xep:UnnecessaryParentheses:ERROR",
50      "-Xep:UseCorrectAssertInTests:ERROR",
51    ],
52  },
53}
54
55java_defaults {
56  name: "tradefed_defaults",
57  defaults: [ "tradefed_errorprone_defaults" ],
58  javacflags: [
59    "-g",
60    "-Xlint",
61  ],
62}
63
64java_library_host {
65    name: "tradefed-protos",
66    srcs: ["proto/**/*.proto"],
67    libs: [
68        "libprotobuf-java-full",
69    ],
70    proto: {
71        include_dirs: ["external/protobuf/src"],
72        type: "full",
73    },
74    static_libs: [
75        "platformprotos",
76        "asuite_proto_java",
77    ],
78}
79
80python_library_host {
81    name: "tradefed-protos-py",
82    pkg_path: "atest",
83    srcs: ["proto/**/*.proto"],
84    libs: [
85        "libprotobuf-python",
86    ],
87    proto: {
88        include_dirs: ["external/protobuf/src"],
89    },
90    version: {
91        py2: {
92            enabled: true,
93        },
94        py3: {
95            enabled: true,
96        },
97    },
98}
99
100// Main Target to build tradefed jar
101java_library_host {
102    name: "tradefed",
103    defaults: ["tradefed_defaults"],
104    java_resource_dirs: [
105        "res",
106    ],
107    static_libs: [
108        "tradefed-lib-core",
109        "tradefed-test-framework",
110    ],
111    manifest: "MANIFEST.mf",
112}
113
114// Tradefed build target without the test framework statically linked
115java_library_host {
116    name: "tradefed-no-fwk",
117    defaults: ["tradefed_defaults"],
118    java_resource_dirs: [
119        "res",
120    ],
121    static_libs: [
122        "tradefed-lib-core",
123    ],
124    libs: [
125        "tradefed-test-framework",
126    ],
127    manifest: "MANIFEST.mf",
128}
129
130java_library_host {
131    name: "tradefed-lib-core",
132    defaults: ["tradefed_defaults"],
133    srcs: [
134        "src/**/*.java",
135        "global_configuration/**/*.java",
136    ],
137    static_libs: [
138        "tradefed-common-util",
139        "tradefed-clearcut-client",
140        "tradefed-result-interfaces",
141        "tradefed-device-build-interfaces",
142        "tradefed-invocation-interfaces",
143        "protobuf-java-util-prebuilt-jar",
144        "aoa-helper",
145        "error_prone_annotations-2.0.18",
146        "google-api-java-client-min-repackaged",
147        "google-api-services-compute",
148        "google-api-services-storage",
149        "gson-prebuilt-jar",
150        "guice",
151        "jacoco-cli",
152        "jline-1.0",
153        "junit-params",
154        "kxml2-2.3.0",
155        "libprotobuf-java-full",
156        "platform-test-annotations",
157        "snakeyaml",
158        "tf-remote-client",
159        "tradefed-protos",
160        "tradefed-isolation-protos",
161        "tradefed-lite",
162    ],
163    libs: [
164        "loganalysis",
165    ],
166}
167
168// Turn off various doclava warnings when generating
169// the docs. These are the same warnings that are
170// turned off in frameworks/base, plus error 101
171// which is necessary here because tradefed is
172// referencing bootclasspath classes that are not
173// feed to metalava when generating the stubs.
174tradefed_docs_only_args = " -hide 101 -hide 111 -hide 113 -hide 125 -hide 126 -hide 127 -hide 128 "
175
176droidstubs_host {
177    name: "tradefed-doc-stubs",
178    srcs: [
179        "src/**/*.java",
180    ],
181    libs: [
182        "loganalysis",
183        "tradefed",
184    ],
185    args: tradefed_docs_only_args + "--package",
186    create_doc_stubs: true,
187}
188
189droiddoc_host {
190    name: "tradefed-docs",
191    srcs: [
192        ":tradefed-doc-stubs",
193    ],
194    libs: [
195        "loganalysis",
196        "tradefed",
197    ],
198    custom_template: "droiddoc-templates-sdk",
199    hdf: [
200        "sac true",
201        "devices true",
202        "android.whichdoc online",
203        "css.path /reference/assets/css/doclava-devsite.css",
204        "book.root toc",
205        "book.path /_book.yaml",
206    ],
207    args: tradefed_docs_only_args +
208          "-yaml _book.yaml " +
209          "-apidocsdir reference/tradefed/ " +
210          "-werror " +
211          "-package " +
212          "-devsite ",
213    create_stubs: false,
214}
215
216sh_binary_host {
217    name: "tradefed.sh",
218    src: "tradefed.sh",
219}
220
221sh_binary_host {
222    name: "tradefed_win",
223    src: "tradefed_win.bat",
224}
225
226sh_binary_host {
227    name: "script_help.sh",
228    src: "script_help.sh",
229}
230
231sh_binary_host {
232    name: "run_tf_cmd.sh",
233    src: "run_tf_cmd.sh",
234}
235
236sh_binary_host {
237    name: "atest_tradefed.sh",
238    src: "atest_tradefed.sh",
239}
240