-
Notifications
You must be signed in to change notification settings - Fork 100
Description
When a project is built using 'mvn install' then CoreOptions.mavenBundle() can be used to provision its bundles from the local maven repository where it was installed. However, in some circumstances the bundles are not installed, e.g. when run via 'mvn verify', in which case mavenBundle cannot find them. In these cases it would be useful to have a utility method such as a CoreOptions.projectBundle() method that will do the job.
Here is a very basic implementation of the idea:
public static Option projectBundle(String module, String groupId, String artifactId) {
String version = MavenUtils.getArtifactVersion(groupId, artifactId);
String url = OSGiContainerIT.class.getResource("/") + "../../../"
+ module + "/target/" + artifactId + "-" + version + ".jar";
return bundle(url);
}
though it should probably be more robust... one option I thought of is to have the same signature as mavenBundle, i.e. accept just the groupId and artifactId, then find the project root dir (topmost dir with pom?), and recurse through all the subdirectories to find a "target" folder under which a jar with the constructed name exists and then use it.
There are various ways to go about this, but whatever is chosen, it would be quite useful and simple to add such a utility to the built-in CoreOptions rather than everyone re-implementing it on their own (I know I'm not the first to do this...)