-
Notifications
You must be signed in to change notification settings - Fork 34
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
Yet another Gradle update issue: 7.4 deprecated FileTrees using @SkipWhenEmpty #189
Comments
We rely on "no files available", so we need to add the additional annotation also mentioned. Problem may be the minimum gradle version that does not have the annotation :-( This is not urgent, but I will find a solution before the next release (coming with Java 18). For now ignore the warning. |
Hi, Sorry this can't be fixed easily. Please ignore the warning for now and fix it later. Disable with strict deprecation check, sorry for this! |
Thanks a lot for quick reply @uschindler ! |
I think the only way to fix this for forbiddenapis while maintaining backwards compatibility with earlier versions (before Gradle 6.8, Minimum is 3.4), is to remove the annotation and exit in the executeTask method if the FileTree is empty (like @reta did in a first version of the PR opensearch-project/OpenSearch#2078). Unfortunately this causes Gradle to no longer print "NO-SOURCE" behind task name. I am also not sure if this slows additionally. |
@uschindler thank you for the update, the "NO-SOURCE" indeed won't be there, using
I would suspect it may be slower since more evaluations may potentially be run before the the task is skipped manually. There is a hacky way to make it work with annotation (but I don't even want to suggest it for widely used plugin like |
which one? 🤔 |
There are 2 hacks to try (but I have not explored these routes):
[1] https://stackoverflow.com/questions/1635108/adding-java-annotations-at-runtime |
Hi,
OK, this is not a good idea :-)
This may work, but that's not a good idea, and it is much more complex than adding an if-statement in the execute method. I was hoping that like with Inputs, you can add them in the configuration phase. For inputs you can add the annotation, but on the other hand you can also add them using |
I will check at weekend and implement some workaround. This is why I hate Gradle's development model: They change their APIs and workflows all the time and then have no idea how to help to maintain plugins for various versions. It is OK to do this and also remove deprecated stuff in the next major version, but Gradle releases a new major version like every half a year! |
I agree with you, the upgrade from 6.x to 7.x wiped out a week of my life but I really expected the update from 7.3.3 to 7.4 to be a no-brainer but ... :-\ |
Hi,
P.S.: I am about to relase v3.3 with JDK 18 support and the other cool features added recently. |
I will provide a PR later today as this is a bit of tricky change. I am fighting convention properties at the moment. I have it working, but it has some problems. |
Thanks a lot @uschindler ! |
Hi,
This solution was very easy. I just package a copy of the annotation with original package name (not shaded) inside the JAR file. Due to the way classloading works (parent first), Gradle won't load it after Gradle 6.8. Before Gradle 6.8 it is loaded from the forbiddenapis JAR file but ignored by Gradle on reflective access to them (it is just an arbitrary annotation). This is working fine and could also be done with other annotations. Other plugin authors have done the same in the meantime, so the idea was not new. This is mainly because this special annotation is too new (6.8) and brings major hassles. Most plugins in plugin store support a very large range of version numbers of Gradle, so their chance is only to ship with annotation. Uwe |
… forbiddenapis task with it. This works around problems with Grdale 7.4+. Closes #189
Here is the pull request: #193; could you have a look and maybe review it? |
We don't even need to ship with the annotation, so I excluded it from JAR file. This is really the clEanest solution:
|
Thank you @uschindler ! |
I only fixed another issue with forbiddens's own annotation processing (it wanted runtime annotations to be on classpath). This was a long standing issue, now also fixed: #194 |
Looks like all is working fine without any warnings in Gradle 7.4.1: https://jenkins.thetaphi.de/job/Forbidden-APIs-testonly-GradleLatest-Linux/82/console |
Gradle 7.4 (release notes [1]) deprecated
@SkipWhenEmpty
[2], builds (with strict deprecation check) fail with:[1] https://docs.gradle.org/7.4/release-notes.html
[2] https://docs.gradle.org/current/userguide/upgrading_version_7.html#empty_directories_file_tree
The text was updated successfully, but these errors were encountered: