Java Magazine, July/August 2018
ORACLE COM JAVAMAGAZINE JULY AUGUST 2018 60 libraries If your users work on an application however its not too bad they can simply update all their requires directives and use your library under its new name If they also work on a library things are much more complicated Chances are they released a version of their project that requires your JAR file by its filename and now your newer JAR files cannot fulfill that dependency because your module has a diferent name Even worse if a user transitively depends on your library twice once under each name that user is in serious trouble Defining the automatic modules name Consequently users will be wary of depending on your plain JAR file as a module if you dont set the Automatic Module Name entry in your JAR manifest So once youve made sure your library works well and you dont expect any major refactoring where packages get moved between JAR files if you ship more than one you should pick a module name see the next section for more on that and set the manifest entry With the Maven JAR plugin you could do that as follows plugin groupId org apache maven plugins groupId artifactId maven jar plugin artifactId configuration archive manifestEntries Automatic Module Name name Automatic Module Name manifestEntries archive configuration plugin Just replace name with the actual name As soon as youve done that other modules can start requiring your JAR file as an automatic module under a stable name Make sure you advertise that fact and the chosen module name prominently in your documentation
You must have JavaScript enabled to view digital editions.