Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid storing variantName property in the task #448

Merged
merged 1 commit into from
Nov 17, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public abstract class GenerateProtoTask extends DefaultTask {
private String buildType
private boolean isTestVariant
private FileResolver fileResolver
private final Provider<String> variantName = providerFactory.provider { variant.name }
private final Provider<Boolean> isAndroidProject = providerFactory.provider { Utils.isAndroidProject(project) }
private final Provider<Boolean> isTestProvider = providerFactory.provider {
if (Utils.isAndroidProject(project)) {
Expand Down Expand Up @@ -341,11 +340,6 @@ public abstract class GenerateProtoTask extends DefaultTask {
return isAndroidProject
}

@Internal("Not an actual input to the task, only used to find tasks belonging to a variant")
Provider<String> getVariantName() {
return variantName
}

@Internal("Not an actual input to the task, only used to find tasks belonging to a variant")
boolean getIsTestVariant() {
Preconditions.checkState(isAndroidProject.get(),
Expand All @@ -367,7 +361,7 @@ public abstract class GenerateProtoTask extends DefaultTask {
Preconditions.checkState(isAndroidProject.get(),
'buildType should not be used in a Java project')
Preconditions.checkState(
variantName.get() == 'test' || buildType,
variant.name == 'test' || buildType,
'buildType is not set and task is not for local unit test variant')
return buildType
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public class ProtobufConfigurator {

public TaskCollection<GenerateProtoTask> ofVariant(String variant) {
return all().matching { GenerateProtoTask task ->
task.variantName.get() == variant
task.variant.name == variant
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import spock.lang.Unroll
@CompileDynamic
class ProtobufJavaPluginTest extends Specification {
// Current supported version is Gradle 5+.
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.5-rc-1"]
private static final List<String> GRADLE_VERSIONS = ["5.6", "6.0", "6.7.1"]
private static final List<String> KOTLIN_VERSIONS = ["1.3.20", "1.3.30"]

void "testApplying java and com.google.protobuf adds corresponding task to project"() {
Expand Down Expand Up @@ -85,13 +85,16 @@ class ProtobufJavaPluginTest extends Specification {
File projectDir = ProtobufPluginTestHelper.projectBuilder('testProject')
.copyDirs('testProjectBase', 'testProject')
.build()
// Limit max number of problems to catch regressions
new File(projectDir, "gradle.properties").write('org.gradle.unsafe.configuration-cache.max-problems=42')

and:
GradleRunner runner = GradleRunner.create()
.withProjectDir(projectDir)
.withArguments(
'build', '--stacktrace',
'--configuration-cache=warn'
'--configuration-cache',
'--configuration-cache-problems=warn'
)
.withPluginClasspath()
.withGradleVersion(gradleVersion)
Expand Down