build - Best practice for Maven library -


i building jpa library can consumed in other projects. best approach publishing same? should publish fat jar dependencies or publish classes?

kindly recommend build plugin building , publishing common utilities or libraries

the short: never ever publish fat jar. library should have pom file declare libraries compile/runtime dependencies. there no difference between publishing jpa or other library type. use default maven/gradle publish mechanism

the longer: project's pom file should list required runtime dependencies library, when project include jar file dependency transitive dependencies automatically. there vital difference between , fat jar. if library requires guava version 16, , include in project have use version 20 of guava, maven/gradle lets select version want use (or can have both bad idea). when start including other peoples code inside jar, loose posibility, fat jar contains specific version of 3rd party libraries determined when build library. have seen several methodnotfounderror because included old version of library inside jar. during development work because have new version of library, , first in classpath, @ runtime fat jar first, , old versions of class shadowed newer version.

it important understand when jvm load jars folder, instance in webapp (web-inf/lib) cannot control order of jar files in classpath, why having fat jars or multiple versions of same library bad idea. possible 2 machines can read same folder content in different order, because default sort order file system dependent.

best of luck


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -