One liner for generating OSGi fragment export


When developing an OSGI plugin, you often (always) need to generate an OSGi "fragment" which takes the place of manually having to change the osgi-exports.conf line by line.

Below is a quick hack to build a list of all the imported packages that are used in your OSGi plugin.  This should be be run from the command line in the root of your OSGi plugin


grep -h -R "^import " * | grep -v "^import java." | sed  's/^import//g' | awk 'BEGIN{FS="."}{for (i=1; i<NF; i++) printf $i"."}' |tr "[:space:]" '\n'  | uniq | sed  's/^/ /g'|sed  's/\.$/,/g'