custom jar contents for executable jar built with IntelliJ & maven -
The person for whom I am creating an executable JAR file wants to do all the external libraries separately in
 lib /     / code> directory Which will be in its current working directory when it runs my jar. They also said that I want to extract the  log4j.xml  and  config.properties  from the jar so that they can edit their values using IntelliJ and maven How to make a jar with a manifest like this?    
  This is the help of some  Maven  plugins.   Use  maven-dependency-plugin  to get all  dependency  in a separate folder. This example puts them in the  target / lib  folder.    & lt; Plugin & gt; & Lt; Group & gt; Org.apache.maven.plugins & lt; / Group & gt; & Lt; ArtifactId & gt; Maven-dependency-plugin & lt; / ArtifactId> & Lt; Version & gt; 2.5.1 & lt; / Edition & gt; & Lt; Hanging & gt; & Lt; Execution & gt; & Lt; ID & gt; Copy-dependence & lt; / Id & gt; & Lt; Step & gt; Package & lt; / Step & gt; & Lt; Goals & gt; & Lt; Goal & gt; Copy-dependence & lt; / Target & gt; & Lt; / Targets & gt; & Lt; Configuration & gt; & Lt; OutputDirectory & gt; $ {Project.build.directory} / lib / & lt; / OutputDirectory & gt; & Lt; / Configuration & gt; & Lt; / Execution & gt; & Lt; / Hanging & gt; & Lt; / Plugin & gt;  maven-resources-plugin       
 and specify the  resources  in a separate folder Code> & lt; Plugin & gt; & Lt; ArtifactId & gt; Maven-Resource-Plugin & lt; / ArtifactId> & Lt; Version & gt; 2.6 & lt; / Edition & gt; & Lt; Hanging & gt; & Lt; Execution & gt; & Lt; ID & gt; Copy-Resource & lt; / Id & gt; & Lt; Step & gt; Package & lt; / Step & gt; & Lt; Goals & gt; & Lt; Goal & gt; Copy-Resource & lt; / Target & gt; & Lt; / Targets & gt; & Lt; Configuration & gt; & Lt; OutputDirectory & gt; $ {Project.build.directory} / conf & lt; / OutputDirectory & gt; & Lt; Resources & gt; & Lt; Resources & gt; & Lt; Directory & gt; src / home / resources / lt; / Directory & gt; & Lt; Included & gt; & Lt; Included & gt; log4j.xml & lt; / Include & gt; & Lt; Included & gt; config.properties & lt; / Include & gt; & Lt; / Include & gt; & Lt; / Resources & gt; & Lt; / Resources & gt; & Lt; / Configuration & gt; & Lt; / Execution & gt; & Lt; / Hanging & gt; & Lt; / Plugin & gt;    Then in the end, you need to use  maven-jar-plugin  to do the following:   -   
-  Refer to the resources in the config folder in your JAR MANIFEST    
-   Something like this should be done:     & lt; Plugin & gt; & Lt; Group & gt; Org.apache.maven.plugins & lt; / Group & gt; & Lt; ArtifactId & gt; Maven-Jar-plugin & lt; / ArtifactId> & Lt; Version & gt; 2.4 & lt; / Edition & gt; & Lt; Hanging & gt; & Lt; Execution & gt; & Lt; Step & gt; Package & lt; / Step & gt; & Lt; Goals & gt; & Lt; Goal & gt; Jar & lt; / Target & gt; & Lt; / Targets & gt; & Lt; Configuration & gt; & Lt; Collections & gt; & Lt; Appearance & gt; & Lt; AddClasspath & gt; True & lt; / addClasspath & gt; & Lt; MainClass & gt; foo.bar.Main & lt; / MainClass & gt; & Lt; classpathPrefix & gt; lib / & lt; / classpathPrefix & gt; & Lt; / Reveal & gt; & Lt; ManifestEntries & gt; & Lt; Classroom & gt; conf / & lt; / Class-paths & gt; & Lt; / ManifestEntries & gt; & Lt; / Collection & gt; & Lt; Classifier & gt; Jar-un-resources & lt; / Classifier & gt; & Lt; Exclude & gt; & Lt; To exit & gt; log4j.properties & lt; / Exclude & gt; & Lt; To exit & gt; config.properties & lt; / Exclude & gt; & Lt; / Not included & gt; & Lt; / Configuration & gt; & Lt; / Execution & gt; & Lt; / Hanging & gt; & Lt; / Plugin & gt;    Hope this helps,    will   
 
 
 
 
Comments
Post a Comment