Divide core components into runtime and common.
Bug: 36069458
Test: existing tests pass
Change-Id: I2fee9af971d540e41eb448ff345c2d57dbd54fb1
diff --git a/.gitignore b/.gitignore
index 9c6e6eb..abfef7c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@
*.iml
**/out
buildSrc/build
-lifecycle/common/build
\ No newline at end of file
+lifecycle/common/build
+jacoco.exec
\ No newline at end of file
diff --git a/app-toolkit/common/build.gradle b/app-toolkit/common/build.gradle
new file mode 100644
index 0000000..2f54c2a
--- /dev/null
+++ b/app-toolkit/common/build.gradle
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+apply plugin: 'java'
+apply plugin: 'maven'
+
+sourceCompatibility = 1.7
+
+dependencies {
+ compile libs.support.annotations
+
+ testCompile libs.junit
+ testCompile libs.mockito_core
+}
+
+archivesBaseName = "common"
+
+createAndroidCheckstyle(project)
diff --git a/app-toolkit/core/src/main/java/android/arch/core/internal/SafeIterableMap.java b/app-toolkit/common/src/main/java/android/arch/core/internal/SafeIterableMap.java
similarity index 100%
rename from app-toolkit/core/src/main/java/android/arch/core/internal/SafeIterableMap.java
rename to app-toolkit/common/src/main/java/android/arch/core/internal/SafeIterableMap.java
diff --git a/app-toolkit/core/src/main/java/android/arch/core/util/Function.java b/app-toolkit/common/src/main/java/android/arch/core/util/Function.java
similarity index 100%
rename from app-toolkit/core/src/main/java/android/arch/core/util/Function.java
rename to app-toolkit/common/src/main/java/android/arch/core/util/Function.java
diff --git a/app-toolkit/core/src/test/java/android/arch/core/internal/SafeIterableMapTest.java b/app-toolkit/common/src/test/java/android/arch/core/internal/SafeIterableMapTest.java
similarity index 98%
rename from app-toolkit/core/src/test/java/android/arch/core/internal/SafeIterableMapTest.java
rename to app-toolkit/common/src/test/java/android/arch/core/internal/SafeIterableMapTest.java
index 91814ac..60a10ab 100644
--- a/app-toolkit/core/src/test/java/android/arch/core/internal/SafeIterableMapTest.java
+++ b/app-toolkit/common/src/test/java/android/arch/core/internal/SafeIterableMapTest.java
@@ -19,9 +19,6 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import android.arch.core.internal.SafeIterableMap;
-import android.support.test.filters.SmallTest;
-
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -31,7 +28,6 @@
import java.util.Map;
@RunWith(JUnit4.class)
-@SmallTest
public class SafeIterableMapTest {
@Test
diff --git a/app-toolkit/core-testing/build.gradle b/app-toolkit/core-testing/build.gradle
index 52ff125..c757533 100644
--- a/app-toolkit/core-testing/build.gradle
+++ b/app-toolkit/core-testing/build.gradle
@@ -41,7 +41,7 @@
}
dependencies {
- compile project(":arch:core")
+ compile project(":arch:runtime")
compile libs.support.annotations
compile libs.support.core_utils
compile(libs.junit) {
diff --git a/app-toolkit/core/build.gradle b/app-toolkit/runtime/build.gradle
similarity index 96%
rename from app-toolkit/core/build.gradle
rename to app-toolkit/runtime/build.gradle
index ceb6628..5e2fe46 100644
--- a/app-toolkit/core/build.gradle
+++ b/app-toolkit/runtime/build.gradle
@@ -48,6 +48,7 @@
dependencies {
compile libs.support.annotations
+ compile project(":arch:common")
testCompile libs.junit
testCompile libs.mockito_core
testCompile(libs.test_runner) {
@@ -55,7 +56,7 @@
}
}
-archivesBaseName = "core"
+archivesBaseName = "runtime"
createAndroidCheckstyle(project)
diff --git a/app-toolkit/core/src/main/AndroidManifest.xml b/app-toolkit/runtime/src/main/AndroidManifest.xml
similarity index 100%
rename from app-toolkit/core/src/main/AndroidManifest.xml
rename to app-toolkit/runtime/src/main/AndroidManifest.xml
diff --git a/app-toolkit/core/src/main/java/android/arch/core/executor/AppToolkitTaskExecutor.java b/app-toolkit/runtime/src/main/java/android/arch/core/executor/AppToolkitTaskExecutor.java
similarity index 78%
rename from app-toolkit/core/src/main/java/android/arch/core/executor/AppToolkitTaskExecutor.java
rename to app-toolkit/runtime/src/main/java/android/arch/core/executor/AppToolkitTaskExecutor.java
index 29d9c1b..7337f74 100644
--- a/app-toolkit/core/src/main/java/android/arch/core/executor/AppToolkitTaskExecutor.java
+++ b/app-toolkit/runtime/src/main/java/android/arch/core/executor/AppToolkitTaskExecutor.java
@@ -20,13 +20,15 @@
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
+import java.util.concurrent.Executor;
+
/**
* A static class that serves as a central point to execute common tasks.
* <p>
*
* @hide This API is not final.
*/
-@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP, RestrictTo.Scope.TESTS})
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class AppToolkitTaskExecutor extends TaskExecutor {
private static volatile AppToolkitTaskExecutor sInstance;
@@ -36,6 +38,22 @@
@NonNull
private TaskExecutor mDefaultTaskExecutor;
+ @NonNull
+ private static final Executor sMainThreadExecutor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ getInstance().postToMainThread(command);
+ }
+ };
+
+ @NonNull
+ private static final Executor sIOThreadExecutor = new Executor() {
+ @Override
+ public void execute(Runnable command) {
+ getInstance().executeOnDiskIO(command);
+ }
+ };
+
private AppToolkitTaskExecutor() {
mDefaultTaskExecutor = new DefaultTaskExecutor();
mDelegate = mDefaultTaskExecutor;
@@ -82,6 +100,16 @@
mDelegate.postToMainThread(runnable);
}
+ @NonNull
+ public static Executor getMainThreadExecutor() {
+ return sMainThreadExecutor;
+ }
+
+ @NonNull
+ public static Executor getIOThreadExecutor() {
+ return sIOThreadExecutor;
+ }
+
@Override
public boolean isMainThread() {
return mDelegate.isMainThread();
diff --git a/app-toolkit/core/src/main/java/android/arch/core/executor/DefaultTaskExecutor.java b/app-toolkit/runtime/src/main/java/android/arch/core/executor/DefaultTaskExecutor.java
similarity index 100%
rename from app-toolkit/core/src/main/java/android/arch/core/executor/DefaultTaskExecutor.java
rename to app-toolkit/runtime/src/main/java/android/arch/core/executor/DefaultTaskExecutor.java
diff --git a/app-toolkit/core/src/main/java/android/arch/core/executor/TaskExecutor.java b/app-toolkit/runtime/src/main/java/android/arch/core/executor/TaskExecutor.java
similarity index 96%
rename from app-toolkit/core/src/main/java/android/arch/core/executor/TaskExecutor.java
rename to app-toolkit/runtime/src/main/java/android/arch/core/executor/TaskExecutor.java
index 1e8124b..055b476 100644
--- a/app-toolkit/core/src/main/java/android/arch/core/executor/TaskExecutor.java
+++ b/app-toolkit/runtime/src/main/java/android/arch/core/executor/TaskExecutor.java
@@ -26,7 +26,7 @@
* TODO: Don't use this from outside, we don't know what the API will look like yet.
* @hide
*/
-@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP, RestrictTo.Scope.TESTS})
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public abstract class TaskExecutor {
/**
* Executes the given task in the disk IO thread pool.
diff --git a/app-toolkit/settings.gradle b/app-toolkit/settings.gradle
index 2a132e0..15ed47c 100644
--- a/app-toolkit/settings.gradle
+++ b/app-toolkit/settings.gradle
@@ -27,8 +27,11 @@
println "support root:${supportRoot}"
-include ':arch:core'
-project(':arch:core').projectDir = new File(supportRoot, "app-toolkit/core")
+include ':arch:runtime'
+project(':arch:runtime').projectDir = new File(supportRoot, "app-toolkit/runtime")
+
+include ':arch:common'
+project(':arch:common').projectDir = new File(supportRoot, "app-toolkit/common")
include ':arch:core-testing'
project(':arch:core-testing').projectDir = new File(supportRoot, "app-toolkit/core-testing")
diff --git a/lifecycle/extensions/build.gradle b/lifecycle/extensions/build.gradle
index 4fe78a0..daef74b 100644
--- a/lifecycle/extensions/build.gradle
+++ b/lifecycle/extensions/build.gradle
@@ -32,7 +32,7 @@
dependencies {
compile project(":lifecycle:common")
compile project(":lifecycle:runtime")
- compile project(":arch:core")
+ compile project(":arch:runtime")
compile libs.support.fragments
testCompile project(":arch:core-testing")
diff --git a/lifecycle/reactivestreams/build.gradle b/lifecycle/reactivestreams/build.gradle
index d438fb9..1d30331 100644
--- a/lifecycle/reactivestreams/build.gradle
+++ b/lifecycle/reactivestreams/build.gradle
@@ -45,7 +45,7 @@
allprojects {
dependencies {
- compile project(":arch:core")
+ compile project(":arch:runtime")
compile project(":lifecycle:common")
compile project(":lifecycle:extensions")
compile project(":lifecycle:runtime")
diff --git a/lifecycle/runtime/build.gradle b/lifecycle/runtime/build.gradle
index f2bf671..c0c2033 100644
--- a/lifecycle/runtime/build.gradle
+++ b/lifecycle/runtime/build.gradle
@@ -31,7 +31,7 @@
dependencies {
compile project(":lifecycle:common")
- compile project(":arch:core")
+ compile project(":arch:runtime")
// necessary for IJ to resolve dependencies.
compile libs.support.annotations
diff --git a/room/integration-tests/testapp/build.gradle b/room/integration-tests/testapp/build.gradle
index a687653..8f0053f 100644
--- a/room/integration-tests/testapp/build.gradle
+++ b/room/integration-tests/testapp/build.gradle
@@ -51,7 +51,7 @@
compile project(":room:db")
compile project(":room:db-impl")
compile project(':room:runtime')
- compile project(':arch:core')
+ compile project(':arch:runtime')
compile libs.support.app_compat
annotationProcessor project(":room:compiler")
diff --git a/room/runtime/build.gradle b/room/runtime/build.gradle
index 1415d85..2bf1baf 100644
--- a/room/runtime/build.gradle
+++ b/room/runtime/build.gradle
@@ -54,7 +54,7 @@
compile project(":room:common")
compile project(":room:db")
compile project(":room:db-impl")
- compile project(":arch:core")
+ compile project(":arch:runtime")
compile libs.support.core_utils
diff --git a/room/rxjava2/build.gradle b/room/rxjava2/build.gradle
index 21df34b..d7b5ceb 100644
--- a/room/rxjava2/build.gradle
+++ b/room/rxjava2/build.gradle
@@ -49,7 +49,7 @@
dependencies {
compile project(":room:common")
compile project(":room:runtime")
- compile project(":arch:core")
+ compile project(":arch:runtime")
compile libs.support.core_utils
compile libs.rx_java
testCompile libs.junit
diff --git a/room/testing/build.gradle b/room/testing/build.gradle
index 065400b..d378d84 100644
--- a/room/testing/build.gradle
+++ b/room/testing/build.gradle
@@ -52,7 +52,7 @@
compile project(":room:db")
compile project(":room:db-impl")
compile project(":room:migration")
- compile project(":arch:core")
+ compile project(":arch:runtime")
compile libs.support.core_utils
compile libs.junit
}