How to build a jar using an own MANIFEST.MF in Eclipse

I have a custom MANIFEST.MF in my java-project in Eclipse.

When exporting the project to a jar, I choose

Use existing manifest from workspace

Extracting the .jar shows that eclipse generated its own manifest.

My manifest:

Manifest-Version: 1.0 
Main-Class: de.somehow.tagPDF.Main
Class-Path: lib/iText-5.0.2.jar;lib/jxl.jar;lib/jai_codec.jar;lib/jai_core.jar

How can I fix this?

Answers


You can make use of a build.xml to build the jar file for you.

Then you just run the build.xml as a Ant task.

See

If you want the build.xml to run automatically every time you build your Eclipse project, you can add it to the Builders list.

See

Below is a sample build.xml where a custom manifest is used:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="Example" default="run_build">

    <property name="guiJar" value="../../Library/<jar-name>.jar"></property>

    <target name="run_build" depends="delete_old_jar,create_dirs,create_manifest,copy_all_class_files,create_jar,delete_temp_dirs">
    </target>

    <target name="delete_old_jar">
        <delete file="${guiJar}">
        </delete>
    </target>

    <target name="create_dirs">
        <mkdir dir="jar_temp" />
        <mkdir dir="jar_temp/META-INF" />
    </target>

    <target name="delete_temp_dirs">
        <delete dir="jar_temp">
        </delete>
    </target>

    <target name="create_manifest">
        <manifest file="jar_temp/META-INF/MANIFEST.MF">
            <attribute name="Manifest-Version" value="1.0" />
            <attribute name="Version" value="1.0.0" />
            <attribute name="Company" value="Value" />
            <attribute name="Project" value="Value" />
            <attribute name="Java-Version" value="${java.version}" />
            <attribute name="Class-Path" value="test.jar" />
                    <attribute name="Main-Class" value="com.Main" />
        </manifest>
    </target>

    <target name="create_jar">
        <jar destfile="${guiJar}" manifest="jar_temp/META-INF/MANIFEST.MF" basedir="jar_temp">
        </jar>
    </target>

    <target name="copy_all_class_files">
        <copy todir="jar_temp">
            <fileset dir="classes">
                <include name="*/**" />
            </fileset>
        </copy>
    </target>
</project>

Need Your Help

How to group Multivalued Value with LINQ?

c# asp.net-mvc linq solr

Im my model I have decleared value from wich I have to group, like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.