views:

1438

answers:

5
+1  Q: 

Netbeans manifest

Hi there,

Is it possible to add entries to the manifest.mf file of jars generated by netbeans?

to build an osgi bundle for instance.

A: 

in the same dir as the build.xml you can put your manifest.mf file

I'm using Netbeans 6.7.1 Turns out that the build-imp.xml (the actual build script Netbeans uses)

  • doesn't have a target which runs if 'with manifest, without main-class'
  • but it does have one like 'with manifest, with main-class'

So.. make sure you have the project-properties,run,main-Class filled with -anything-

i think that's some undocumented feature :(

this is my manifest content:

Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Bundle-ManifestVersion: 2
Bundle-Name: jinstall
Bundle-SymbolicName: jinstall
Import-Package: ( .... )
Export-Package: ( .... )
Bundle-Activator: ( ..... )
Houtman
Yes, but the problem with that is that netbeans refuses any property it doesn't understand, and it doesn't understand much. All the osgi properties such as Bundle-ManifestVersion or Bundle-Activator are rejected.
Maurice Perry
I don't have that problem in ordinary netbeans 6.7.1 java-project.I can fill in any Bundle-xxxx property in the custom manifest. What happened in my case was that it completely ignored the whole manifest file and created a default manifest.
Houtman
A: 

See this article.

Here it is described how to

  • create own ant targets
  • add manual entries to manifest.mf for the output JAR
  • run custom ant targets from Netbeans
ivan_ivanovich_ivanoff
The referenced article doesn't speak very directly to this question. If you're referring to the custom ant task ... that's not a very good approach to the simple task of adding an entry to the manifest, IMHO.
Kyle W. Cartmell
+1  A: 

Interesting information might be here:

http://wiki.netbeans.org/FaqNoMainClass

java.is.for.desktop
This is the correct answer! Simply create the desired manifest.mf in the project root and append "manifest.file=manifest.mf" to file project.properties. Assuming your project isn't setting any values in the manifest dynamically, that is. If you need to get fancy here, it's time to turn to maven!
Kyle W. Cartmell
A: 

Why not using the a maven project, which worked well for me? E.g. apache felix

See this pluggable Swing example which I created in netbeans.

Karussell
A: 

I have a Java Class Library project with a custom manifest file - perfect for an OSGI bundle. To get this working first edit project.properties and set:

manifest.file=manifest.mf
manifest.available=true

Create your own custom manifest.mf file in the project directory.

(At this point if you try a clean/build you still won't get your custom manifest file - NetBeans will provide its own. This is because the build-impl.xml Ant target "-do-jar-with-libraries-without-manifest" is being called immediately after "-do-jar-with-manifest", overwriting your custom manifest JAR file with a default NetBeans manifest JAR.)

Add a custom target to your build.xml file as follows:

<target name="-do-jar-with-libraries-without-manifest">
    <!-- Inserted to prevent target from running so we can have a custom
         manifest file with a class library project type. -->
</target>

Tested in NetBeans 6.7.1

gazzamop