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

Android - Add tested top-level dirs that contains protos #542

Merged
merged 1 commit into from
Jan 11, 2022
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 @@ -426,7 +426,7 @@ class ProtobufPlugin implements Plugin<Project> {
// ad-hoc solution that manually includes the source protos of 'main' and its
// dependencies.
if (Utils.isTest(sourceSetOrVariantName)) {
inputFiles.from getSourceSets()['main'].proto
inputFiles.from getSourceSets()['main'].proto.sourceDirectories
inputFiles.from testedCompileClasspathConfiguration
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,38 @@ class ProtobufAndroidPluginTest extends Specification {
agpVersion << ANDROID_PLUGIN_VERSION
gradleVersion << GRADLE_VERSION
}

@Unroll
void "testProjectAndroid tests build without warnings [android #agpVersion, gradle #gradleVersion]"() {
given: "project from testProject, testProjectLite & testProjectAndroid"
File testProjectStaging = ProtobufPluginTestHelper.projectBuilder('testProject')
.copyDirs('testProjectBase', 'testProject')
.build()
File testProjectAndroidStaging = ProtobufPluginTestHelper.projectBuilder('testProjectAndroid')
.copyDirs('testProjectAndroidBase', 'testProjectAndroid')
.build()
File testProjectLiteStaging = ProtobufPluginTestHelper.projectBuilder('testProjectLite')
.copyDirs('testProjectLite')
.build()
File mainProjectDir = ProtobufPluginTestHelper.projectBuilder('testProjectAndroidMain')
.copySubProjects(testProjectStaging, testProjectLiteStaging, testProjectAndroidStaging)
.withAndroidPlugin(agpVersion)
.build()
when: "build is invoked"
BuildResult result = buildAndroidProject(
mainProjectDir,
gradleVersion,
"testProjectAndroid:assembleAndroidTest"
)

then: "it succeed"
result.task(":testProjectAndroid:assembleAndroidTest").outcome == TaskOutcome.SUCCESS

and: "does not contain warnings about proto location"
!result.output.contains("This makes you vulnerable to https://github.com/google/protobuf-gradle-plugin/issues/248")

where:
agpVersion << ANDROID_PLUGIN_VERSION.takeRight(1)
gradleVersion << GRADLE_VERSION.takeRight(1)
}
}