I successfully configured my gradle build script to create a zip distribution for my application with an extra βconfigβ folder in the root. This folder contains (at least right now) only one properties file used by the application and is located in the class path for the application.
However, now I am looking for a way to do the same with the run task in the application plugin. When I try to run my application this way (for testing), my program does not start because of a class trying to access this properties file in the root of the class path.
The bonus would be if I could force IntelliJ or Eclipse to also add this folder to my classpath, like other folders (src / main / java, src / main / resources, ...) so that I can run and debug my code from the IDE without calling the gradle task. I want to try to avoid linking this code as much as possible with any IDE, so when someone needs to work on a project, they just need to import the build.gradle file and provide the IDE with the configuration files they need.
Here is my build.gradle file:
apply plugin: 'application' mainClassName = "MainClass" startScripts { // Add config folder to classpath. Using workaround at // https://discuss.gradle.org/t/classpath-in-application-plugin-is-building-always-relative-to-app-home-lib-directory/2012 classpath += files('src/dist/config') doLast { def windowsScriptFile = file getWindowsScript() def unixScriptFile = file getUnixScript() windowsScriptFile.text = windowsScriptFile.text.replace('%APP_HOME%\\lib\\config', '%APP_HOME%\\config') unixScriptFile.text = unixScriptFile.text.replace('$APP_HOME/lib/config', '$APP_HOME/config') } } repositories { ... } dependencies { ... }
It is likely that what should happen is that I need the / src / dist / config folder to be copied to the assembly directory and added to the class path, or its contents will be copied to a folder that is already in the class path.
java classpath eclipse intellij-idea gradle
agent154
source share