Convert more of tools/tradefederation/core to Android.bp

See build/soong/README.md for more information.

Bug: 122332235
Test: m tradefed-all
Test: m tradefed.sh
Test: m checkbuild
Change-Id: Ic15709d44bec0913cc7211abb35ba5d8ba0955ba
diff --git a/Android.bp b/Android.bp
index 1d55ff1..6fdafd4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -170,3 +170,28 @@
           "-devsite ",
     create_stubs: false,
 }
+
+sh_binary_host {
+    name: "tradefed.sh",
+    src: "tradefed.sh",
+}
+
+sh_binary_host {
+    name: "tradefed_win",
+    src: "tradefed_win.bat",
+}
+
+sh_binary_host {
+    name: "script_help",
+    src: "script_help.sh",
+}
+
+sh_binary_host {
+    name: "run_tf_cmd",
+    src: "run_tf_cmd.sh",
+}
+
+sh_binary_host {
+    name: "atest_tradefed",
+    src: "atest_tradefed.sh",
+}
diff --git a/Android.mk b/Android.mk
index 25647f5..e6bb150 100644
--- a/Android.mk
+++ b/Android.mk
@@ -29,26 +29,16 @@
 $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar : $(HOST_OUT)/tradefed/loganalysis.jar
 
 #######################################################
-include $(CLEAR_VARS)
 
 # Create a simple alias to build all the TF-related targets
 # Note that this is incompatible with `make dist`.  If you want to make
 # the distribution, you must run `tapas` with the individual target names.
 .PHONY: tradefed-core
-tradefed-core: tradefed atest_tradefed tradefed-contrib tf-contrib-tests script_help
+tradefed-core: tradefed atest_tradefed tradefed-contrib tf-contrib-tests script_help tradefed.sh
 
 .PHONY: tradefed-all
 tradefed-all: tradefed-core tradefed-tests tradefed_win loganalysis-tests
 
-# ====================================
-include $(CLEAR_VARS)
-# copy tradefed.sh script to host dir
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_EXECUTABLES := tradefed.sh tradefed_win.bat script_help.sh run_tf_cmd.sh atest_tradefed.sh
-include $(BUILD_HOST_PREBUILT)
-
 ########################################################
 # Zip up the built files and dist it as tradefed.zip
 
diff --git a/atest/Android.bp b/atest/Android.bp
index 35f74cb..4491b63 100644
--- a/atest/Android.bp
+++ b/atest/Android.bp
@@ -66,6 +66,9 @@
     // Make atest's built name to atest-dev
     stem: "atest-dev",
     defaults: ["atest_py2_default"],
+    dist: {
+        targets: ["droidcore"],
+    },
 }
 
 python_library_host {
diff --git a/atest/Android.mk b/atest/Android.mk
deleted file mode 100644
index 634c50a..0000000
--- a/atest/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Copyright 2018 - The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-$(call dist-for-goals,droidcore,$(HOST_OUT_EXECUTABLES)/atest-dev)
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 0000000..5dab015
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,41 @@
+// Copyright (C) 2010 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+tradefed_java_library_host {
+    name: "tradefed-tests",
+    defaults: ["tradefed_errorprone_defaults"],
+
+    // Only compile source java files in this lib.
+    srcs: ["src/**/*.java"],
+
+    java_resource_dirs: ["res"],
+
+    javacflags: [
+        "-g",
+        "-Xlint",
+    ],
+
+    static_libs: [
+        "easymock",
+        "objenesis",
+        "mockito",
+        "truth-prebuilt",
+    ],
+    libs: [
+        "tradefed",
+        "libprotobuf-java-full",
+    ],
+
+    manifest: "MANIFEST.mf",
+}
diff --git a/tests/Android.mk b/tests/Android.mk
index 0bbc5a1..8da9979 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -12,36 +12,13 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# Only compile source java files in this lib.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAVA_RESOURCE_DIRS := res
-
-LOCAL_JAVACFLAGS += -g -Xlint
--include tools/tradefederation/core/error_prone_rules.mk
-
-LOCAL_MODULE := tradefed-tests
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_JAVA_LIBRARIES := easymock objenesis-host mockito-host truth-prebuilt
-LOCAL_JAVA_LIBRARIES := tradefed host-libprotobuf-java-full
-
-LOCAL_JAR_MANIFEST := MANIFEST.mf
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
 # makefile rules to copy jars to HOST_OUT/tradefed
 # so tradefed.sh can automatically add to classpath
 
-DEST_JAR := $(HOST_OUT)/tradefed/$(LOCAL_MODULE).jar
-$(DEST_JAR): $(LOCAL_BUILT_MODULE)
+DEST_JAR := $(HOST_OUT)/tradefed/tradefed-tests.jar
+BUILT_JAR := $(call intermediates-dir-for,JAVA_LIBRARIES,tradefed-tests,HOST)/javalib.jar
+$(DEST_JAR): $(BUILT_JAR)
 	$(copy-file-to-new-target)
 
 # this dependency ensure the above rule will be executed if module is built
-$(LOCAL_INSTALLED_MODULE) : $(DEST_JAR)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
+$(HOST_OUT_JAVA_LIBRARIES)/tradefed-tests.jar : $(DEST_JAR)