0

I'm using the Typesafe Config library in a Kotlin project built with Gradle 6. How do I tell Gradle that there's a directory (or two, or specific files) with HOCON files that need to be added to the runtime classpath so Config can find them?

(SO is now suggesting that I edit the question to make it clear that the answer in Add resources, config files to your jar using gradle isn't relevant. It's not relevant because there's nothing about jar files in my question.)

James Moore
  • 8,636
  • 5
  • 71
  • 90
  • You put the files under src/main/resources, like all the other classpath resources. https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_project_layout – JB Nizet Dec 29 '19 at 00:30
  • @JBNizet no, since it assumes there's a jar file being generated. That's not the case if you just run your code. – James Moore Dec 29 '19 at 01:06
  • @JBNizet except that files in src/main/resources aren't added to the directories that are on the runtime classpath. By default, the only directory in the classpath that's in your project is build/classes/kotlin/main, and gradle doesn't copy files from src/main/resources to there. – James Moore Dec 29 '19 at 01:09
  • I should think that this is your answer: https://stackoverflow.com/a/38982006/1005481 – barfuin Dec 29 '19 at 06:46
  • Yes, resources end up in the runtime classpath whether you use Gradle to run your code or IntelliJ, and whether or not you create a jar. What makes you think they don't? What are you doing? What do you expect to happen? What happens instead? – JB Nizet Dec 29 '19 at 06:53

0 Answers0