-
Notifications
You must be signed in to change notification settings - Fork 655
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
Modernize build and fix deprecated gradle API usages #1476
Conversation
gradle/dependencies.gradle
Outdated
@@ -19,7 +19,7 @@ ext.androidConfig = [ | |||
] | |||
|
|||
ext.dep = [ | |||
androidPlugin : 'com.android.tools.build:gradle:3.3.0', | |||
androidPlugin : 'com.android.tools.build:gradle:3.4.1', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.4.2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix 👍
@@ -46,7 +46,7 @@ class ApolloExtension { | |||
outputPackageName = project.objects.property(String.class) | |||
outputPackageName.set("") | |||
|
|||
customTypeMapping = project.objects.property(Map.class) | |||
customTypeMapping = project.objects.mapProperty(String.class, String.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these were included in Gradle 4.x. Readme says 4.3 is required. Would be good to double check if 4.3 is fine or need to update the requirement in the Readme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can check, but also feel like only supporting current major version should be fine too. Gradle is already on 5.5, and these APIs are also not stable yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My Sample changes is merged. If you update your branch then you will have the sample. Sample now uses a separate project with composite builds. We can quickly try with different set of Gradle versions there. By changing the wrapper on the sample.
415ac34
to
5450e5c
Compare
So the minimum supported gradle version for current AGP (3.4.2) is 5.1.1. I think that should settle it? |
Hmm, think this as minSdk vs compileSdk on Android. This plugin depends on AGP 3.4.2 but works fine with older versions. In fact it work with java/Kotlin only projects where there is no AGP dependency at all. It's just that we need to figure out which versions we support at minimum and document that in README |
So I'm personally a big proponent of just supporting the current major version. For AGP that's 3.4.0, and for gradle that's 5.x. We can even actually easily set up tests for this on travis (example), but it's much harder to test this regularly if it requires lowering both AGP and gradle versions every time |
e92e4a3
to
fe0dd4a
Compare
Gradle testing APIs support integration testing the plugin across different versions. Testing against different version of AGP is also possible. Of course that is out of scope here. |
Looks like there are some changes which affects the integration module
|
Fixed the source directory set bit, just accidentally lost an import in a rebase. As for testing gradle 4.3, even if I lower back down to AGP 3.3.0, the min gradle version is still 4.10.1. This does fail on one new source directory set API 3.2.1 requires gradle 4.6 (feb 2018). This also fails on the new source directory set API 4.3 was October 2017. Not sure So in short - this would require gradle 5.x effectively. I think this is reasonable as it matches the current "major" AGP version as well |
Note the test failures appear unrelated, and I think just a change in how the gradle test kit works now. Will investigate |
I've partially addressed the new test requirements, but now I don't know what to do to fix all the tasks seeing themselves as up to date every test. I suspect it's something wrong with the incremental tasks logic in apollo itself |
In another Gradle plugin, we've had similar issues while trying to update to Gradle 5.x. Another problem was that it would use much more memory which results in ~5x slower CI builds. novoda/gradle-static-analysis-plugin#169 What about reverting the Gradle update. Or update to latest 4.10 but just fix depreciations. Then, that can be merged fast and then a PR updating Gradle can be open. |
I don't quite understand, as 4.10 is what we started with and per my last comment, some of these deprecation fixes require 5.x. Would prefer to fix here rather than backtrack |
I was just suggesting to take smaller steps so that this can be merged faster. Its just a suggestion. If it can be fixed here, that's better |
Also requires putting AGP in classpath for android subprojects Per recommendation from the plugin itself: The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build. This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal. Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects. If the parent project does not need the plugin, add 'apply false' to the plugin line.
Using DefaultSourceDirectorySet directly is deprecated
46e43ce
to
36416a3
Compare
Compiler doesn't like this, dunno why it passes master
Finally figured out the issue and resolved with 57f829c. Should be good to go now 🤞 Would like to get resolution for the gradle versioning bit. I think supporting the latest gradle (5.x) and AGP (3.4.x, which requires gradle 5.1+) is a very sane baseline support strategy. |
@@ -73,8 +73,7 @@ class ApolloAndroidPluginSpec extends Specification { | |||
|
|||
then: | |||
project.android.sourceSets.all { sourceSet -> | |||
assert (sourceSet.extensions.findByName("graphql")) != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really small comment. I find having hard coded graphql
in tests is better in terms of quality assurance.
Imagine a case where somebody changes GraphQLSourceDirectorySet.NAME
parameter, that will be a breaking change. The previous version of these tests will catch it whereas the new one will just accept them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Amazing maintenance work. Thanks @ZacSweers
@ZacSweers can you also update the README mentioning the minimum Gradle requirement. I checked it with your branch, everything works as expected when a client uses Gradle 5.1.1 (which is also what is required by the latest stable Android plugin) |
@tasomaniac done and also opportunistically updated to gradle 5.6 |
Is it ready to merge? |
I think so. |
This fixes a number of deprecated API usages found in my own project, and also brings the project up to speed with modern gradle and AGP versions