0

My target directory has main sub-folders and I don't want those sub-folders be included in my package, only their contents (folders and files they consist of).

For example, this is my target folder:

targetFolder
-subfolder1
-subfolder2

Currently, I am using Maven-Jar-Plugin but I don't know how I will be able to package my jar as structured below.

from subfolder1, include only base/**/*files1.*
from subfolder2, include only base/**/*files2.*

For that one, i tried doing this but it did not result to a jar structure that I want.

<include>subfolder1/base/**/*files1.*</include>
<include>subfolder2/base/**/*files2.*</include>

This is considering that both folders have similar structure

By doing so, the result jar when opened would look like:

subfolder1
- -base
- - -sub1
- - - -sub2
- - - - -sub3
- - - - - -subfolder1files1.class
subfolder2
- -base
- - -sub1
- - - -sub2
- - - - -sub3
- - - - - -subfolder2files2.class

I want my jar package to look like this:

base
-sub1
- -sub2
- - -sub3
- - - -subfolder1files1.class
- - - -subfolder2files2.class

This is just an example but I hope I have shown the situation of my target folder where I have plenty sub-folders and I have filters to include in the jar package for each of the target sub-folders.

banana
  • 23
  • 7
  • Are those sub folders java packages? If yes it does not make sense to only include their content cause a package is an identification where to find a class...I assume you have those folders under `src/main/java/...`? Or do you have them under `src/main/resources/...`? – khmarbaise Nov 10 '16 at 04:31
  • contents are from a target folder which was generated after the java files are compiled. @khmarbaise – banana Nov 10 '16 at 06:20
  • And why do you need to change the structure of a resulting jar file? What is the purpose of that? – khmarbaise Nov 10 '16 at 06:45
  • some parts of the package are only generated. They were not physically in my src/main, just generated. Also, in my actual project, there needs to be a number of jars that i need to create in one module which has their own contents. @khmarbaise – banana Nov 10 '16 at 09:16
  • This means you should create a saparate maven module which contains the generated code and another which contains the manually created parts... – khmarbaise Nov 10 '16 at 09:33
  • Why did you delete this question only to repost it? I'm pretty sure I have seen this exact same question, and commented on it... And the question is still a bit unclear but having 2 modules sounds like your real solution here. – Tunaki Nov 10 '16 at 17:36
  • @Tunaki, i don't know haha i was thinking my post will get noticed again when i repost it. Haha – banana Nov 11 '16 at 00:20

0 Answers0