diff --git a/java/dagger/hilt/android/plugin/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt b/java/dagger/hilt/android/plugin/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt index 1c8f4afea3d..0677bd90d92 100644 --- a/java/dagger/hilt/android/plugin/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt +++ b/java/dagger/hilt/android/plugin/src/main/kotlin/dagger/hilt/android/plugin/HiltGradlePlugin.kt @@ -119,8 +119,8 @@ class HiltGradlePlugin : Plugin { // Java/Kotlin library projects offer an artifact of type 'jar'. spec.from.attribute(ARTIFACT_TYPE_ATTRIBUTE, "jar") // Android library projects (with or without Kotlin) offer an artifact of type - // 'android-classes', which AGP can offer as a jar. - spec.from.attribute(ARTIFACT_TYPE_ATTRIBUTE, "android-classes-jar") + // 'processed-jar', which AGP can offer as a jar. + spec.from.attribute(ARTIFACT_TYPE_ATTRIBUTE, "processed-jar") spec.to.attribute(ARTIFACT_TYPE_ATTRIBUTE, DAGGER_ARTIFACT_TYPE_VALUE) } } diff --git a/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle b/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle index 93442b44d85..ecfaf6e927d 100644 --- a/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle +++ b/javatests/artifacts/hilt-android/simpleKotlin/app/build.gradle @@ -50,6 +50,15 @@ android { lintOptions { checkReleaseBuilds = false } + sourceSets { + String sharedTestDir = 'src/sharedTest/java' + test { + java.srcDirs += sharedTestDir + } + androidTest { + java.srcDirs += sharedTestDir + } + } } hilt { @@ -58,6 +67,8 @@ hilt { } dependencies { + implementation project(':android-library') + implementation project(':kotlin-library') implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.activity:activity-ktx:1.1.0' @@ -65,6 +76,8 @@ dependencies { implementation 'com.google.dagger:hilt-android:LOCAL-SNAPSHOT' kapt 'com.google.dagger:hilt-compiler:LOCAL-SNAPSHOT' + testImplementation 'androidx.test.ext:junit:1.1.2' + testImplementation 'androidx.test:runner:1.3.0' testImplementation 'com.google.truth:truth:1.0.1' testImplementation 'junit:junit:4.13' testImplementation 'org.robolectric:robolectric:4.5-alpha-3' diff --git a/javatests/artifacts/hilt-android/simpleKotlin/app/src/main/java/dagger/hilt/android/simpleKotlin/DefinedStrings.kt b/javatests/artifacts/hilt-android/simpleKotlin/app/src/main/java/dagger/hilt/android/simpleKotlin/DefinedStrings.kt new file mode 100644 index 00000000000..b22e588a76f --- /dev/null +++ b/javatests/artifacts/hilt-android/simpleKotlin/app/src/main/java/dagger/hilt/android/simpleKotlin/DefinedStrings.kt @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2021 The Dagger Authors. + * + * 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 dagger.hilt.android.simpleKotlin + +object DefinedStrings { + internal val morningSweet = "Mallorca" + internal fun getInternalSweet() = "Sugar Donuts" +} diff --git a/javatests/artifacts/hilt-android/simpleKotlin/app/src/sharedTest/java/dagger/hilt/android/simpleKotlin/InternalAccessTest.kt b/javatests/artifacts/hilt-android/simpleKotlin/app/src/sharedTest/java/dagger/hilt/android/simpleKotlin/InternalAccessTest.kt new file mode 100644 index 00000000000..43a1abc5cb4 --- /dev/null +++ b/javatests/artifacts/hilt-android/simpleKotlin/app/src/sharedTest/java/dagger/hilt/android/simpleKotlin/InternalAccessTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 The Dagger Authors. + * + * 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 dagger.hilt.android.simpleKotlin + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.google.common.truth.Truth.assertThat +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Verifies internal Kotlin classes are accessible with classpath aggregation. + */ +@RunWith(AndroidJUnit4::class) +class InternalAccessTest { + @Test + fun verifyInternalMembersAreAccessible() { + assertThat(DefinedStrings.morningSweet).isNotNull() + assertThat(DefinedStrings.getInternalSweet()).isNotNull() + } +}