Advertisement
FranzVuttke

xml script fot build "fat jar" java package

Jan 22nd, 2023 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 1.93 KB | None | 0 0
  1. <!--
  2. Source: https://dzone.com/articles/how-build-fat-jar-using
  3.  
  4. to the build.xml file, paste the contents of the build_fat_jar.txt file before
  5.          end tag of the main project </project>
  6.          in line: <property name="store.jar.name" value=""/>
  7.          in the value field, enter the name of the file you want to be generated
  8.          WITHOUT EXTENSION and save
  9.          then go to the Files tab, right click on
  10.          build.xml file and select: Run Target | Other Targets | package-for-store
  11.          ... and done
  12.          compiled .jar package containing all linked libraries
  13.          will be in the /store directory of the main project
  14. -->
  15. <target name="package-for-store" depends="jar">
  16.  
  17.         <!-- Change the value of this property to be the name of your JAR,
  18.             minus the .jar extension. It should not have spaces.
  19.             <property name="store.jar.name" value="MyJarName"/>
  20.        -->
  21.         <property name="store.jar.name" value="SucharOfTheDay_fat"/>
  22.  
  23.  
  24.         <!-- don't edit below this line -->
  25.  
  26.         <property name="store.dir" value="store"/>
  27.         <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
  28.  
  29.         <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
  30.  
  31.         <delete dir="${store.dir}"/>
  32.         <mkdir dir="${store.dir}"/>
  33.  
  34.         <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
  35.             <zipgroupfileset dir="dist" includes="*.jar"/>
  36.             <zipgroupfileset dir="dist/lib" includes="*.jar"/>
  37.  
  38.             <manifest>
  39.                 <attribute name="Main-Class" value="${main.class}"/>
  40.             </manifest>
  41.         </jar>
  42.  
  43.         <zip destfile="${store.jar}">
  44.             <zipfileset src="${store.dir}/temp_final.jar"
  45.            excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
  46.         </zip>
  47.  
  48.         <delete file="${store.dir}/temp_final.jar"/>
  49.  
  50.     </target>  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement