Perhaps the title is not very clear, I will describe the problem in more detail.

Required to configure build.gradle

There is the following project structure:

main java config 

and build.gradle (below only the relevant code from the script)

 distributions { main { contents { into('config') { from 'src/main/config' } } } } 

in the config folder there are files (ini, logback, etc.) that I want to change both in the development process and in the process of working with the assembled application.

Ie for example, the code says new FileReader ("main.ini") (main.ini is in the config folder)

and I want the program to pick up the parameters in a relative path in all three cases:

1) gralde run (application plugin)

2) idea - Main - run (normal run on the main class)

3) gradle distZip - unzip - ./program.sh

How to do it as correctly as possible?

    1 answer 1

    Make resources in the project structure, and drag on YourClass.class.getResourceAsStream ("/ config / my.ini"); No dancing with a tambourine is required.

    • In the version indicated by you, you will have to manually read the configuration files and set the corresponding values ​​of the variables, which is IMHO not quite suitable for situations, for example, if SpringBoot and other frameworks with DI and automapping properties are used. - lospejos