1) create a new module in your reactor tree

2) add all the top level dependencies you wish to put in your deployment in
this new module's pom (you CAN refer to other maven modules in the reactor
as expected)

3) add this [1] maven repository since some of what you need is provided by
the yet-to-be-released bnd 3.4.0-RC

4) configure the pom with the following bnd-export-maven-plugin [2]:

    <plugin>
        <groupId>biz.aQute.bnd</groupId>
        <artifactId>bnd-export-maven-plugin</artifactId>
        <version>3.4.0-SNAPSHOT</version>
        <configuration>
            <failOnChanges>false</failOnChanges>
            <bndruns>
                <bndrun>main.bndrun</bndrun>
            </bndruns>
            <bundlesOnly>true</bundlesOnly>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>export</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

5) in `main.bndrun` make sure to populate the property `-runrequires` with
the set of top level bundles your deployment requires which won't
transitively be added purely through resolution of requirements and
capabilities: e.g.

-runrequires: \

osgi.identity;filter:='(osgi.identity=org.apache.aries.cdi.extension.http)',\
  osgi.identity;filter:='(osgi.identity=org.apache.felix.configadmin)',\
  osgi.identity;filter:='(osgi.identity=slf4j.log4j12)'

6) remove the following lines from your main.bndrun:

-standalone:

-plugin.examples.eval = \
 aQute.bnd.repository.maven.pom.provider.BndPomRepository; \
 snapshotUrls=https://oss.sonatype.org/content/repositories/osgi/; \
 releaseUrls=https://repo1.maven.org/maven2/; \
 pom=${.}/pom.xml; \
 name=examples.eval; \
 location=${.}/target/cached.xml

7) execute `mvn bnd-export:export`

8) if resolve fails then you've missed a dependency in the pom, add it and
try 7) again.

All the resolved bundles should be placed in `*${project.build.directory}*`

HTH,
- Ray

[1]
https://bndtools.ci.cloudbees.com/job/bnd.next/599/artifact/dist/bundles/
[2]
https://github.com/bndtools/bnd/tree/master/maven/bnd-export-maven-plugin


On Wed, Jun 21, 2017 at 11:49 AM, Mark Raynsford <list+org.o...@io7m.com>
wrote:

> Hello.
>
> I put together a small project a while back to experiment with various
> aspects of OSGi (such as independent module versioning, and producing
> a runnable distribution zip containing an OSGi framework and a set of
> bundles).
>
> I'm currently using Maven for all of my projects (and have been for
> close to ten years), and am currently using the maven-bundle-plugin
> to produce OSGi bundles.
>
>   https://github.com/io7m/thoth
>
> The com.io7m.thoth.distribution module solely exists to aggregate
> dependencies and to produce a runnable distribution.
>
> I've had various issues creating a runnable distribution of the project,
> the latest of which seems to be that the Assembly plugin can't
> really seem to do what I'm asking it to do:
>
>   https://issues.apache.org/jira/browse/MASSEMBLY-848
>
> Basically, what I'm trying to do is produce a zip file containing a
> specific directory hierarchy. The directory hierarchy contains a set of
> Apache Felix bundles (the framework and service implementations), some
> configuration files, and the bundles that make up the thoth project. I
> don't want to produce a single executable jar; I want to keep all of
> the bundles separate so that they can be easily upgraded individually
> after deployment.
>
> As the subject of the bnd-maven-export-plugin came up a few hours ago,
> I thought I'd try it having never actually used Bnd directly, or any
> of the bnd-* Maven plugins. My thinking is that I can get the export
> plugin to intelligently decide what bundles are needed, to
> intelligently fetch framework bundles, and to dump all of those into a
> single directory. I can then use the Assembly plugin to package them up
> into the directory layout that I need, and won't need to depend on the
> problematic artifact resolution mechanism the Assembly plugin
> apparently uses.
>
> I'm following the enRoute runtime tutorial:
>
>   http://enroute.osgi.org/tutorial_eval/380-run.html
>
> Using a somewhat incomplete main.bndrun file, I have something that I
> think should effectively not do very much:
>
>   https://github.com/io7m/thoth/commit/a9f58c11daeba94f5d79878cd23a68
> bef7955195
>
> In other words, unless I'm misunderstanding the documentation, the
> export plugin should grab some Felix bundles and put them into the
> target directory. It hasn't been asked to do anything else, so it
> shouldn't.
>
> Unfortunately, what actually happens is this:
>
> [INFO] --- bnd-export-maven-plugin:3.3.0:export (default) @
> com.io7m.thoth.distribution --- [INFO] cached
> file:/home/someone/git/com.github/io7m/thoth/com.io7m.
> thoth.distribution/pom.xml
> [INFO] Unlocking url cache
> file:/home/someone/git/com.github/io7m/thoth/com.io7m.
> thoth.distribution/pom.xml
> [INFO] cached
> https://repo1.maven.org/maven2/com/io7m/thoth/com.
> io7m.thoth/1.0.0/com.io7m.thoth-1.0.0.pom
> [INFO] Proxy handlers [] [INFO] No match for
> https://repo1.maven.org/maven2/com/io7m/thoth/com.
> io7m.thoth/1.0.0/com.io7m.thoth-1.0.0.pom,
> handler Server [ match=sonatype-nexus-staging,
> basic=BasicAuthentication
> [password=*, user=io7m],
> https=HttpsVerification [verify=true, certificatesPath=null]] [INFO] No
> match for
> https://repo1.maven.org/maven2/com/io7m/thoth/com.
> io7m.thoth/1.0.0/com.io7m.thoth-1.0.0.pom,
> handler Server [ match=sonatype-nexus-snapshots,
> basic=BasicAuthentication
> [password=*, user=io7m],
> https=HttpsVerification [verify=true, certificatesPath=null]] [INFO]
> set header User-Agent=Bnd [INFO] GET
> https://repo1.maven.org/maven2/com/io7m/thoth/com.
> io7m.thoth/1.0.0/com.io7m.thoth-1.0.0.pom
> [INFO] result TaggedData [tag="1fb066da6a67c7c02962f59b4b8cd1ee",
> code=404, modified=Wed Aug 10 15:08:35 UTC 2016,
> url=https://repo1.maven.org/maven2/com/io7m/thoth/com.
> io7m.thoth/1.0.0/com.io7m.thoth-1.0.0.pom,
> state=NOT_FOUND, msg= 404 Not Found 404 Not Found nginx ] [INFO]
> Unlocking url cache
> https://repo1.maven.org/maven2/com/io7m/thoth/com.
> io7m.thoth/1.0.0/com.io7m.thoth-1.0.0.pom
>
> I'm not sure why the plugin is going out to Maven Central to resolve
> that particular artifact (the parent POM), and this project is unlikely
> to ever be deployed to Maven Central as it's just a toy project for
> experimenting with OSGi.
>
> Can I get Bnd to work with the modules in the current Maven reactor?
>
> M
>
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev
>



-- 
*Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile>
 (@rotty3000)
Senior Software Architect *Liferay, Inc.* <http://www.liferay.com>
 (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org> (@OSGiAlliance)
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to