Hi Carsten,
On Tue, 2023-07-04 at 16:06 +0200, Carsten Ziegeler wrote:
> Hi,
>
> I think this falls into the category of a build problem, therefore I
> would solve it with additions to the maven plugin (your second
> option).
>
> I'm not sure which maven plugin adds the current OSGi bundle to the
> feature. But that functionality could maybe be extended to create the
> repository like structure in the target directory. Then the launcher
> just needs to be configured to use that additional directory as a
> repository.
The bundle is not added automatically, it's defined in a feature file,
see [4].
Thinking about it some more, we already have the 'repository' goal for
the slingfeature-maven-plugin. To keep the plug-ins focused I think the
ideal flow would be:
a. slingfeature-maven-plugin creates the complete repository after the
bundle is packaged
b. feature-launcher-maven-plugin launches with the single repository
url set to the above-created repository
b. is something I can add, but unfortunately a. does not seem to work
yet.
When the slingfeature-maven-plugin creates a repository that includes
the project currenly being built, it always looks under target/classes
for it.
The simplest configuration is
<repositories>
<repository>
<embedArtifact>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</embedArtifact>
</repository>
</repositories>
When building, the following error is reported
[ERROR] Failed to execute goal org.apache.sling:slingfeature-maven-
plugin:1.7.0:repository (create-repository) on project
org.apache.sling.servlets.oidc-rp: Execution create-repository of goal
org.apache.sling:slingfeature-maven-plugin:1.7.0:repository failed:
Parameter 'srcFile' is not a file:
/home/robert/sources/apache/sling/whiteboard/org.apache.sling.servlets.
oidc-rp/target/classes
I checked with the maven-dependency-plugin and is able to copy the
project dependency as a jar file after it has been packaged, so it
seems like there is an opportunity to improve things.
Do you think this is something worth fixing in the slingfeature-maven-
plugin? Then the improvement for the feature-launcher-maven-plugin
would make sense and close the gap on this particular usage scenario.
Thanks,
Robert
[4]:
https://github.com/apache/sling-whiteboard/blob/6c7a129f1d59b759727ec7d469107e03fc331670/org.apache.sling.servlets.oidc-rp/src/main/features/main.json#L31-L34
>
> Regards
> Carsten
>
> On 04.07.2023 14:52, Robert Munteanu wrote:
> > Hi,
> >
> > I have a single-module Maven project [1] where I do the following:
> >
> > - build an OSGi bundle
> > - create an aggregated feature composed of the Sling Starter and
> > the
> > local bundle + requirements [2]
> > - start the created aggregate for integration tests using the
> > feature-
> > launcher-maven-plugin [3]
> >
> > This breaks down because when starting the aggregate the bundle is
> > not
> > yet installed in the local repository ( $HOME/.m2/repository ), but
> > it
> > is present in the project directory ( target/$ARTIFACTID.jar ).
> >
> > The feature-launcher-maven-plugin runs the feature-launcher as a
> > child
> > process, so there can be no sharing of classpaths.
> >
> > I'm looking for ideas on how to make this work. I have a couple,
> > but
> > I'm not sure they're the best ones
> >
> > 1. extend the feature launcher to accept
> > groupdId/artifactId/version →
> > URL mappings that will override the default lookup
> >
> > This could be a new command line arguments
> >
> > --
> > artifactOverrides=org.apache.sling:org.apache.sling.servlets.oidc-
> > rp:0.1-SNAPSHOT=target/org.apache.sling.servlets.oidc-rp-0.1-
> > SNAPSHOT.jar
> >
> > 2. add a mechanism to the feature launcher maven plugin to install
> > selected artifacts in a dedicated repository
> >
> > The Maven plugin could
> >
> > - install the jar file in a Maven repository structure under
> > target/feature-launcher-maven-plugin/local-repository
> > - configure the feature launcher to additionally use this artifact
> > url
> >
> > Something I did rule out quite quickly is to install the artifact
> > early
> > on in the local repository ( $HOME/.m2/repository ), because that
> > be
> > inconsistent with the Maven lifecycle.
> >
> > Ideas/comments welcome,
> >
> > Thanks,
> > Robert
> >
> > [1]:
> > https://github.com/apache/sling-whiteboard/blob/master/org.apache.sling.servlets.oidc-rp/pom.xml
> > [2]:
> > https://github.com/apache/sling-whiteboard/blob/e4f3c260813792f9f1d1e2262accdd50c35d6edb/org.apache.sling.servlets.oidc-rp/pom.xml#L84-L115
> > [3]:
> > https://github.com/apache/sling-whiteboard/blob/e4f3c260813792f9f1d1e2262accdd50c35d6edb/org.apache.sling.servlets.oidc-rp/pom.xml#L189-L203
>