Skip to content

Commit

Permalink
Use ProjectLayout to get build directory in GenerateProtoTask
Browse files Browse the repository at this point in the history
Accessing build directory through Task.project is incompatible with Gradle configuration caching.
  • Loading branch information
ALikhachev authored and ejona86 committed Jun 21, 2021
1 parent 0e24de2 commit 5d0d5ad
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.gradle.api.Named
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import org.gradle.api.file.ProjectLayout
import org.gradle.api.file.SourceDirectorySet
import org.gradle.api.internal.file.FileResolver
import org.gradle.api.logging.LogLevel
Expand Down Expand Up @@ -88,6 +89,7 @@ public abstract class GenerateProtoTask extends DefaultTask {
private final ConfigurableFileCollection sourceFiles = objectFactory.fileCollection()
private final NamedDomainObjectContainer<PluginOptions> builtins = objectFactory.domainObjectContainer(PluginOptions)
private final NamedDomainObjectContainer<PluginOptions> plugins = objectFactory.domainObjectContainer(PluginOptions)
private final ProjectLayout projectLayout = project.layout

// These fields are set by the Protobuf plugin only when initializing the
// task. Ideally they should be final fields, but Gradle task cannot have
Expand Down Expand Up @@ -703,7 +705,7 @@ public abstract class GenerateProtoTask extends DefaultTask {
if (jarFileName.length() <= JAR_SUFFIX.length()) {
throw new GradleException(".jar protoc plugin path '${jarAbsolutePath}' has no file name")
}
File scriptExecutableFile = new File("${project.buildDir}/scripts/" +
File scriptExecutableFile = new File("${projectLayout.buildDirectory.get()}/scripts/" +
jarFileName[0..(jarFileName.length() - JAR_SUFFIX.length() - 1)] + "-${getName()}-trampoline." +
(isWindows ? "bat" : "sh"))
try {
Expand Down

0 comments on commit 5d0d5ad

Please sign in to comment.