Marco
(Marco Paolieri)
March 15, 2013, 4:41pm
1
Using the plugins Java and Application, I cannot add a subdirectory of ‘$APP_HOME/lib’ to the build path. If I add
// include all the jars in lib/plugins startScripts.classpath += files(’$APP_HOME/lib/plugins/*’)
I get a script where only ‘$APP_HOME/lib/*’ is appended to the build path, like if I added
// include all the jars in lib startScripts.classpath += files(’$APP_HOME/lib/*’)
Do you have any hint on this? (I’m using gradle 1.4).
Thanks, Marco
Currently, the plugin makes the assumption that all files that go on the application’s class path are directly located in the ‘lib’ directory.
That aside, I’m not sure if ‘*’ works, but maybe it does.
Marco
(Marco Paolieri)
March 15, 2013, 5:16pm
3
Thanks Peter for the prompt answer!
The ‘’ works fine for all the jars inside the lib directory (since Java 6). Are you sure the all the files of the class path need to be in the lib directory? Adding ‘files(‘plugins’)’ to startScripts.classpath, I get ‘$APP_HOME/lib/plugins’. Adding 'files('plugins/ ’)’, I get ‘$APP_HOME/lib/*’.
This is strange, since from github it seems that the paths should just be prepended with the APP_HOME and joined together (am I looking at the right source code?)
https://github.com/gradle/gradle/blob/REL_1.4/subprojects/plugins/src/main/groovy/org/gradle/api/internal/plugins/StartScriptGenerator.groovy
Also, this pull request was quite interesting, since it would allow other directories on the classpath outside of lib:
https://github.com/gradle/gradle/pull/105
Marco
The * works fine for all the jars inside the lib directory (since Java 6)
I know, I just wasn’t sure if ‘Project.files()’ is happy with it.
Are you sure the all the files of the class path need to be in the lib directory?
From ‘org.gradle.api.tasks.application.CreateStartScripts’:
generator.classpath = getClasspath().collect { "lib/${it.name}" }
I’m not saying this is good or bad, just that it’s the status quo.
Marco
(Marco Paolieri)
March 15, 2013, 5:30pm
5
Peter, I feel confused (but again, thanks for the help). Why ‘plugins’ works and ‘plugins/(asterisk)’ doesn’t? Couldn’t ${it.name } be ‘plugins/*’?
‘File.getName()’ returns the last part of the pathname, which in this case is ‘*’.
Marco
(Marco Paolieri)
March 15, 2013, 5:42pm
7
Argh, you’re right. No way. Such a shame, since copying included jars in /lib/plugins was easy and the script thing is great. Thanks anyway.
ceilfors
(Wisen Tanasa)
June 25, 2013, 3:19pm
8