maven - How to avoid the manifest file being overwritten by proguard -


i'm using several libraries in java application.

in pom.xml proguard maven plugin includes them so:

<inclusion>     <groupid>javafx</groupid>     <artifactid>jfxrt</artifactid>     <library>true</library>     <filter>!meta-inf/**</filter> </inclusion> 

i noticed, when include libraries <library> set true, manifest file gets replaced, allthough specify <filter> libraries. need include them <library> set true, since otherwise of them don't work.

now after building jar, won't start, because manifest doesn't contain path main class more.

i found 2 approaches, solve this. however, both don't work.

first approach:

    <plugin>     <groupid>org.apache.maven.plugins</groupid>     <artifactid>maven-antrun-plugin</artifactid>     <version>1.3</version>     <executions>         <execution>             <phase>install</phase>             <configuration>                 <tasks>                     <echo                         message="adding manifest  ${project.build.directory}/${my.outfilename}.jar" />                     <manifest file="meta-inf/manifest.mf" mode="replace">                         <attribute name="manifest-version" value="1.0" />                         <attribute name="package"                             value="com.xyz.mypackage" />                         <attribute name="main-class" value="mymainclass" />                         <attribute name="version"                             value="${my.version.main}${my.version.sub}" />                     </manifest>                 </tasks>             </configuration>         </execution>     </executions> </plugin> 

nothing happens @ all. i've set <phase> install , deploy. both have no effect.

second approach:

<plugin>     <groupid>org.apache.maven.plugins</groupid>     <artifactid>maven-jar-plugin</artifactid>     <version>2.4</version>     <executions>         <execution>             <phase>deploy</phase>             <configuration>                 <archive>                     <manifestfile>${basedir}/build/manifest.mf</manifestfile>                 </archive>             </configuration>         </execution>     </executions> </plugin> 

this doesn't change anything. -x debug output can't see 1 of plugins ever executed. both <plugin> sections inside <build><plugins></plugins></build>

now i'm stuck, since manually changing manifest file after jar has been built not acceptable in automated build process.

hope can help. thanks!

took me days figure out. it's quite simple though:

in <configuration> section of proguard-maven-plugin add this:

<archive>      <manifest>         <mainclass>mymainclass</mainclass>         <packagename>com.xyz.abc</packagename>     </manifest> </archive> 

this add line in manifest, contains specified main class


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -