How to replace the default launcher of BndTools and change the structure of the export file

I am using BndTools ( http://bndtools.org/ ) to develop an OSGI application. Everything works fine, but I have some things that I would like to change when exporting my application.

I am trying to achieve two things (I think they can be related):

1: replace the default BndTools launcher ( aQute.launcher ) with a regular one (or in .JAR format)

How can I get rid or change the default BndTools launcher (aQute.launcher) to normal?

The only thing I could find out on this topic is here: http://goo.gl/jYliih

Launchers are not embedded in bnd, but the actual launch strategy is parameterized. The launcher is linked to the bnd or bndrun file by putting the JAR in -runpath . A .JAR must have a Launcher-Plugin header to run. If no launcher is found on -runpath , then the built-in biz.aQute.launcher will be used.

The reason is because I need my application to accept args commands and not interfere with aQute starts (like all -run args). On the other hand, I would like to get rid of the batch approach of .bat/.sh launching the application and use one .JAR file to launch the application.

Is it possible?

2: Set up exported file structure

By default, BndTools creates this file structure when exporting the application:

jar/ → This is the jar OSGI package folder

aQute/ → BndTools launcher by default (Launcher.class inside)

META-INF/ → Why is there a META-INF folder here? This is not a jar

launcher.properties → Launch Properties

start.sh → Launches Launcher.class from these batch files.

start.bat / Where is the advantage of this over JAR?

Basically I would like to delete aQute , META-INF and start.* Files and add the bin folder for the binaries.

This can be achieved using the "Ant", "Maven" or "Gridle" script. But I can just create a “BndTools Project” or “Gradle Project” without BndTools support. I installed the "BndTools Gradle" plugin, but I haven’t found any useful documentation anywhere on this subject.

Hope someone can help me or point me in the right direction. Hey.

+5
source share
1 answer

(This question was also asked in the bndtools group list)

I am a little confused, because the wishes that seem to be provided to you. You can export the bndrun file to a single executable JAR. In bndtools, you can access command line arguments by getting the Object service and then the launcher.arguments service property. This is the source string [] specified in the main launch method.

 @Reference(target="(launcher.arguments=*)") void setArgs( Map<String,Object> args ) { … = (String[]) args.get( "launcher.arguments"; } 

An exported JAR is an executable JAR. JPM can easily be converted to a local executable.

 jpm install -n mycode mycode.jar 

You can install jpm from http://jpm4j.org/#!/md/install .

Robert: Thank you, Peter, the code snippet of the argument on the command line is what I need.

About the folder structure:

I need my update packages. If I insert all the bundles inside the .Jar, then they cannot be updated. I just need to pack Launcher when you have the packages.

BndTools has two export options. 1, where you can embed the entire launcher and all packages within the same JAR. Or option 2 is to have packages inside the lib directory and run them using shell scripts (start.bat, start.sh). I am looking for a solution for a <script shell.

Peter: Even though the packages are inside, you can still update them until you clear the Frameworks storage area. You can easily enable File Install, for example, and download packages from a directory or use another Apache Ace management agent.

From my point of view, the current JAR export (I really do not like exporting directories at all, it's dirty) is just as good as it is. It has a very good release model, only one file that is easy to modify and update. Using JPM, you can install it on any system.

So, if you want something else, you will have to create your own exporter ...

+3
source

Source: https://habr.com/ru/post/1243710/


All Articles