8

I have the following target 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 fine, opening manifest.mf after a Clean and Build within Netbeans shows all my extra attributes that I've added. However, when I open my 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 working fine before when I had two packages in one project. The one package was all library stuff that I'm gonna be taking to other projects, so I decided to split it out into another project so I could build the library jar by itself. Now I have this problem. It occurs both when I compile the library on its own as well as my other project that depends on it.

ldam
  • 4,412
  • 6
  • 45
  • 76

7 Answers7

4

I've fixed it by opening nbproject/project.properties and adding manifest.file=manifest.mf to the end. Simple as that.

ldam
  • 4,412
  • 6
  • 45
  • 76
3

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

I had your same problem, adding this at the end of my build.xml solved the issue:

<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>
Community
  • 1
  • 1
user299791
  • 2,021
  • 3
  • 31
  • 57
2

I happen to have encountered the same issues youre having here, and luckly enough have fixed it. Unfortunately I dont know what exactly caused the issue, and after comparing your code to mine, the only difference I see really is the name of the manifest file in your build.xml, and the event which triggers the task (I used pre init). I have all in capitals, and supplement the manifest version info with in the Version.txt file which is created in the dist directory -post-jar. You may just want to try to make

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>
Celio Marcos
  • 129
  • 1
  • 6
Mark W
  • 2,791
  • 1
  • 21
  • 44
  • I tried using caps (on windows where pathnames are case insensitive) and that didn't work, and I tried moving it to -pre-init and that didn't work either. – ldam Mar 06 '13 at 20:26
1

You need to use the "update mode".

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

Jean Waghetti
  • 4,711
  • 1
  • 18
  • 28
  • Didn't work either. Like I said in my OP, if I run clean and build and open the manifest afterwards I can see that the manifest has all my fields in it, but it seems they get removed or my manifest is replaced when the jar-ing takes place. – ldam Mar 09 '13 at 21:47
  • Maybe a new manifest is being created (not updated) before NetBeans script creating the jar. Maybe put your `manifest` task in `-pre-jar` target. – Jean Waghetti Mar 10 '13 at 00:33
  • I'm sure I've tried that too but I will try again later when I get home from work. – ldam Mar 11 '13 at 04:37
1

As Thihara already asked, you may have a task that builds the jar? are you having manifest="MANIFEST.MF" in your create jar(or something similary ) tag/task?

<target name="jar">
        <jar   manifest="path-to/MANIFEST.MF" basedir="base dir" destfile="outJarfileName">
        </jar>
    </target>
dillip
  • 1,782
  • 17
  • 16
  • I haven't edited any of netbeans' tasks or anything, I've just done the usual override of the target in `build.xml`. – ldam Mar 11 '13 at 16:51
0

While Creating Jars,Wars,Ears a common issue in MANIFEST.MF is

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

If you want to Ignore Ant-Version Number and Created by use filesetmanifest="mergewithoutmain" option.

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

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

<manifest file="${build.web.dir}/META-INF/MANIFEST.MF">...</manifest>
ld_raivan
  • 11
  • 1