1// Copyright (C) 2022 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
15package {
16    default_visibility: ["//visibility:private"],
17    default_applicable_licenses: ["libcore_ojluni_src_test_license"],
18}
19
20license {
21    name: "libcore_ojluni_src_test_license",
22    visibility: [":__subpackages__"],
23    license_kinds: [
24        "SPDX-license-identifier-Apache-2.0",
25        "SPDX-license-identifier-GPL-2.0",
26    ],
27    license_text: [
28        "LICENSE",
29    ],
30}
31
32// Builds the core-ojtests library that contains test code from OpenJDK.
33java_test {
34    name: "core-ojtests",
35    defaults: ["libcore_java_defaults"],
36    hostdex: true,
37
38    srcs: [
39        "java/**/*.java",
40        "javax/**/*.java",
41        "sun/**/*.java",
42    ],
43    java_resource_dirs: [
44        "resources",
45    ],
46
47    java_resources: [
48        ":core-ojtests-java-resources",
49        ":core-ojtests-javax-resources",
50    ],
51
52    sdk_version: "none",
53    system_modules: "core-all-system-modules",
54    libs: [
55        "okhttp",
56        "bouncycastle",
57    ],
58
59    static_libs: [
60        "core-test-rules",
61        "junit",
62        "mockwebserver",
63        "testng",
64    ],
65
66    // ojluni/src/test/java/util/stream/{bootlib,boottest}
67    // contains tests that are in packages from java.base;
68    // By default, OpenJDK 9's javac will only compile such
69    // code if it's declared to also be in java.base at
70    // compile time.
71    //
72    // For now, we use patch_module to put all sources
73    // and dependencies from this make target into java.base;
74    // other source directories in this make target are in
75    // packages not from java.base; if this becomes a problem
76    // in future, this could be addressed eg. by splitting
77    // boot{lib,test} out into a separate make target,
78    // deleting those tests or moving them to a different
79    // package.
80    patch_module: "java.base",
81
82    errorprone: {
83        javacflags: [
84            "-Xep:AlwaysThrows:OFF",
85            "-Xep:DoNotCall:OFF",
86            "-Xep:ArrayToString:WARN",
87            "-Xep:ReturnValueIgnored:WARN",
88            "-Xep:MathRoundIntLong:WARN",
89            "-Xep:FormatString:WARN",
90            "-Xep:IdentityBinaryExpression:WARN",
91            "-Xep:RandomModInteger:WARN",
92            "-Xep:SelfEquals:WARN",
93            "-Xep:DurationTemporalUnit:WARN",
94            "-Xep:DurationFrom:WARN",
95            "-Xep:InstantTemporalUnit:WARN",
96            "-Xep:SelfComparison:WARN",
97            "-Xep:PeriodFrom:WARN",
98            "-Xep:BoxedPrimitiveEquality:WARN",
99            "-Xep:IdentityHashMapBoxing:WARN",
100            "-Xep:DoubleBraceInitialization:WARN",
101            "-Xep:ComparableType:WARN",
102            "-Xep:ModifyingCollectionWithItself:WARN",
103            "-Xep:InvalidZoneId:WARN",
104            "-Xep:HashtableContains:WARN",
105            "-Xep:EqualsNull:WARN",
106        ],
107    },
108}
109
110// Builds the core-ojtests-public library. Excludes any private API tests.
111// Like core-ojtests but smaller.
112java_test {
113    name: "core-ojtests-public",
114    visibility: [
115        "//art/build/sdk",
116        "//cts/tests/libcore/ojluni",
117    ],
118    defaults: ["libcore_java_defaults"],
119    srcs: [
120        "java/**/*.java",
121        "javax/**/*.java",
122        "sun/**/*.java",
123    ],
124    // Filter out the following:
125    // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
126    //     and won't actually run, and
127    // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
128    //     excluding them means we don't need patch_module: "java.base"
129    exclude_srcs: [
130        "**/DeserializeMethodTest.java",
131        "**/SerializedLambdaTest.java",
132        "java/util/stream/boot*/**/*",
133    ],
134    java_resource_dirs: [
135        "resources",
136        // Include source code as part of JAR
137        "dist",
138    ],
139
140    java_resources: [
141        ":core-ojtests-java-resources",
142        ":core-ojtests-javax-resources",
143    ],
144
145    sdk_version: "none",
146    system_modules: "core-all-system-modules",
147    libs: [
148        "bouncycastle",
149        "core-test-rules",
150        "junit",
151        "okhttp",
152        "testng",
153    ],
154
155    static_libs: ["mockwebserver"],
156
157    errorprone: {
158        javacflags: [
159            "-Xep:AlwaysThrows:OFF",
160            "-Xep:DoNotCall:OFF",
161            "-Xep:ArrayToString:WARN",
162            "-Xep:ReturnValueIgnored:WARN",
163            "-Xep:MathRoundIntLong:WARN",
164            "-Xep:FormatString:WARN",
165            "-Xep:IdentityBinaryExpression:WARN",
166            "-Xep:RandomModInteger:WARN",
167            "-Xep:SelfEquals:WARN",
168            "-Xep:DurationTemporalUnit:WARN",
169            "-Xep:DurationFrom:WARN",
170            "-Xep:InstantTemporalUnit:WARN",
171            "-Xep:SelfComparison:WARN",
172            "-Xep:PeriodFrom:WARN",
173            "-Xep:BoxedPrimitiveEquality:WARN",
174            "-Xep:IdentityHashMapBoxing:WARN",
175            "-Xep:DoubleBraceInitialization:WARN",
176            "-Xep:ComparableType:WARN",
177            "-Xep:ModifyingCollectionWithItself:WARN",
178            "-Xep:InvalidZoneId:WARN",
179            "-Xep:HashtableContains:WARN",
180            "-Xep:EqualsNull:WARN",
181        ],
182    },
183}
184