Create copy of Bundle and modify it

Hi,
can somebody tell me what the best way is to copy a package from a bundle and to create a new bundle from it? I want to take the package “…simulator.datsource.csv” and create a new bundle by just doing some minor modifications in it.
I hope the question is clear.
Thank you for the answer.
Nils

Hi. just do the getting started and modify this file and build it.
https://openems.github.io/openems.io/openems/latest/edge/build.html

Hi,
thank you for the reply. But actually I don’t want to go through the whole procedure of the “getting started” again all the time I want to create a new bundle. Isn’t there a way in BNDtools to just copy and paste and rename a bundle…that would take only a few seconds. Compared to minutes if I program everything from scratch…
Thanks!

Hi Nils,

what I usually do when creating a new OSGi Bundle for OpenEMS is, I let bndtools create a new “Bnd OSGi Provider/Adapter Bundle” (see “Create a new OSGi Bundle”) and then copy over the following files from some other Bundle:

  • bnd.bnd
  • Config.java
  • [Component].java

The more professional way in future would be to provide templates for bndtools that allow this kind of scaffolding - but we are not there yet… I just created an Issue for it

If you just want to add a new package inside the Simulator-Bundle, you can just copy an existing package. Make sure to add the new package to the bnd.bnd file as a “Private-Package”.

Regards,
Stefan

Hi Stefan,
thank you for the answer. I actually tried to follow the second path that you proposed to copy a package. But something is missing. So here is what I did:

  • Copy package …meter.grid.reacting from the io.openems.edge.simulator bundle and renamed the copy to e.g. “newPack”
  • include the according “Private-Package” in bnd.bnd and saved it

Two build errors are occurring:

  1. Duplicate pid Simulator.GridMeter.Reacting from class io.openems.simulator.newPack.config
  2. Service-component entry can not be located in JAR: OSGI-INF/Simulator.GridMeter.Reacting.xml~

Any propositions?
Nils

Hi,
seems that I solved it myself.
Two renaming steps have to be done:

  1. rename [component].java by rightclicking => refactor => rename
  2. in this java-file the @component declaration needs to be changed

Quite logic!

1 Like