Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ build --experimental_disk_cache_gc_max_size=2G
build --javacopt=-g
build --host_javacopt=-g

# Disable The Guava Beta Checker.
# Enable The Guava Beta Checker.
# TODO(ronshapiro): explore how much work it would be to reenable this
build --javacopt="-Xep:BetaApi:OFF"
build --host_javacopt="-Xep:BetaApi:OFF"
build --javacopt="-Xep:BetaApi:ERROR"
build --host_javacopt="-Xep:BetaApi:ERROR"

# Sets the JDK for compiling sources.
# TODO(b/394093156): Upgrade to JDK 21.
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ECLIPSE_SISU_VERSION = "0.3.0"

ERROR_PRONE_VERSION = "2.23.0"

GUAVA_VERSION = "33.0.0"
GUAVA_VERSION = "33.6.0"

GRPC_VERSION = "1.2.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ private void addNodesForGraph(dagger.internal.codegen.binding.BindingGraph graph
addChildComponentEdges(graph);
}

@SuppressWarnings(
"BetaApi") // Kythe's bundled Guava still has @Beta on com.google.common.graph APIs.
private void addDependencyEdges(BindingGraph graph) {
for (DependencyEdge dependencyEdge : graph.dependencyEdges()) {
DependencyRequest dependency = dependencyEdge.dependencyRequest();
Expand All @@ -106,6 +108,8 @@ private void addDependencyEdges(BindingGraph graph) {
* points to all of the contributions for the multibound object. It does so by recursively calling
* this method, with each dependency's key as the {@code targetKey}.
*/
@SuppressWarnings(
"BetaApi") // Kythe's bundled Guava still has @Beta on com.google.common.graph APIs.
private void addEdgesForDependencyRequest(
DependencyRequest dependency, BindingNode bindingNode, BindingGraph graph) {
if (!dependency.requestElement().isPresent()) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ autoService = "1.0"
autoValue = "1.9"
lifecycle = "2.5.1"
lint = "30.3.1"
guava = "33.0.0-jre"
guava = "33.6.0-jre"
gradleIncap = "0.2"
grpc = "1.2.0"
jdk = "17"
Expand Down
6 changes: 3 additions & 3 deletions javatests/artifacts/dagger-android/simple/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies {
androidTestAnnotationProcessor 'com.google.dagger:dagger-android-processor:LOCAL-SNAPSHOT'

// To help us catch usages of Guava APIs for Java 8 in the '-jre' variant.
annotationProcessor'com.google.guava:guava:28.1-android'
testAnnotationProcessor'com.google.guava:guava:28.1-android'
androidTestAnnotationProcessor'com.google.guava:guava:28.1-android'
annotationProcessor'com.google.guava:guava:33.6.0-android'
testAnnotationProcessor'com.google.guava:guava:33.6.0-android'
androidTestAnnotationProcessor'com.google.guava:guava:33.6.0-android'
}
238 changes: 112 additions & 126 deletions javatests/artifacts/hilt-android/simple/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import java.io.File

plugins {
id("com.android.application")
id("com.google.dagger.hilt.android")
id("com.android.application")
id("com.google.dagger.hilt.android")
}

data class AgpVersion(
Expand All @@ -27,40 +27,37 @@ data class AgpVersion(
val patch: Int,
val qualifierName: String?,
val qualifierVersion: Int?,
): Comparable<AgpVersion> {
) : Comparable<AgpVersion> {
override fun compareTo(other: AgpVersion): Int {
val versionComparison = compareValuesBy(this, other, { it.major }, { it.minor }, { it.patch })
return if (versionComparison != 0) {
versionComparison
versionComparison
} else {
// If the versions are equal then compare qualifiers:
when {
qualifierName == null && other.qualifierName == null -> 0
qualifierName == null && other.qualifierName != null -> -1
qualifierName != null && other.qualifierName == null -> 1
else -> compareValuesBy(
this, other,
{ it.qualifierName!! },
{ it.qualifierVersion!! },
)
else -> compareValuesBy(this, other, { it.qualifierName!! }, { it.qualifierVersion!! })
}
}
}

companion object {
val VERSION_REGEX = Regex(
"(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)" +
val VERSION_REGEX =
Regex(
"(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)" +
"(?:-(?<qualifierName>[a-zA-Z]+)(?<qualifierVersion>\\d+))?"
)
)

fun parse(versionStr: String): AgpVersion {
return VERSION_REGEX.matchEntire(versionStr)?.let { match ->
AgpVersion(
major = match.groups["major"]!!.value.toInt(),
minor = match.groups["minor"]!!.value.toInt(),
patch = match.groups["patch"]!!.value.toInt(),
qualifierName = match.groups["qualifierName"]?.value,
qualifierVersion = match.groups["qualifierVersion"]?.value?.toInt()
major = match.groups["major"]!!.value.toInt(),
minor = match.groups["minor"]!!.value.toInt(),
patch = match.groups["patch"]!!.value.toInt(),
qualifierName = match.groups["qualifierName"]?.value,
qualifierVersion = match.groups["qualifierVersion"]?.value?.toInt(),
)
} ?: error("Version string has incorrect format: $versionStr")
}
Expand All @@ -71,130 +68,119 @@ data class AgpVersion(
// sets. If the directory name is appended with '-agp-x.x.x' then the directory
// is conditionally added based on the AGP version of the project.
fun getAdditionalTestDirs(variant: String): List<String> {
val testDirs = mutableMapOf(
"androidTest" to mutableListOf<String>(),
"sharedTest" to mutableListOf("src/sharedTest/java"),
"test" to mutableListOf<String>()
val testDirs =
mutableMapOf(
"androidTest" to mutableListOf<String>(),
"sharedTest" to mutableListOf("src/sharedTest/java"),
"test" to mutableListOf<String>(),
)
val suffix = "-agp-"

val agpVersionString = properties["agp_version"] as String
val agpVersion = AgpVersion.parse(agpVersionString)

File("${project.projectDir.absolutePath}/src").listFiles()?.forEach { file ->
if (file.isDirectory) {
val indexOf = file.name.indexOf(suffix)
if (indexOf != -1) {
try {
val dirAgpVersionStr = file.name.substring(indexOf + suffix.length)
val dirAgpVersion = AgpVersion.parse(dirAgpVersionStr)
if (agpVersion >= dirAgpVersion) {
val dirName = file.name.substring(0, indexOf)
testDirs[dirName]?.add("src/${file.name}/java")
}
} catch (e: IllegalArgumentException) {
// Handle cases where the version string is not valid
println("Warning: Could not parse version from directory name: ${file.name}")
}
}
val suffix = "-agp-"

val agpVersionString = properties["agp_version"] as String
val agpVersion = AgpVersion.parse(agpVersionString)

File("${project.projectDir.absolutePath}/src").listFiles()?.forEach { file ->
if (file.isDirectory) {
val indexOf = file.name.indexOf(suffix)
if (indexOf != -1) {
try {
val dirAgpVersionStr = file.name.substring(indexOf + suffix.length)
val dirAgpVersion = AgpVersion.parse(dirAgpVersionStr)
if (agpVersion >= dirAgpVersion) {
val dirName = file.name.substring(0, indexOf)
testDirs[dirName]?.add("src/${file.name}/java")
}
} catch (e: IllegalArgumentException) {
// Handle cases where the version string is not valid
println("Warning: Could not parse version from directory name: ${file.name}")
}
}
}
return (testDirs[variant] ?: emptyList()) + (testDirs["sharedTest"] ?: emptyList())
}
return (testDirs[variant] ?: emptyList()) + (testDirs["sharedTest"] ?: emptyList())
}

android {
compileSdk = 36
buildToolsVersion = "36.0.0"

defaultConfig {
applicationId = "dagger.hilt.android.simple"
minSdk = 16
targetSdk = 36
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "dagger.hilt.android.simple.SimpleEmulatorTestRunner"
}
namespace = "dagger.hilt.android.simple"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
testOptions {
unitTests.isIncludeAndroidResources = true
}
lint {
checkReleaseBuilds = false
}
sourceSets {
named("test").configure {
java.srcDirs(getAdditionalTestDirs("test"))
}
named("androidTest").configure {
java.srcDirs(getAdditionalTestDirs("androidTest"))
}
}
flavorDimensions += "tier"
productFlavors {
create("free") {
dimension = "tier"
}
create("pro") {
dimension = "tier"
matchingFallbacks += "free"
}
compileSdk = 36
buildToolsVersion = "36.0.0"

defaultConfig {
applicationId = "dagger.hilt.android.simple"
minSdk = 16
targetSdk = 36
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "dagger.hilt.android.simple.SimpleEmulatorTestRunner"
}
namespace = "dagger.hilt.android.simple"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
testOptions { unitTests.isIncludeAndroidResources = true }
lint { checkReleaseBuilds = false }
sourceSets {
named("test").configure { java.srcDirs(getAdditionalTestDirs("test")) }
named("androidTest").configure { java.srcDirs(getAdditionalTestDirs("androidTest")) }
}
flavorDimensions += "tier"
productFlavors {
create("free") { dimension = "tier" }
create("pro") {
dimension = "tier"
matchingFallbacks += "free"
}
}
}

hilt {
enableAggregatingTask = true
}
hilt { enableAggregatingTask = true }

val dagger_version: String by project

configurations.all {
resolutionStrategy.eachDependency {
if (dagger_version == "LOCAL-SNAPSHOT" && requested.group == "com.google.dagger") {
useVersion("LOCAL-SNAPSHOT")
because("LOCAL-SNAPSHOT should act as latest version.")
}
resolutionStrategy.eachDependency {
if (dagger_version == "LOCAL-SNAPSHOT" && requested.group == "com.google.dagger") {
useVersion("LOCAL-SNAPSHOT")
because("LOCAL-SNAPSHOT should act as latest version.")
}
}
}

dependencies {
implementation(project(":feature"))
implementation(project(":lib"))
implementation("androidx.appcompat:appcompat:1.2.0")
implementation("com.google.dagger:hilt-android:$dagger_version")
annotationProcessor("com.google.dagger:hilt-compiler:$dagger_version")
compileOnly("com.google.errorprone:error_prone_annotations:2.45.0")

testImplementation("com.google.truth:truth:1.0.1")
testImplementation("junit:junit:4.13")
testImplementation("org.robolectric:robolectric:4.11.1")
testImplementation("androidx.core:core:1.3.2")
testImplementation("androidx.test.ext:junit:1.1.3")
testImplementation("androidx.test:runner:1.4.0")
testImplementation("androidx.test.espresso:espresso-core:3.5.1")
testImplementation("com.google.dagger:hilt-android-testing:$dagger_version")
testAnnotationProcessor("com.google.dagger:hilt-compiler:$dagger_version")

androidTestImplementation("com.google.truth:truth:1.0.1")
androidTestImplementation("junit:junit:4.13")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("com.google.dagger:hilt-android-testing:$dagger_version")
androidTestAnnotationProcessor("com.google.dagger:hilt-compiler:$dagger_version")

// To help us catch usages of Guava APIs for Java 8 in the '-jre' variant.
annotationProcessor("com.google.guava:guava:28.1-android")
testAnnotationProcessor("com.google.guava:guava:28.1-android")
androidTestAnnotationProcessor("com.google.guava:guava:28.1-android")

// To help us catch version skew related issues in hilt extensions.
// TODO(bcorso): Add examples testing the actual API.
implementation("androidx.hilt:hilt-work:1.0.0")
annotationProcessor("androidx.hilt:hilt-compiler:1.0.0")
testAnnotationProcessor("androidx.hilt:hilt-compiler:1.0.0")
androidTestAnnotationProcessor("androidx.hilt:hilt-compiler:1.0.0")
implementation(project(":feature"))
implementation(project(":lib"))
implementation("androidx.appcompat:appcompat:1.2.0")
implementation("com.google.dagger:hilt-android:$dagger_version")
annotationProcessor("com.google.dagger:hilt-compiler:$dagger_version")
compileOnly("com.google.errorprone:error_prone_annotations:2.45.0")

testImplementation("com.google.truth:truth:1.0.1")
testImplementation("junit:junit:4.13")
testImplementation("org.robolectric:robolectric:4.11.1")
testImplementation("androidx.core:core:1.3.2")
testImplementation("androidx.test.ext:junit:1.1.3")
testImplementation("androidx.test:runner:1.4.0")
testImplementation("androidx.test.espresso:espresso-core:3.5.1")
testImplementation("com.google.dagger:hilt-android-testing:$dagger_version")
testAnnotationProcessor("com.google.dagger:hilt-compiler:$dagger_version")

androidTestImplementation("com.google.truth:truth:1.0.1")
androidTestImplementation("junit:junit:4.13")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("com.google.dagger:hilt-android-testing:$dagger_version")
androidTestAnnotationProcessor("com.google.dagger:hilt-compiler:$dagger_version")

// To help us catch usages of Guava APIs for Java 8 in the '-jre' variant.
annotationProcessor("com.google.guava:guava:33.6.0-android")
testAnnotationProcessor("com.google.guava:guava:33.6.0-android")
androidTestAnnotationProcessor("com.google.guava:guava:33.6.0-android")

// To help us catch version skew related issues in hilt extensions.
// TODO(bcorso): Add examples testing the actual API.
implementation("androidx.hilt:hilt-work:1.0.0")
annotationProcessor("androidx.hilt:hilt-compiler:1.0.0")
testAnnotationProcessor("androidx.hilt:hilt-compiler:1.0.0")
androidTestAnnotationProcessor("androidx.hilt:hilt-compiler:1.0.0")
}
Loading
Loading