简体   繁体   中英

Have maven add dependency to target jar/lib

Is it possible to have maven create a statically linked jar?

I have a specific design pattern I'd like to enforce regarding my JPA entities and the library that depends on them.

In my design pattern I have a library project that provides entity and would like to have a separate project project provide entity-ejb . In this way I would be able to develop an additional distinct project using only the entity classes and non of the JPA implementation.

This works fine in theory and practice with manual classpath resolution. I am however finding maven to be rather frustrating in this regard. I can't seem to add the dependency jar file to the ejb/lib folder using maven.


I have tried using the

  <artifactId>maven-dependency-plugin</artifactId>

to copy the dependancy to the target/classes directory folder. Unfortunately it does not appear this folder is jarred directly.

Thoughts and suggestions are appreciated.

Not 100% sure what you're after exactly, but it sounds like the maven assembly plugin might be what you need. You can provide this plugin with an assembly descriptor (an xml file) that details the type of assembly file (eg a jar, a war, a binary zip, etc.) as well as the exact composition of that file. You can package things in the assembly in any way you like, include/exclude any file, create directory structures, etc.

There's a good description and some practical examples on the linked page that should get you started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM