probably lots of you will find this question annoying and too easy, but it is causing me a bit of a headache.
I needed to compile my java code into an executable jar, and in order to set the classpath attrubute of the manifest i used ‘Class-Path’ : configurations.compile.collect { it.getName() }.join(’ '). It worked perfectly and I get what it does, but since i just discovered that instruction in a forum post I wanted to go to the documentation and find out how people got to that solution but I was able to find out only what a ConfigurationContainer and configurations are.
Now I now that compile is one of the four configurations created by the java plugin, but how can I see all the methods associated to it ?
Thank you for your time and patience.
That’s all true, but the method in his example is one of the cases that confuses people. Technically, you can find the “collect” method in the GDK javadoc for the “Collection” class, and you can see that Configuration is an Iterable, which leads to Collection, but you have to know that Groovy “enhances” Java classes, which is what the GDK javadoc shows. All in all, it’s not trivial to just “get a list of methods”. Even if you could, that would be a long list.
Configuration is an interface, because as an end-user you should only be interested by the services offered by such type, and not its implementation, which is the responsibility of the gradle devs.
That is without doubt correct, I got that far myself going through the gradle documentation. In my opinion knowing how things work and not just copy-paste code is paramount. Collect doesn’t appear anywhere in the gradle docs pages regarding configuration and since I need to use it as an end-user i wanted to know where it came from.
I just started using gradle and this build script required more knowledge of Groovy than I anticipated. A good excuse to get more into it.
Hi, I am also new to Gradle and have exact same question when I try to understand configurations.compile. By tracing down the source code, I can tell Configuration is a FileCollection. But I cannot see why FileCollection is a Collection, I don’t see FileCollection extends Collection in the Javadoc: https://docs.gradle.org/current/javadoc/org/gradle/api/file/FileCollection.html.
Thank you!