Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for installing bundles into the Karaf system directory [PAXEXAM-800] #893

Open
ops4j-issues opened this issue Dec 8, 2016 · 2 comments
Labels

Comments

@ops4j-issues
Copy link

S created PAXEXAM-800

Problem:
I need to run unit tests inside the karaf container. I am able to generate my manifest and DS files before the test phase and want to include target/classes using the include assembly protocol; That bundle needs to be loaded during boot, and that cannot be specified using the current Karaf options. It important that I run my tests before installing my artifact locally, as other Karaf runtimes on my machine are watching the local repo and would inadvertently install an untested bundle.

Solution:
I recently implemented a Karaf option that allows installing bundles into the system directory while also adding an entry to startup.properties. Basically, you can use the standard karaf feature, install pax-url-assembly et al during boot, and then wrap target/classes.

Documentation:
Here is the new option in action

        Option[] myOptions = options(

                karafDistributionConfiguration()
                        .frameworkUrl(karafUrl)
                        .karafVersion(version)
                        .useDeployFolder(false)
                        .unpackDirectory(new File("target/pax")),

                systemProperty("-Djava.protocol.handler.pkgs=org.ops4j.pax.url"),
                systemBundle("org.ops4j.pax.url", "pax-url-wrap", "2.4.7"),
                systemBundle("org.ops4j.base", "ops4j-base-net", "1.5.0"),
                ...

In doing so, this now works in the Karaf forked container.

     bundle("assembly:target/classes"),

There is also an overloaded method that allows specifying maven coordinates and a local file. This allows the test code to use a local lib directory.

     systemBundle("org.ops4j.base", "ops4j-base-net", "1.5.0", new File(pathToMyArtifact))

Votes: 0, Watches: 1

@ops4j-issues
Copy link
Author

S commented

#53

@rhierlmeier
Copy link

Any plans to merge this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants