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
Gradle plugin warning after migrating to Gradle 4.0 #1686
Comments
I believe the issue is that Gradle 4 wants plugins to call A naive "fix" is probably as simple as --- a/flyway-gradle-plugin/src/main/java/org/flywaydb/gradle/task/AbstractFlywayTask.java
+++ b/flyway-gradle-plugin/src/main/java/org/flywaydb/gradle/task/AbstractFlywayTask.java
@@ -303,9 +303,11 @@ public abstract class AbstractFlywayTask extends DefaultTask {
JavaPluginConvention plugin = getProject().getConvention().getPlugin(JavaPluginConvention.class);
for (SourceSet sourceSet : plugin.getSourceSets()) {
- URL classesUrl = sourceSet.getOutput().getClassesDir().toURI().toURL();
- getLogger().debug("Adding directory to Classpath: " + classesUrl);
- extraURLs.add(classesUrl);
+ for (File classesDir : sourceSet.getOutput().getClassesDirs().getFiles()) {
+ URL classesUrl = classesDir.toURI().toURL();
+ getLogger().debug("Adding directory to Classpath: " + classesUrl);
+ extraURLs.add(classesUrl);
+ }
URL resourcesUrl = sourceSet.getOutput().getResourcesDir().toURI().toURL();
getLogger().debug("Adding directory to Classpath: " + resourcesUrl); but this would cause the plugin to stop working with pre-4.0 Gradle versions, and would require the plugin to be built against Gradle 4.x libraries. You could get around that by trying to dynamically invoke the method via reflection; I'm not sure if that's the approach Flyway's maintainers would want to take here. |
I have gone in and modified things to be ready for gradle 5 but as mentioned then this breaks everything on pre gradle 4.x. Unfortunately we still need to use gradle 3.x for some things. I get I can use different wrappers for different projects but individual developers are also a consideration not just the build system. Is there no good way to change this for gradle 5 and have it work in gradle 3.x? |
With Flyway 5.0.0 the new minimum supported Gradle version is 3.0. We can't move to 4.0 yet as it is still too recent. If someone wants to contribute a pull request (probably using some reflection) to bridge the gap between Gradle 3.0 and 4.0+, I would be more than glad to merge it. |
In Gradle 4.x, the method getClassesDir() in SourceSetOutput has been deprecated in favor of a new method getClassesDirs(). Use reflection to invoke this method, if it is available, so that consumers using Gradle 4.x are spared the deprecation warning. Fall back to the original method for consumers using Gradle 3.x. Fixes flyway#1686
@axelfontaine, I believe I have something that might work for both Gradle 3.x and Gradle 4.x. I was able to test these changes locally with simple projects using Gradle 3.x/4.x based on https://flywaydb.org/getstarted/firststeps/gradle. |
Tackle deprecation warning generated by Gradle 4.x
In Gradle 4.x, the method getClassesDir() in SourceSetOutput has been deprecated in favor of a new method getClassesDirs(). Use reflection to invoke this method, if it is available, so that consumers using Gradle 4.x are spared the deprecation warning. Fall back to the original method for consumers using Gradle 3.x. Fixes flyway#1686
Tackle deprecation warning generated by Gradle 4.x
Flyway 4.2.0, Gradle 4.0, Postgres 9.6.
All Flyway tasks work as expected from what I can tell, but they generate the following warning on each run:
This seems to be an issue with current Gradle plugin implementation.
The text was updated successfully, but these errors were encountered: