Skip to content

Add core option for provisioning bundle directly from project module target directory #1025

@amichair

Description

@amichair

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...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions