-
Notifications
You must be signed in to change notification settings - Fork 276
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
Fix support with Gradle 5.x/Android 2.5+; add Gradle 5.1 and drop Gradle 3.0 in tests. #287
Merged
+83
−77
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Fixed missing Gradle version specifications in two tests. - Added missing settings.gradle in the test projects because Gradle 5.0 starts to complain about it.
After upgrading to Gradle 5.0, a few new codenarc failures emerged. Don't know why, but fixed them anyway.
WIP: Still trying to fix tests. There are multiple issues: 1. extracted-include-protos as input of GenerateProtoTask, when doesn't exist, will fail the validation of GenerateProtoTask. Tried to always mkdir for them, but doesn't work. (TODO: Currently suppressed by removing the "input" setting. Should be fixed). 2. MethodDefNotFoundError from Kotlin plugin calling into Gradle API. This is supposedly fixed by upgrading the kotlin plugin version in the build file of the protouf plugin. 3. Could not find lint-gradle:26.1.0 in Android projects. Probably missing repo definition. 4. AndroidProjectDetectionTest fails due to class path issues. Thought: currently the whole classpath of the protobuf plugin as it's built is injected into the test projects (through plugin-classpath.txt). The plugin is built with Gradle 5.0 and a certain Android and kotlin plugin versions, but the tests can be run in different versions. They may not necessarily be compatible. Additionally, the current test harness is done in a way that's hard to track, run and debug. The whole thing needs to be revisited.
This resolves missing dependencies for lint-gradle:26.1.0
Support for Android plugin 2.5+ was added in google#121. While it made extractIncludeProtosTask to copy the protos to a different destination with Android plugin 2.5+ than with older verisons, it didn't make generateProtoTask to "include" the new location. This causes Android tests to fail with Gradle 5.0 and Android plugin 3.1.0. The bug has remained undetected because test was never run with Android 2.5+.
TODO: Couldn't expand to the fourth (oldest) version because of OverlappingFileLockException when Gradle trying to resolve dependencies.
Refactored the codepath to make it less prone to such mistake.
…tionTest. This case fails with java.lang.NoSuchMethodException: com.android.build.gradle.internal.BuildSessionImpl.initialize(org.gradle.api.invocation.Gradle) The (Gradle(3.0) Android(2.2.0)) also fails with OverlappingFileLockException seen in ProtobufAndroidPluginTest.
Gradle 3.0 / Android 2.2.0 is commented out due to gradle/gradle#8158
This fixes #253 for me |
ejona86
approved these changes
Jan 10, 2019
Still have the same issue with Gradle wrapper 5.1 and android plugin 3.4.0 - alpha 10 |
@SzasznikaJanos were you running with a locally built protobuf-gradle-plugin? If not, you are probably using the snapshot in repo which is not up-to-date. I just pushed a new one and you can try again. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
gradle/wrapper/gradle-wrapper.properties
: the Protobuf plugin is now built with Gradle 5.1ProtobufPlugin.groovy
: fixed a bug where GenerateProtoTask may "include" the wrong directory when running with Android plugin >= 2.5.addGenerateProtoTask()
always use the directory per sourceSet as input (original line 328), but with Android plugin >= 2.5, the extract task writes to the directory per variant (original line 272), thus they don't match. The GenerateProtoTask ends up using a nonexistent directory as an input. We didn't catch it in tests because the integration tests were only run with Android plugin up to 2.3. However, Gradle produced a warning about missing input directory, which becomes an error on Gradle 5.0 (Gradle 5.0 Depreciated API features #253). Adding Gradle 5.1 and Android 3.1.0 to the test reproduces this bug.