Netbeans 7: Why is my edited manifest not enabled?

I have the following goal in my build.xml :

 <target name="-pre-compile"> <property file="build.properties"/> <buildnumber file="build.version"/> <tstamp> <format property="timestamp" pattern="yyyy-MM-dd HH:mm:ss"/> </tstamp> <manifest file="manifest.mf"> <attribute name="MAJOR" value="${version.major}"/> <attribute name="MINOR" value="${version.minor}"/> <attribute name="RELEASE" value="${release}"/> <attribute name="BUILD" value="${build.number}"/> <attribute name="BUILD-DATE" value="${timestamp}"/> <attribute name="PROTOCOL" value="${protocol}"/> <attribute name="APPCODE" value="${appcode}"/> </manifest> </target> 

It works great by opening manifest.mf after Clean and Build inside Netbeans show all of my additional attributes that I added. However, when I open the jar file, I see that it just contains the default stuff:

 Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.2 Created-By: 1.7.0-b147 (Oracle Corporation) 

I had this job perfectly when I had two packages in one project. One package was all the material of the library that I am going to take in other projects, so I decided to split it into another project so that I could build a library jar myself. Now I have this problem. This happens both when compiling the library on my own, and in my other project, which depends on it.

+8
java manifest netbeans ant netbeans-7
source share
7 answers

I fixed it by opening nbproject/project.properties and adding manifest.file=manifest.mf to the end. Just like that.

+4
source share

check this answer here: Is it possible to add a custom manifest to the Java library compiled in Netbeans 6.7.1?

I had the same problem, adding that the problem was solved at the end of my build.xml:

 <target name="-post-jar"> <jar destfile="${dist.jar}" update="true"> <manifest> <attribute name="Manifest-Version" value="1.0" /> <attribute name="Extension-Name" value="polpol" /> <attribute name="Class-Manager" value="org.nlogo.extensions.polpol.Manager" /> <attribute name="NetLogo-Extension-API-Version" value="5.0" /> </manifest> </jar> </target> 
+3
source share

I happen to encounter the same problems as yours and, fortunately, fixed them. Unfortunately, I don’t know what exactly caused the problem, and after comparing the code with my only difference that I actually see is the name of the manifest file in the build.xml file and the event that triggers the task (I used pre init), I have all the capitals and supplement the information about this verde file with the Version.txt file, which is created in the dist-post-jar directory. You can just try to do

manifest file = "manifest.mf"

read

manifest file = "MANIFEST.MF"

Here is a copy of the important parts of my build.xml:

 <property name="project.name" value="VOXManagement" /> <property name="version.num" value="1.1" /> <target name="-pre-init"> <tstamp> <format property="NOW" pattern="yyyy-MM-dd HH:mm:ss z" /> </tstamp> <manifest file="MANIFEST.MF"> <attribute name="Bundle-Name" value="${project.name}" /> <attribute name="Bundle-Version" value="${version.num}" /> <attribute name="Bundle-Date" value="${NOW}" /> <!--<attribute name="Bundle-Revision" value="${svna.version}" />--> <attribute name="Implementation-Title" value="${project.name}" /> <attribute name="Implementation-Version" value="${version.num}" /> </manifest> <echo file="Version.txt">V${version.num}</echo> </target> <target name="-post-jar"> <copy file="Version.txt" todir="dist" overwrite="true"/> <delete file="dist/README.TXT"/> </target> 
+2
source share

You need to use the "update mode".

<manifest file="${manifest.file}" mode="update">

+1
source share

As Tihara already asked, can you have a task that builds a jar? Do you have a manifest = "MANIFEST.MF" in your bank (or something similar) tag / task?

 <target name="jar"> <jar manifest="path-to/MANIFEST.MF" basedir="base dir" destfile="outJarfileName"> </jar> </target> 
+1
source share

When creating Jars, Wars, Ears, a common problem in MANIFEST.MF is

"Manifest version: 1.0 Ant -Version: Apache Ant 1.9.4 Created: from 1.7.0_40-b43 (Oracle Corporation)"

If you want to ignore the Ant -Version Number and created using the filesetmanifest = "mergewithoutmain" parameter.

 <jar destfile="MyJar.jar" basedir="./bin" filesetmanifest="mergewithoutmain" manifest="./src/META-INF/MANIFEST.MF" update="true" > 
0
source share

In Netbeans 7.3.X for .war in build.xml file Use

 <manifest file="${build.web.dir}/META-INF/MANIFEST.MF">...</manifest> 
0
source share

All Articles