2

I want to know if it is possible to exclude some resources from my maven project to be bundled within the jar file, either using the assembly or shade plugin. Note that I can do this by putting in the build DOM node:

<resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>**</exclude>
            </excludes>
            <filtering>false</filtering>
        </resource>
</resources>

but I'm looking for something else, as this screws up my eclipse setup.

PS:For instance I want to exclude the whole src/main/resources/config folder from the jar and instead copy it in the target folder. To copy I use maven-resource-plugin, but can't exclude it.

Alex Botev
  • 1,369
  • 2
  • 19
  • 34
  • just to be clear, do you mean source or resource? – JamesB Feb 26 '15 at 00:26
  • I mean resources. This is because I want them explicitly to be kept outside of the jar file not inside. – Alex Botev Feb 26 '15 at 00:36
  • I will delete my answer as it applies to source. – JamesB Feb 26 '15 at 00:39
  • Why isn't this made configurable, imho it shouldn't be this hard >. – Alex Botev Feb 26 '15 at 00:44
  • I would go for your solution with the ``````. What do you mean by "screws up your eclipse setup" ? – Nicolas C Feb 26 '15 at 01:05
  • Since eclipse, and IntelliJ for the matter, autodetect the maven setup based on the pom, adding the exclude in the build, makes both of the IDEs to ignore the resources during run time. Although I want the packaged outside of the jar, I do want to run and test the program in the IDE to debug etc. Ignoring the resources makes this impossible. – Alex Botev Feb 26 '15 at 01:19
  • possible duplicate of [In Maven how to exclude resources from the generated jar?](http://stackoverflow.com/questions/4113697/in-maven-how-to-exclude-resources-from-the-generated-jar) – Jeen Broekstra Feb 26 '15 at 03:01
  • Just put your resources into some other folder. – Aleksandr M Feb 26 '15 at 09:14

2 Answers2

2

You could put the excluded resources in src/main/config instead of src/main/resources/config and configure the maven-resources-plugin accordingly. Per convention, the resources directory is for resources which go into the Jar file. It is OK to create your own directories under src/main for unconventional usages.

Michael Koch
  • 1,152
  • 11
  • 17
0

You could use a profile that you activate in your IDE which contains the additional resource folder so that you can run / debug / test with it but they won't be included in a default packaging.

gizmo
  • 11,819
  • 6
  • 44
  • 61