xref: /aosp_15_r20/external/guice/Android.bp (revision dc5640d1ceac12a29404866b9a53df952a7a6c47)
1// Copyright (C) 2016 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
16//
17// Build support for guice within the Android Open Source Project
18// See https://source.android.com/source/building.html for more information
19//
20
21//##################################
22//           Guice                 #
23//##################################
24
25//
26// Builds the 'no_aop' flavor for Android.
27// -- see core/pom.xml NO_AOP rule.
28//
29
30package {
31    default_applicable_licenses: ["external_guice_license"],
32}
33
34// Added automatically by a large-scale-change
35//
36// large-scale-change included anything that looked like it might be a license
37// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
38//
39// Please consider removing redundant or irrelevant files from 'license_text:'.
40// See: http://go/android-license-faq
41license {
42    name: "external_guice_license",
43    visibility: [":__subpackages__"],
44    license_kinds: [
45        "SPDX-license-identifier-Apache-2.0",
46    ],
47    license_text: [
48        "COPYING",
49        "NOTICE",
50    ],
51}
52
53filegroup {
54    name: "guice_srcs",
55    srcs: ["core/src/**/*.java"],
56    exclude_srcs: [
57        "core/src/com/google/inject/spi/InterceptorBinding.java",
58        "core/src/com/google/inject/internal/InterceptorBindingProcessor.java",
59        "core/src/com/google/inject/internal/InterceptorStackCallback.java",
60        "core/src/com/google/inject/internal/InterceptorStackCallback.java",
61        "core/src/com/google/inject/internal/util/LineNumbers.java",
62        "core/src/com/google/inject/internal/MethodAspect.java",
63        "core/src/com/google/inject/internal/ProxyFactory.java",
64    ],
65}
66
67filegroup {
68    name: "guice_test_src_files",
69    srcs: ["core/test/**/*.java"],
70    exclude_srcs: [
71        "core/test/com/googlecode/guice/BytecodeGenTest.java",
72        "core/test/com/google/inject/IntegrationTest.java",
73        "core/test/com/google/inject/MethodInterceptionTest.java",
74        "core/test/com/google/inject/internal/ProxyFactoryTest.java",
75    ],
76}
77
78// Copy munge.jar to a srcjar.
79// Remove MungeTask.java, which is missing ant dependencies in Android.
80genrule {
81    name: "guice_munge_srcjar",
82    out: ["guice_munge.srcjar"],
83    srcs: ["lib/build/munge.jar"],
84    cmd: "zip -q --temp-path $${TMPDIR:-/tmp} $(in) -O $(out) -d MungeTask.java *.class",
85}
86
87genrule {
88    name: "guice_munge_manifest",
89    out: ["guice_munge.manifest"],
90    srcs: ["lib/build/munge.jar"],
91    cmd: "unzip -p -q $(in) META-INF/MANIFEST.MF > $(out)",
92}
93
94java_binary_host {
95    name: "guice_munge",
96    srcs: [":guice_munge_srcjar"],
97    manifest: ":guice_munge_manifest",
98    libs: ["junit"],
99}
100
101genrule {
102    name: "guice_munged_srcs",
103    srcs: [":guice_srcs"],
104    out: ["guice_munged_srcs.srcjar"],
105    tools: [
106        "guice_munge",
107        "soong_zip",
108    ],
109    cmd: "for src in $(in); do " +
110        "  mkdir -p $$(dirname $(genDir)/$${src}) && " +
111        "  $(location guice_munge) -DNO_AOP $${src} $(genDir)/$${src} || exit 1; " +
112        " done && " +
113        " $(location soong_zip) -o $(out) -C $(genDir) -D $(genDir)",
114}
115
116// Target-side Dalvik, host-side, and host-side Dalvik build
117
118java_library_static {
119    name: "guice",
120    visibility: [
121        "//external/testng:__pkg__",
122        "//platform_testing/libraries/audio-test-harness/server:__pkg__",
123        "//tools/tradefederation/core:__pkg__",
124        "//vendor:__subpackages__",
125    ],
126    host_supported: true,
127    hostdex: true,
128    sdk_version: "core_current",
129    srcs: [":guice_munged_srcs"],
130    static_libs: [
131        "guava",
132        "jsr330",
133    ],
134}
135
136// Variation that doesn't link guava statically
137java_library_static {
138    name: "guice-no-guava",
139    visibility: [
140        "//device/google/cuttlefish/tests/integration:__pkg__",
141        "//external/testng:__pkg__",
142        "//platform_testing/libraries/audio-test-harness/server:__pkg__",
143        "//tools/tradefederation/core:__pkg__",
144    ],
145    host_supported: true,
146    hostdex: true,
147    sdk_version: "core_current",
148    srcs: [":guice_munged_srcs"],
149    libs: [
150        "guava",
151    ],
152    static_libs: [
153        "jsr330",
154    ],
155}
156
157// TODO: Consider adding tests.
158