Skip to content

Commit

Permalink
Fix implicit task dependency issue
Browse files Browse the repository at this point in the history
Redwood Lint can't use the project directory as a "directory" input as gradle considers all the contents of the directory to be inputs to the task. The "official" recommendation is to use a String input with the absolute path as the input.

Set all JVM targets to 11
  • Loading branch information
dellisd authored and JakeWharton committed Apr 18, 2023
1 parent f47ba3a commit 5d33f4d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ allprojects {

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile).configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
jvmTarget.set(JvmTarget.JVM_11)
freeCompilerArgs.addAll([
'-Xjvm-default=all',
])
Expand Down Expand Up @@ -148,8 +148,8 @@ allprojects {
project.android {
compileSdk 33
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
minSdk 21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private fun Project.createRedwoodLintTask(
task.description = taskDescription(descriptionTarget)

task.toolClasspath.setFrom(configuration.incoming.artifacts.artifactFiles)
task.projectDirectory.set(project.projectDir)
task.projectDirectoryPath.set(project.projectDir.absolutePath)
task.sourceDirectories.set(sourceDirs())
task.classpath.setFrom(
classpath().incoming.artifactView {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ import java.io.File
import javax.inject.Inject
import org.gradle.api.DefaultTask
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity.ABSOLUTE
import org.gradle.api.tasks.TaskAction
import org.gradle.process.ExecOperations
import org.gradle.workers.WorkAction
Expand All @@ -40,9 +36,8 @@ internal abstract class RedwoodLintTask @Inject constructor(
@get:Classpath
abstract val toolClasspath: ConfigurableFileCollection

@get:InputDirectory
@get:PathSensitive(ABSOLUTE)
abstract val projectDirectory: RegularFileProperty
@get:Input
abstract val projectDirectoryPath: Property<String>

@get:Input
abstract val sourceDirectories: Property<Collection<File>>
Expand All @@ -55,7 +50,7 @@ internal abstract class RedwoodLintTask @Inject constructor(
val queue = workerExecutor.noIsolation()
queue.submit(RedwoodLintWorker::class.java) {
it.toolClasspath.from(toolClasspath)
it.projectDirectory.set(projectDirectory)
it.projectDirectoryPath.set(projectDirectoryPath)
it.sourceDirectories.set(sourceDirectories)
it.classpath.setFrom(classpath)
}
Expand All @@ -64,7 +59,7 @@ internal abstract class RedwoodLintTask @Inject constructor(

private interface RedwoodLintParameters : WorkParameters {
val toolClasspath: ConfigurableFileCollection
val projectDirectory: RegularFileProperty
val projectDirectoryPath: Property<String>
val sourceDirectories: Property<Collection<File>>
val classpath: ConfigurableFileCollection
}
Expand All @@ -79,7 +74,7 @@ private abstract class RedwoodLintWorker @Inject constructor(

exec.args = mutableListOf<String>().apply {
add("lint")
add(parameters.projectDirectory.get().asFile.absolutePath)
add(parameters.projectDirectoryPath.get())

for (file in parameters.sourceDirectories.get()) {
add("--sources")
Expand Down

0 comments on commit 5d33f4d

Please sign in to comment.