Initial commit for the View Model Hilt Extension

This CL adds 3 skeleton projects:
* lifecycle-hilt - Android lib containing the runtime classes of the
extension.
* lifecycle-hilt-common - Java lib for the common annotation between
compiler and runtime.
* lifecycle-hilt-compiler - The annotation processor that will generate
Hilt modules for each ViewModel that is constructor injected.

Test: n/a
Change-Id: Id8fb667defe9753fabe12531b03eb699708f9e80
diff --git a/build.gradle b/build.gradle
index 8df231c..2ba5b07 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,6 +16,7 @@
 
 import androidx.build.AndroidXPlugin
 import androidx.build.SdkHelperKt
+import static androidx.build.dependencies.DependenciesKt.*
 
 buildscript {
     ext.supportRootFolder = project.projectDir
@@ -28,6 +29,7 @@
         classpath build_libs.agp
         classpath build_libs.kotlin.gradle_plugin
         classpath build_libs.dokka_gradle
+        classpath HILT_ANDROID_GRADLE_PLUGIN
     }
 }
 
diff --git a/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt b/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
index 5ab2e8f..0657025 100644
--- a/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/PublishDocsRules.kt
@@ -84,6 +84,9 @@
     ignore(LibraryGroups.LIFECYCLE.group, "lifecycle-runtime-ktx-lint")
     prebuilts(LibraryGroups.LIFECYCLE, "lifecycle-extensions", "2.2.0") // No longer published
     ignore(LibraryGroups.LIFECYCLE.group, "lifecycle-runtime-testing")
+    ignore(LibraryGroups.LIFECYCLE.group, "lifecycle-viewmodel-hilt") // Not yet published
+    ignore(LibraryGroups.LIFECYCLE.group, "lifecycle-viewmodel-hilt-common") // Not yet published
+    ignore(LibraryGroups.LIFECYCLE.group, "lifecycle-viewmodel-hilt-compiler") // Not yet published
     prebuilts(LibraryGroups.LIFECYCLE, "2.3.0-alpha01")
     ignore(LibraryGroups.LOADER.group, "loader-ktx")
     prebuilts(LibraryGroups.LOADER, "1.1.0")
diff --git a/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt b/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
index a067d51..bdc1b63 100644
--- a/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/dependencies/Dependencies.kt
@@ -35,6 +35,8 @@
 const val CHECKER_FRAMEWORK = "org.checkerframework:checker-qual:2.5.3"
 const val CONSTRAINT_LAYOUT = "androidx.constraintlayout:constraintlayout:1.1.0@aar"
 const val CONSTRAINT_LAYOUT_SOLVER = "androidx.constraintlayout:constraintlayout-solver:2.0.0-beta4"
+const val DAGGER = "com.google.dagger:dagger:2.27"
+const val DAGGER_COMPILER = "com.google.dagger:dagger-compiler:2.27"
 const val DEXMAKER_MOCKITO = "com.linkedin.dexmaker:dexmaker-mockito:2.25.0"
 const val ESPRESSO_CONTRIB = "androidx.test.espresso:espresso-contrib:3.1.0"
 const val ESPRESSO_CORE = "androidx.test.espresso:espresso-core:3.1.0"
@@ -52,6 +54,9 @@
 const val GUAVA_LISTENABLE_FUTURE = "com.google.guava:listenablefuture:1.0"
 const val GRADLE_INCAP_HELPER = "net.ltgt.gradle.incap:incap:0.2"
 const val GRADLE_INCAP_HELPER_PROCESSOR = "net.ltgt.gradle.incap:incap-processor:0.2"
+const val HILT_ANDROID = "com.google.dagger:hilt-android:DEV-SNAPSHOT"
+const val HILT_ANDROID_COMPILER = "com.google.dagger:hilt-android-compiler:DEV-SNAPSHOT"
+const val HILT_ANDROID_GRADLE_PLUGIN = "com.google.dagger:hilt-android-gradle-plugin:DEV-SNAPSHOT"
 const val INTELLIJ_ANNOTATIONS = "com.intellij:annotations:12.0"
 const val JAVAPOET = "com.squareup:javapoet:1.8.0"
 const val JSR250 = "javax.annotation:javax.annotation-api:1.2"
diff --git a/lifecycle/lifecycle-viewmodel-hilt-common/build.gradle b/lifecycle/lifecycle-viewmodel-hilt-common/build.gradle
new file mode 100644
index 0000000..a56c8c8
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt-common/build.gradle
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2020 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.
+ */
+
+import androidx.build.LibraryGroups
+import androidx.build.LibraryVersions
+import androidx.build.AndroidXExtension
+
+import static androidx.build.dependencies.DependenciesKt.*
+import androidx.build.Publish
+
+plugins {
+    id("AndroidXPlugin")
+    id("java-library")
+}
+
+dependencies {
+    implementation(HILT_ANDROID)
+}
+
+androidx {
+    name = "Android Lifecycle ViewModel Hilt Extension Annotations"
+    publish = Publish.NONE
+    mavenVersion = LibraryVersions.LIFECYCLE
+    mavenGroup = LibraryGroups.LIFECYCLE
+    inceptionYear = "2020"
+    description = "Android Lifecycle ViewModel Hilt Extension Annotations"
+    url = AndroidXExtension.ARCHITECTURE_URL
+}
\ No newline at end of file
diff --git a/lifecycle/lifecycle-viewmodel-hilt-common/src/main/java/androidx/lifecycle/hilt/ViewModelInject.java b/lifecycle/lifecycle-viewmodel-hilt-common/src/main/java/androidx/lifecycle/hilt/ViewModelInject.java
new file mode 100644
index 0000000..db9559c
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt-common/src/main/java/androidx/lifecycle/hilt/ViewModelInject.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2020 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.
+ */
+
+package androidx.lifecycle.hilt;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import dagger.hilt.GeneratesRootInput;
+
+/**
+ * Identifies a {@link androidx.lifecycle.ViewModel}'s constructor for injection.
+ */
+@Target(ElementType.CONSTRUCTOR)
+@Retention(RetentionPolicy.CLASS)
+@GeneratesRootInput
+public @interface ViewModelInject {
+}
diff --git a/lifecycle/lifecycle-viewmodel-hilt-compiler/build.gradle b/lifecycle/lifecycle-viewmodel-hilt-compiler/build.gradle
new file mode 100644
index 0000000..af2d212
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt-compiler/build.gradle
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2020 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.
+ */
+
+
+import androidx.build.CompilationTarget
+import androidx.build.LibraryGroups
+import androidx.build.LibraryVersions
+import androidx.build.AndroidXExtension
+
+import static androidx.build.dependencies.DependenciesKt.*
+import androidx.build.Publish
+
+plugins {
+    id("AndroidXPlugin")
+    id("kotlin")
+    id("kotlin-kapt")
+}
+
+dependencies {
+    implementation(project(":lifecycle:lifecycle-viewmodel-hilt-common"))
+
+    implementation(KOTLIN_STDLIB)
+    compileOnly(AUTO_SERVICE_ANNOTATIONS)
+    kapt(AUTO_SERVICE_PROCESSOR)
+    compileOnly(GRADLE_INCAP_HELPER)
+    kapt(GRADLE_INCAP_HELPER_PROCESSOR)
+    implementation(AUTO_COMMON)
+    implementation(JAVAPOET)
+
+    testImplementation(GOOGLE_COMPILE_TESTING)
+}
+
+androidx {
+    name = "Android Lifecycle ViewModel Hilt Extension Compiler"
+    publish = Publish.NONE
+    mavenVersion = LibraryVersions.LIFECYCLE
+    mavenGroup = LibraryGroups.LIFECYCLE
+    inceptionYear = "2020"
+    description = "Android Lifecycle ViewModel Hilt Extension Compiler"
+    url = AndroidXExtension.ARCHITECTURE_URL
+    compilationTarget = CompilationTarget.HOST
+}
\ No newline at end of file
diff --git a/lifecycle/lifecycle-viewmodel-hilt-compiler/src/main/kotlin/androidx/lifecycle/hilt/ClassNames.kt b/lifecycle/lifecycle-viewmodel-hilt-compiler/src/main/kotlin/androidx/lifecycle/hilt/ClassNames.kt
new file mode 100644
index 0000000..a99f10a
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt-compiler/src/main/kotlin/androidx/lifecycle/hilt/ClassNames.kt
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2020 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.
+ */
+
+package androidx.lifecycle.hilt
+
+import com.squareup.javapoet.ClassName
+
+object ClassNames {
+    val ACTIVITY_COMPONENT = ClassName.get("dagger.hilt.android.component", "ActivityComponent")
+    val BINDS = ClassName.get("dagger", "Binds")
+    val INJECT = ClassName.get("javax.inject", "Inject")
+    val INSTALL_IN = ClassName.get("dagger.hilt", "InstallIn")
+    val INTO_MAP = ClassName.get("dagger.multibindings", "IntoMap")
+    val MODULE = ClassName.get("dagger", "Module")
+    val PROVIDER = ClassName.get("javax.inject", "Provider")
+    val VIEW_MODEL_KEY = ClassName.get("androidx.lifecycle.hilt", "ViewModelKey")
+}
diff --git a/lifecycle/lifecycle-viewmodel-hilt-compiler/src/main/kotlin/androidx/lifecycle/hilt/HiltViewModelProcessor.kt b/lifecycle/lifecycle-viewmodel-hilt-compiler/src/main/kotlin/androidx/lifecycle/hilt/HiltViewModelProcessor.kt
new file mode 100644
index 0000000..785586e
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt-compiler/src/main/kotlin/androidx/lifecycle/hilt/HiltViewModelProcessor.kt
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2020 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.
+ */
+
+package androidx.lifecycle.hilt
+
+import com.google.auto.common.BasicAnnotationProcessor
+import com.google.auto.service.AutoService
+import com.google.common.collect.SetMultimap
+import net.ltgt.gradle.incap.IncrementalAnnotationProcessor
+import net.ltgt.gradle.incap.IncrementalAnnotationProcessorType.ISOLATING
+import javax.annotation.processing.Processor
+import javax.lang.model.element.Element
+
+/**
+ * Should generate:
+ * ```
+ * @Module
+ * @InstallIn(ActivityComponent.class)
+ * public abstract class $_HiltModule {
+ *   @Binds
+ *   @IntoMap
+ *   @ViewModelKey($.class)
+ *   public bind($_AssistedFactory f): ViewModelAssistedFactory<?>
+ * }
+ * ```
+ * and
+ * ```
+ * class $_AssistedFactory extends ViewModelAssistedFactory<$> {
+ *
+ *   private final Provider<Dep1> dep1;
+ *   private final Provider<Dep2> dep2;
+ *   ...
+ *
+ *   @Inject
+ *   $_AssistedFactory(Provider<Dep1> dep1, Provider<Dep2> dep2, ...) {
+ *     this.dep1 = dep1;
+ *     this.dep2 = dep2;
+ *     ...
+ *   }
+ *
+ *   @Overrides
+ *   @NonNull
+ *   public $ create(@NonNull SavedStateHandle handle) {
+ *     return new $(dep1.get(), dep2.get(), ..., handle);
+ *   }
+ * }
+ * ```
+ */
+@AutoService(Processor::class)
+@IncrementalAnnotationProcessor(ISOLATING)
+class HiltViewModelProcessor : BasicAnnotationProcessor() {
+    override fun initSteps() = listOf(ViewModelInjectStep())
+
+    class ViewModelInjectStep : ProcessingStep {
+
+        override fun annotations() = setOf(ViewModelInject::class.java)
+
+        override fun process(
+            elementsByAnnotation: SetMultimap<Class<out Annotation>, Element>
+        ): MutableSet<out Element> {
+            // TODO(danysantiago): Implement this...
+            return mutableSetOf()
+        }
+    }
+}
\ No newline at end of file
diff --git a/lifecycle/lifecycle-viewmodel-hilt/build.gradle b/lifecycle/lifecycle-viewmodel-hilt/build.gradle
new file mode 100644
index 0000000..7e0adfd
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt/build.gradle
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2020 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.
+ */
+
+import androidx.build.LibraryGroups
+import androidx.build.LibraryVersions
+import androidx.build.AndroidXExtension
+
+import static androidx.build.dependencies.DependenciesKt.*
+import androidx.build.Publish
+
+plugins {
+    id("AndroidXPlugin")
+    id("com.android.library")
+}
+
+dependencies {
+    api("androidx.annotation:annotation:1.1.0")
+    api(project(":lifecycle:lifecycle-viewmodel-hilt-common"))
+    api(project(":lifecycle:lifecycle-viewmodel-savedstate"))
+    implementation(project(":activity:activity"))
+    implementation(DAGGER)
+    annotationProcessor(DAGGER_COMPILER)
+    implementation(HILT_ANDROID)
+    annotationProcessor(HILT_ANDROID_COMPILER)
+}
+
+androidx {
+    name = "Android Lifecycle ViewModel Hilt Extension"
+    publish = Publish.NONE
+    mavenVersion = LibraryVersions.LIFECYCLE
+    mavenGroup = LibraryGroups.LIFECYCLE
+    inceptionYear = "2020"
+    description = "Android Lifecycle ViewModel Hilt Extension"
+    url = AndroidXExtension.ARCHITECTURE_URL
+}
\ No newline at end of file
diff --git a/lifecycle/lifecycle-viewmodel-hilt/src/main/AndroidManifest.xml b/lifecycle/lifecycle-viewmodel-hilt/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..572f7d0
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt/src/main/AndroidManifest.xml
@@ -0,0 +1,19 @@
+<!--
+  Copyright 2020 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.
+  -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="androidx.lifecycle.hilt">
+</manifest>
diff --git a/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelAssistedFactory.java b/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelAssistedFactory.java
new file mode 100644
index 0000000..cf23fa6
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelAssistedFactory.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2020 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.
+ */
+
+package androidx.lifecycle.hilt;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.RestrictTo;
+import androidx.lifecycle.SavedStateHandle;
+import androidx.lifecycle.ViewModel;
+
+/**
+ * Factory interface to be implemented by generated code.
+ *
+ * @param <T> The ViewModel type.
+ * @hide
+ */
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
+public interface ViewModelAssistedFactory<T extends ViewModel> {
+    /**
+     * Create the ViewModel.
+     *
+     * @param handle the saved state handle.
+     * @return the created ViewModel.
+     */
+    @NonNull T create(@NonNull SavedStateHandle handle);
+}
diff --git a/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelFactory.java b/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelFactory.java
new file mode 100644
index 0000000..49f1318
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelFactory.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2020 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.
+ */
+
+package androidx.lifecycle.hilt;
+
+import android.os.Bundle;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.lifecycle.AbstractSavedStateViewModelFactory;
+import androidx.lifecycle.SavedStateHandle;
+import androidx.lifecycle.ViewModel;
+import androidx.savedstate.SavedStateRegistryOwner;
+
+import java.util.Map;
+
+/**
+ * View Model Provider Factory for the Hilt Extension.
+ */
+public final class ViewModelFactory extends AbstractSavedStateViewModelFactory {
+
+    private final Map<Class<? extends ViewModel>, ViewModelAssistedFactory<?>> mViewModelFactories;
+
+    ViewModelFactory(
+            @NonNull SavedStateRegistryOwner owner,
+            @Nullable Bundle defaultArgs,
+            @NonNull Map<Class<? extends ViewModel>,
+                    ViewModelAssistedFactory<?>> viewModelFactories) {
+        super(owner, defaultArgs);
+        this.mViewModelFactories = viewModelFactories;
+    }
+
+    @NonNull
+    @Override
+    @SuppressWarnings("unchecked")
+    protected <T extends ViewModel> T create(@NonNull String key, @NonNull Class<T> modelClass,
+            @NonNull SavedStateHandle handle) {
+        // TODO(danysantiago): What to do with 'key' ???
+        // TODO(danysantiago): Better exception for missing class
+        return (T) mViewModelFactories.get(modelClass).create(handle);
+    }
+}
diff --git a/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelKey.java b/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelKey.java
new file mode 100644
index 0000000..09207ab
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelKey.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2020 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.
+ */
+
+package androidx.lifecycle.hilt;
+
+import androidx.annotation.RestrictTo;
+import androidx.lifecycle.ViewModel;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import dagger.MapKey;
+
+/**
+ * Dagger multibinding key for View Models
+ *
+ * @hide
+ */
+@MapKey
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.CLASS)
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
+public @interface ViewModelKey {
+    /**
+     * The ViewModel class used as key.
+     * @return the class.
+     */
+    Class<? extends ViewModel> value();
+}
diff --git a/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelModule.java b/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelModule.java
new file mode 100644
index 0000000..c14787d
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-hilt/src/main/java/androidx/lifecycle/hilt/ViewModelModule.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2020 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.
+ */
+
+package androidx.lifecycle.hilt;
+
+import android.app.Activity;
+
+import androidx.activity.ComponentActivity;
+import androidx.annotation.NonNull;
+import androidx.annotation.RestrictTo;
+import androidx.lifecycle.ViewModel;
+
+import java.util.Map;
+
+import dagger.Module;
+import dagger.Provides;
+import dagger.hilt.InstallIn;
+import dagger.hilt.android.components.ActivityComponent;
+import dagger.multibindings.Multibinds;
+
+/**
+ * Hilt Module for the View Model Provider Factory
+ *
+ * @hide
+ */
+@Module
+@InstallIn(ActivityComponent.class)
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
+abstract class ViewModelModule {
+
+    @Multibinds
+    abstract Map<Class<? extends ViewModel>, ViewModelAssistedFactory<?>> viewModelFactoriesMap();
+
+    @Provides
+    @NonNull
+    static ViewModelFactory provideFactory(
+            @NonNull Activity activity,
+            @NonNull Map<Class<? extends ViewModel>,
+                    ViewModelAssistedFactory<?>> viewModelFactories) {
+        // TODO(danysantiago): Validate activity instanceof ComponentActivity
+        return new ViewModelFactory(
+                (ComponentActivity) activity,
+                activity.getIntent().getExtras(),
+                viewModelFactories);
+    }
+}
diff --git a/settings.gradle b/settings.gradle
index a2d09c8..15654f3 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -167,6 +167,9 @@
 includeProject(":lifecycle:lifecycle-runtime-testing", "lifecycle/lifecycle-runtime-testing")
 includeProject(":lifecycle:lifecycle-service", "lifecycle/lifecycle-service")
 includeProject(":lifecycle:lifecycle-viewmodel", "lifecycle/lifecycle-viewmodel")
+includeProject(":lifecycle:lifecycle-viewmodel-hilt", "lifecycle/lifecycle-viewmodel-hilt")
+includeProject(":lifecycle:lifecycle-viewmodel-hilt-common", "lifecycle/lifecycle-viewmodel-hilt-common")
+includeProject(":lifecycle:lifecycle-viewmodel-hilt-compiler", "lifecycle/lifecycle-viewmodel-hilt-compiler")
 includeProject(":lifecycle:lifecycle-viewmodel-ktx", "lifecycle/lifecycle-viewmodel-ktx")
 includeProject(":lifecycle:lifecycle-viewmodel-savedstate","lifecycle/lifecycle-viewmodel-savedstate")
 includeProject(":lint-demos:lint-demo-appcompat", "lint-demos/lint-demo-appcompat")