0

I am a newbie to Intellij and have a question about module dependencies.

My project has two modules say A and B. A is dependent on B in the way that it needs to use xmls from B/src/spring. But we don't want to include these xmls in A jar. Instead, we want the jar use xmls from a folder that contains all xml on file system (where is has all xmls in B/src/spring). The reason for this is that we can just update xml files without re-generate jar file. This enables us to avoid redeployment.

However, there is an issue with this method, when I run this project within Intellij, I have to add the xml folder path back into build.gradle file in order to build and run it, otherwise, it will throw xml not found error.

In some other threads, I see I can add the folder that contains xmls into module dependencies (I this way, I don't need to add the xml relative path in build.gradle) but I got same error after I added there.

Is there anyway I can avoid xmls to be added to jar and I also don't need to add the xml folder path back to build.gradle when I run this in Intellij?

Guifan Li
  • 165
  • 2
  • 14
  • If your code loads XMLs from the classpath, the folder with these files needs to be present in classpath, for that it needs to be configured as the dependency. If you you don't want dependencies to be packaged in the jars, adjust the jar build configuration to exclude certain files/folders. This questions lack the code/sample project to get better help. – CrazyCoder Apr 24 '20 at 18:51
  • @CrazyCoder Thanks a lot for you info, but how to exclude certain files/folders in the jar build configuration ? Also, "folder with these files needs to be present in classpath" do you mean they need to be in build.gradle file or in module dependencies, I need to put file/folder paths there ? – Guifan Li Apr 24 '20 at 18:56
  • In build.gradle, module dependencies are imported automatically from Gradle. Excluding from jar via Gradle can be googled in 5 seconds: https://stackoverflow.com/questions/19575474/gradle-how-to-exclude-a-particular-package-from-a-jar. – CrazyCoder Apr 24 '20 at 19:03
  • @CrazyCoder thanks for that and I tried that way before but not ideal. The question is actually simple in this way, how could I somehow provide a folder that xml as a classpath in Intellij without adding it to build.gradle? – Guifan Li Apr 24 '20 at 19:15
  • You can't do that as IntelliJ IDEA imports the configuration from Gradle automatically. All the changes you make manually to the IDE project structure would be discarded on the next Gradle project reimport. It even shows you a warning about that if you try to modify the dependencies in the Gradle or Maven managed projects. – CrazyCoder Apr 24 '20 at 19:16
  • @CrazyCoder In this case, I guess I have to exclude all the xmls from the jar. Thanks for that! – Guifan Li Apr 24 '20 at 20:37

0 Answers0