diff --git a/annotation/compiler/test/build.gradle b/annotation/compiler/test/build.gradle deleted file mode 100644 index 421f2c5796..0000000000 --- a/annotation/compiler/test/build.gradle +++ /dev/null @@ -1,97 +0,0 @@ -apply plugin: 'com.android.library' - -android { - sourceSets { - test { - resources { - // *.java is excluded by default... - setExcludes([]) - } - // TODO: Re-enable these tests after fixing import orders. - java { - exclude "**/AppGlideModuleWithExcludesTest.java" - exclude "**/AppGlideModuleWithLibraryInPackageTest.java" - exclude "**/AppGlideModuleWithMultipleExcludesTest.java" - exclude "**/EmptyAppAndLibraryGlideModulesTest.java" - exclude "**/GlideExtensionWithOptionTest.java" - exclude "**/GlideExtensionWithTypeTest.java" - exclude "**/GlideExtensionWithTypeTest.java" - } - } - } -} - -afterEvaluate { - lint.enabled = false - compileReleaseJavaWithJavac.enabled = false -} - -android { - namespace 'com.bumptech.glide.annotation.compiler.test' - compileSdk libs.versions.compile.sdk.version.get() - - defaultConfig { - minSdk libs.versions.min.sdk.version.get() as int - targetSdk libs.versions.target.sdk.version.get() as int - versionName VERSION_NAME as String - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - testOptions { - unitTests { - all { Test testTask -> - testTask.maxParallelForks = 2 - } - } - } -} - -// This special test only submodule exists because adding the :glide dependency seems to break -// the annotation processor dependency chain for the internal sample apps. It's also somewhat -// easier to parse as a separate module given the existing complexity here and in the compiler -// build.gradle file. -dependencies { - testImplementation project(':glide') - testImplementation project(':annotation:compiler') - testImplementation libs.junit - testImplementation libs.javapoet - testImplementation libs.findbugs.jsr305 - // Using 0.10 of compile-testing is required for Android Studio to function, but not for the - // gradle build. Not yet clear why, but it looks like some kind of version conflict between - // javapoet, guava and/or truth. - //noinspection GradleDependency - testImplementation ("com.google.testing.compile:compile-testing:0.10") { - // We don't use this and including it requires us to list it separatel which would be - // confusing. - exclude group: "com.google.auto.value", module: "auto-value" - } - testImplementation libs.androidx.annotation - testImplementation libs.androidx.fragment - // TODO: Find some way to include a similar dependency on java 9+ and re-enable these tests in gradle. -// testImplementation files(Jvm.current().getJre().homeDir.getAbsolutePath()+'/lib/rt.jar') - - testAnnotationProcessor project(':annotation:compiler') - testAnnotationProcessor libs.autoservice -} - -task regenerateTestResources { - group 'Verification' - description 'Regenerates all test resource files under annotation/compiler/test/src/test/resources that are compared against the current output to detect regressions' - tasks.withType(Test) { - systemProperties.put("com.bumptech.glide.annotation.compiler.test.regenerate.path", projectDir) - } - doFirst { - println("Regenerating test resources....") - } - doLast { - println("Finished regenerating test resources") - } -} - -afterEvaluate { - regenerateTestResources.finalizedBy(testReleaseUnitTest) -} diff --git a/annotation/compiler/test/build.gradle.kts b/annotation/compiler/test/build.gradle.kts new file mode 100644 index 0000000000..5c1c5b6ef1 --- /dev/null +++ b/annotation/compiler/test/build.gradle.kts @@ -0,0 +1,90 @@ +plugins { + id("com.android.library") +} + +android { + namespace = "com.bumptech.glide.annotation.compiler.test" + compileSdkVersion = libs.versions.compile.sdk.version.get() + + defaultConfig { + minSdk = libs.versions.min.sdk.version.get().toInt() + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + testOptions { + unitTests.all { testTask -> + testTask.maxParallelForks = 2 + } + } + + sourceSets { + getByName("test") { + resources { + // *.java is excluded by default... + setExcludes(emptyList()) + } + // TODO: Re-enable these tests after fixing import orders. + java { + exclude("**/AppGlideModuleWithExcludesTest.java") + exclude("**/AppGlideModuleWithLibraryInPackageTest.java") + exclude("**/AppGlideModuleWithMultipleExcludesTest.java") + exclude("**/EmptyAppAndLibraryGlideModulesTest.java") + exclude("**/GlideExtensionWithOptionTest.java") + exclude("**/GlideExtensionWithTypeTest.java") + exclude("**/GlideExtensionWithTypeTest.java") + } + } + } +} + +// This special test only submodule exists because adding the :glide dependency seems to break +// the annotation processor dependency chain for the internal sample apps. It's also somewhat +// easier to parse as a separate module given the existing complexity here and in the compiler +// build.gradle file. +dependencies { + testImplementation(project(":glide")) + testImplementation(project(":annotation:compiler")) + testImplementation(libs.junit) + testImplementation(libs.javapoet) + testImplementation(libs.findbugs.jsr305) + // Using 0.10 of compile-testing is required for Android Studio to function, but not for the + // gradle build. Not yet clear why, but it looks like some kind of version conflict between + // javapoet, guava and/or truth. + //noinspection GradleDependency + testImplementation("com.google.testing.compile:compile-testing:0.10") { + // We don't use this and including it requires us to list it separatel which would be + // confusing. + exclude(group = "com.google.auto.value", module = "auto-value") + } + testImplementation(libs.androidx.annotation) + testImplementation(libs.androidx.fragment) + // TODO: Find some way to include a similar dependency on java 9+ and re-enable these tests in gradle. +// testImplementation files(Jvm.current().getJre().homeDir.getAbsolutePath()+'/lib/rt.jar') + + testAnnotationProcessor(project(":annotation:compiler")) + testAnnotationProcessor(libs.autoservice) +} + +tasks.register("regenerateTestResources") { + group = "Verification" + description = "Regenerates all test resource files under annotation/compiler/test/src/test/resources that are compared against the current output to detect regressions" + tasks.withType { + systemProperties["com.bumptech.glide.annotation.compiler.test.regenerate.path"] = projectDir + } + doFirst { + println("Regenerating test resources....") + } + doLast { + println("Finished regenerating test resources") + } +} + +afterEvaluate { + tasks.named("lint").configure { enabled = false } + tasks.named("compileReleaseJavaWithJavac").configure { enabled = false } + tasks.named("regenerateTestResources") { finalizedBy("testReleaseUnitTest") } +} diff --git a/library/build.gradle b/library/build.gradle deleted file mode 100644 index 01ba8cedea..0000000000 --- a/library/build.gradle +++ /dev/null @@ -1,103 +0,0 @@ -apply plugin: 'com.android.library' - -if (!hasProperty('DISABLE_ERROR_PRONE')) { - apply plugin: "net.ltgt.errorprone" -} - -tasks.withType(JavaCompile) { - options.fork = true -} - -dependencies { - api project(':third_party:gif_decoder') - api project(':third_party:disklrucache') - api project(':annotation') - api libs.androidx.fragment - api libs.androidx.vectordrawable - api libs.androidx.exifinterface - api libs.androidx.tracing - compileOnly libs.androidx.appcompat - - if (project.plugins.hasPlugin('net.ltgt.errorprone')) { - errorprone libs.errorprone.core - } - - testImplementation libs.androidx.appcompat - testImplementation project(':testutil') - testImplementation libs.guava.testlib - testImplementation libs.truth - testImplementation libs.junit - testImplementation libs.mockito.core - testImplementation libs.robolectric - testImplementation libs.mockwebserver - testImplementation libs.androidx.test.core - testImplementation libs.androidx.junit - testImplementation libs.androidx.test.runner -} - -if (project.plugins.hasPlugin('net.ltgt.errorprone')) { - tasks.withType(JavaCompile) { - options.errorprone.disable( - // It's often useful to track individual objects when debugging - // object pooling. - "ObjectToString", - // Doesn't apply when we can't use lambadas. - "UnnecessaryAnonymousClass", - // TODO(judds): Fix these and re-enable this check - "BadImport", - "UnescapedEntity", - "MissingSummary", - "InlineMeSuggester", - "CanIgnoreReturnValueSuggester", - "TypeNameShadowing", - "UndefinedEquals", - "UnnecessaryParentheses", - "UnusedVariable", - "EqualsGetClass", - "LockNotBeforeTry") - } -} - -android { - namespace 'com.bumptech.glide' - compileSdkVersion libs.versions.compile.sdk.version.get() - - defaultConfig { - minSdk libs.versions.min.sdk.version.get() as int - targetSdk libs.versions.target.sdk.version.get() as int - versionName VERSION_NAME as String - consumerProguardFiles 'proguard-rules.txt' - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } -} - -// Change the name to make it a little more obvious where the main library -// documentation has gone. Using a capital letter happens to make this first in -// the list too... -afterEvaluate { - dokkaHtmlPartial.configure { - dokkaSourceSets { - named("main") { - moduleName.set("Glide") - } - } - } -} - -check.dependsOn(':library:pmd:pmd') -check.dependsOn(':library:test:check') - -// Used in pmd and findbugs subprojects. -@SuppressWarnings("GroovyUnusedDeclaration") -def classPathForQuality() { - return files( - android.bootClasspath, - project.android.libraryVariants.collect { it.javaCompile.classpath } - ) -} - -apply from: "${rootProject.projectDir}/scripts/upload.gradle.kts" diff --git a/library/build.gradle.kts b/library/build.gradle.kts new file mode 100644 index 0000000000..5527fd9b19 --- /dev/null +++ b/library/build.gradle.kts @@ -0,0 +1,107 @@ +import com.android.build.gradle.LibraryExtension +import net.ltgt.gradle.errorprone.errorprone +import org.gradle.api.tasks.compile.JavaCompile + +plugins { + id("com.android.library") +} + +if (!hasProperty("DISABLE_ERROR_PRONE")) { + apply(plugin = "net.ltgt.errorprone") +} + +tasks.withType().configureEach { + options.setFork(true) +} + +dependencies { + api(project(":third_party:gif_decoder")) + api(project(":third_party:disklrucache")) + api(project(":annotation")) + api(libs.androidx.fragment) + api(libs.androidx.vectordrawable) + api(libs.androidx.exifinterface) + api(libs.androidx.tracing) + compileOnly(libs.androidx.appcompat) + + if (project.plugins.hasPlugin("net.ltgt.errorprone")) { + "errorprone"(libs.errorprone.core) + } + + testImplementation(libs.androidx.appcompat) + testImplementation(project(":testutil")) + testImplementation(libs.guava.testlib) + testImplementation(libs.truth) + testImplementation(libs.junit) + testImplementation(libs.mockito.core) + testImplementation(libs.robolectric) + testImplementation(libs.mockwebserver) + testImplementation(libs.androidx.test.core) + testImplementation(libs.androidx.junit) + testImplementation(libs.androidx.test.runner) +} + +if (project.plugins.hasPlugin("net.ltgt.errorprone")) { + tasks.withType().configureEach { + options.errorprone.disable( + // It's often useful to track individual objects when debugging + // object pooling. + "ObjectToString", + // Doesn't apply when we can't use lambadas. + "UnnecessaryAnonymousClass", + // TODO(judds): Fix these and re-enable this check + "BadImport", + "UnescapedEntity", + "MissingSummary", + "InlineMeSuggester", + "CanIgnoreReturnValueSuggester", + "TypeNameShadowing", + "UndefinedEquals", + "UnnecessaryParentheses", + "UnusedVariable", + "EqualsGetClass", + "LockNotBeforeTry", + ) + } +} + +android { + namespace = "com.bumptech.glide" + compileSdkVersion = libs.versions.compile.sdk.version.get() + + defaultConfig { + minSdk = libs.versions.min.sdk.version.get().toInt() + consumerProguardFiles("proguard-rules.txt") + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } +} + +// Change the name to make it a little more obvious where the main library +// documentation has gone. Using a capital letter happens to make this first in +// the list too... +afterEvaluate { + tasks.named("dokkaHtmlPartial").configure { + (this as org.jetbrains.dokka.gradle.DokkaTaskPartial).dokkaSourceSets { + named("main") { + moduleName.set("Glide") + } + } + } +} + +tasks.named("check") { + dependsOn(":library:pmd:pmd") + dependsOn(":library:test:check") +} + +// Used in pmd and findbugs subprojects. +val classPathForQuality by extra { + files(android.bootClasspath) + + project.the().libraryVariants.map { it.javaCompileProvider.get().classpath } +} + +apply(from = "${rootProject.projectDir}/scripts/upload.gradle.kts") diff --git a/library/pmd/build.gradle b/library/pmd/build.gradle deleted file mode 100644 index 05748e5bbd..0000000000 --- a/library/pmd/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -apply plugin: 'pmd' - -def library = project(':library') - -pmd { - toolVersion libs.versions.pmd.get() -} - -tasks.create('pmd', Pmd) { - dependsOn library.tasks.compileReleaseJavaWithJavac - targetJdk = TargetJdk.VERSION_1_7 - - description 'Run pmd' - group 'verification' - - // If ruleSets is not empty, it seems to contain some - // defaults which override rules in the ruleset file... - ruleSets = [] - ruleSetFiles = files("${library.projectDir}/pmd-ruleset.xml") - source library.android.sourceSets.main.java.srcDirs - classpath = files() - classpath += files(library.tasks.compileReleaseJavaWithJavac.destinationDir) - doFirst { - classpath += library.classPathForQuality() - } - - //TODO enable this once new Gradle containing this flag is out - //see https://github.com/gradle/gradle/pull/3125#issuecomment-352442432 - //incrementalAnalysis = true - - // Failures are caught and printed by the violations plugin. - ignoreFailures = true - - reports { - xml.required.set(true) - html.required.set(false) - } -} - diff --git a/library/pmd/build.gradle.kts b/library/pmd/build.gradle.kts new file mode 100644 index 0000000000..d0d71f2107 --- /dev/null +++ b/library/pmd/build.gradle.kts @@ -0,0 +1,41 @@ +import com.android.build.gradle.LibraryExtension + +plugins { + pmd +} + +val library = project(":library") + +pmd { + toolVersion = libs.versions.pmd.get() +} + +tasks.register("pmd") { + dependsOn(library.tasks.named("compileReleaseJavaWithJavac")) + targetJdk = TargetJdk.VERSION_1_7 + + description = "Run pmd" + group = "verification" + + // If ruleSets is not empty, it seems to contain some + // defaults which override rules in the ruleset file... + ruleSets = emptyList() + ruleSetFiles = files("${library.projectDir}/pmd-ruleset.xml") + source(library.the().sourceSets.getByName("main").java.srcDirs) + classpath = files(library.tasks.named("compileReleaseJavaWithJavac").map { (it as org.gradle.api.tasks.compile.JavaCompile).destinationDirectory }) + doFirst { + classpath = classpath!!.plus(library.extra["classPathForQuality"] as FileCollection) + } + + //TODO enable this once new Gradle containing this flag is out + //see https://github.com/gradle/gradle/pull/3125#issuecomment-352442432 + //incrementalAnalysis = true + + // Failures are caught and printed by the violations plugin. + ignoreFailures = true + + reports { + xml.required.set(true) + html.required.set(false) + } +}