Maven compile all source files, but include into jar only few of them
I have source folder with more than 500 source files. I need to produce 4 J开发者_StackOverflow中文版ars from this sources. But there is one problem when i try to compile sources needed for my first jar they dont want to compile because, all sources are needed to compile my specific sources.
and here is the question: if i compiled once all my 500 source files with maven how i can split them into several JAR files? i dont need that all my for 4 jar were containing all 500 sources, each JAR must contain only their specific .class files...
With ant it was very easy, u just compile all sources once, and then when creating JAR u just include specified .class files into jar, and no problem... Can some thing similar be done i n MAVEN?
You should split your source code in multiple inter-dependant java projects.
Then, make each project compile to a jar.
I really recommend going Tristans solution but you should also achieve what you want by configurating the maven-jar-plugin to exclude/include the content that you (not) want. This is described here (see How to include/exclude content from jar artifact?).
As you can only build one artifact with one pom.xml (in general) you have to prepare several pom's (or you try the <classifier>
configuration also described on the maven-jar-plugin Usage page (I never used it but it seams to help you to do what you want).
You SHOULD split this jar project into Multi-Module jar project. This will solve your problem and project structure will be much better.
精彩评论