1

We have a project which we build with gradle. We use IntelliJ as our development environment. We have some resources we want to keep outside the JAR and so we have put them in the src/dist-folder. This works fine when running the application from the command line, but not so good when we want to debug from IntelliJ. We could put a runtime-dependency to src/dist, but then we end up with files inside our lib-folder in the generated ZIP file and that's not what we would like to have.

Bottom line: how can we keep some resources outside the JAR (in src/dist) and also on the classpath of IntelliJ (as generated by Gradle; I don't want to have to add things manually to the IntelliJ classpath). The directory structure in the resulting zip should be something like:

root
  |
  |- config/*
  |- css/*
  |- lib/*

It seems that this question describes a similar problem, but the solution in addition #4 still mentions that no solution was found to correctly get the resources on the classpath of IntelliJ: Gradle build file with conf folder with properties not in jar but on classpath

Pieter
  • 3,339
  • 5
  • 30
  • 63
  • Did you consider using the conditions in the build script so that you can handle it differently for IntelliJ IDEA and for the command line? Here is the expression that you can use in the condition to know that the script is evaluated from the IDE: `System.getProperty('idea.active')`. – CrazyCoder Aug 23 '17 at 13:50

1 Answers1

0

The solution I've used in a similar situation is to:

  1. Use the Idea plugin in gradle rather than relying on the IntelliJ support.
  2. Once that is working you can tweak the source path that IntelliJ uses in the gradle file itself
matt helliwell
  • 2,574
  • 16
  • 24