Search code examples
javabuildgradle

Adding classpath entries using Gradle's Application plugin


I'm using Gradle's Application plugin to generate the install for a standalone java application. I have a configuration file I need to put on the classpath but I can't seem to get it to generate the classpath correctly in the sh/bat files. This configuration file needs to be located outside of the jar.

The conf file is in the directory /src/dist/conf/ so when I run installApp it installs it under a conf directory like this $APP_HOME/conf.

I tried adding this directory to the claspath like this:

startScripts.classpath.add(files('$APP_HOME/conf'))

but when I look at the classpath in the sh/bat files it adds an entry that looks like this:

$APP_HOME/lib/conf

How do I tell gradle to drop the lib section for this entry?


Solution

  • It seems to me that what I'm trying to do shouldn't be that far out of the ordinary, but as a workaround I can have the dist directory be src/dist/lib/conf which allows the conf directory to be placed in the lib directory and the classpath that gradle generates for the sh/bat files to be correct.

    I'll accept another answer if someone has a better one.