-
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
apply plugin: 'de.thetaphi.forbiddenapis' is very slow. #116
Comments
For several reasons I will not add precompiled Groovy code at the moment (not compatible to the setup of compiling the plugin for 3 build systems + CLI in one single artifact). The only idea would be to only parse the groovy script once and reuse the compiled class. That should be easy to implement. |
Hi, The reason why I am not sure is: It is undefined in the Gradle docs, if a new instance of the plugin is created for all subprojects, or if there is a single instance and the apply() method is just called multiple times. If you have some time to figure that out, I would be happy. |
An alternative would be to init the script in the static initializer, but if there is only a single instance of the Plugin, I would prefer to have it like that. FYI, creating the plugin-init code in pure Java is not really doable for several reasons:
|
Oh oh, I think I should compile the script on clinit: http://stackoverflow.com/questions/27026996/what-is-gradle-plugin-lifecycle Will work on this later! |
I pushed a new version that "compiles" the script on loading the plugin class. |
See the PR #117 |
268ms configuration time with the 500+ module Gradle build using #117. 👍 FYI: I had to manually create |
May I ask why it needs to be Groovy at all? Why can't that piece of code not be written in Java like the rest of the plugin? |
@oehme the problem was mentioned before: The ForbiddenAPIs plugin supports Ant, Maven, Gradle and a CLI interface. Yes you could theoretically write everything in Java, but there are some problems:
|
You should be able to run |
Thanks, so this PR fixes the issue. I will merge that later! |
I simply executed |
Thanks for the explanation. We are planning to make that easier in the future, as we've seen some other projects as well who are stuck on Maven, but still want to provide a Gradle plugin. |
@huxi OK. Id like to fix this. Could you create another issue and post the whole build output there? Maybe I should explicitely create the missing directories in the ant script. |
@oehme Thanks! I hope this will be possible also with older, still Java-6-based Gradle versions, so the forbiddenapis plugin can stay compatible with Java 6 (it is currently built against Java 6). If you would publish Maven artifacts only for newer versions, this may still not solve the issue (unless forbiddenapis requires Java 7 minimum at some point). Keep me updated! :-) |
@uschindler Just tried |
…ch invocation instead of an instance (according to Groovy guidelines)
@huxi No problem, sometimes strange things happens. I added a small rewrite according to the Groovy guidelines. This new implementation now still compiles the script on static initializer, but actually to a Java class that is then reused to create several instances. This makes it thread safe, so I was able to remove the stupid synchronization. |
The new implementation is now committed and pushed. Have fun! I try to release a new version soon, because other people were already complaining about some slowness for large projects, maybe that was related. |
Thanks for taking care about this issue in such a timely fashion. |
…in class (policeman-tools#117) Compile the Groovy script only once when loading the Gradle plugin class. This closes policeman-tools#116
…s reused for each invocation instead of an instance (according to Groovy guidelines)
adds 25s to the configuration time of a multi-module build with about 500 modules.
The reason for this is that ForbiddenApisPlugin.java is compiling the plugin-init.groovy script for every single
apply
call.You should instead re-implement the
plugin-init.groovy
functionality in Java or switch theForbiddenApisPlugin
to Groovy.The text was updated successfully, but these errors were encountered: