1# Copyright (C) 2013 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
17LOCAL_PATH := $(call my-dir)
18
19###################################################################
20# Host build
21###################################################################
22
23include $(CLEAR_VARS)
24
25LOCAL_SRC_FILES := \
26    $(call all-java-files-under, src) \
27    $(call all-java-files-under, cglib-and-asm/src)
28
29LOCAL_JAVA_LIBRARIES := junit objenesis-host ant
30LOCAL_MODULE := mockito-host
31LOCAL_MODULE_TAGS := optional
32LOCAL_JAVA_LANGUAGE_VERSION := 1.7
33include $(BUILD_HOST_JAVA_LIBRARY)
34
35
36###################################################################
37# Target build
38###################################################################
39
40# Builds the Mockito source code, but does not include any run-time
41# dependencies. Most projects should use mockito-target instead, which includes
42# everything needed to run Mockito tests.
43include $(CLEAR_VARS)
44
45# Exclude source used to dynamically create classes since target builds use 
46# dexmaker instead and including it causes conflicts.
47explicit_target_excludes := \
48    src/org/mockito/internal/creation/AbstractMockitoMethodProxy.java \
49    src/org/mockito/internal/creation/AcrossJVMSerializationFeature.java \
50    src/org/mockito/internal/creation/CglibMockMaker.java \
51    src/org/mockito/internal/creation/DelegatingMockitoMethodProxy.java \
52    src/org/mockito/internal/creation/MethodInterceptorFilter.java \
53    src/org/mockito/internal/creation/MockitoMethodProxy.java \
54    src/org/mockito/internal/creation/SerializableMockitoMethodProxy.java \
55    src/org/mockito/internal/invocation/realmethod/FilteredCGLIBProxyRealMethod.java \
56    src/org/mockito/internal/invocation/realmethod/CGLIBProxyRealMethod.java \
57    src/org/mockito/internal/invocation/realmethod/HasCGLIBMethodProxy.java
58
59target_src_files := \
60    $(call all-java-files-under, src)
61target_src_files := \
62    $(filter-out src/org/mockito/internal/creation/cglib/%, $(target_src_files))
63target_src_files := \
64    $(filter-out src/org/mockito/internal/creation/jmock/%, $(target_src_files))
65target_src_files := \
66    $(filter-out $(explicit_target_excludes), $(target_src_files))
67
68LOCAL_SRC_FILES := $(target_src_files)
69LOCAL_JAVA_LIBRARIES := junit4-target objenesis-target
70LOCAL_MODULE := mockito-api
71LOCAL_SDK_VERSION := 10
72LOCAL_MODULE_TAGS := optional
73include $(BUILD_STATIC_JAVA_LIBRARY)
74
75# Main target for dependent projects. Bundles all the run-time dependencies
76# needed to run Mockito tests on the device.
77include $(CLEAR_VARS)
78
79LOCAL_MODULE := mockito-target
80LOCAL_STATIC_JAVA_LIBRARIES := mockito-target-minus-junit4 junit4-target
81LOCAL_SDK_VERSION := 10
82LOCAL_MODULE_TAGS := optional
83include $(BUILD_STATIC_JAVA_LIBRARY)
84
85# A mockito target that doesn't pull in junit4-target. This is used to work around
86# issues caused by multiple copies of junit4 in the classpath, usually when a test
87# using mockito is run using android.test.runner.
88include $(CLEAR_VARS)
89LOCAL_MODULE := mockito-target-minus-junit4
90LOCAL_STATIC_JAVA_LIBRARIES := mockito-api dexmaker dexmaker-mockmaker objenesis-target
91LOCAL_JAVA_LIBRARIES := junit4-target
92LOCAL_SDK_VERSION := 10
93LOCAL_MODULE_TAGS := optional
94include $(BUILD_STATIC_JAVA_LIBRARY)
95
96
97###################################################################
98# Host build
99###################################################################
100
101# Builds the Mockito source code, but does not include any run-time
102# dependencies. Since host modules are not compiled against the SDK,
103# an explicit inclusion of core-junit-hostdex is needed in contrast
104# with the target module above.
105ifeq ($(HOST_OS),linux)
106include $(CLEAR_VARS)
107LOCAL_SRC_FILES := $(target_src_files)
108LOCAL_JAVA_LIBRARIES := core-junit-hostdex junit4-target-hostdex \
109    objenesis-hostdex
110LOCAL_MODULE := mockito-api-hostdex
111LOCAL_MODULE_TAGS := optional
112include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
113endif # HOST_OS == linux
114
115
116###################################################
117# Clean up temp vars
118###################################################
119explicit_target_excludes :=
120target_src_files :=
121