Adding a subdirectory of lib to the classpath of a distZip script

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.

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.

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 ‘*’.

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.

The lib folder is added by this guy: https://github.com/gradle/gradle/blob/REL_1.5/subprojects/plugins/src/main/groovy/org/gradle/api/tasks/application/CreateStartScripts.groovy