Description
I slightly modified Karaf's standard feature to give you an idea about the configuration leading to faults (see inline comments).
<build> <plugins> <plugin> <groupId>org.apache.karaf.tooling</groupId> <artifactId>karaf-maven-plugin</artifactId> <version>3.0.2</version> <extensions>true</extensions> <executions> <execution> <id>features-add-to-repo</id> <phase>generate-resources</phase> <goals> <goal>features-add-to-repository</goal> </goals> <configuration> <descriptors> <-- LATEST won't work for descriptors.--> <descriptor>mvn:org.apache.karaf.features/standard-mod/LATEST/xml/features</descriptor> </descriptors> <features> <feature>http</feature> </features> </configuration> </execution> </executions> </plugin> </plugins> </build>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="standard-3.0.2"> <!-- LATEST won't work for repositories as artifacts are resolved by Maven but not copied into Target folder (searching for LATEST placeholder instead of the version). --> <repository>mvn:org.ops4j.pax.web/pax-web-features/LATEST/xml/features</repository> <feature name="http" version="3.0.2" description="Implementation of the OSGI HTTP Service" resolver="(obr)"> <feature version="[3.1.2,5)">pax-http</feature> <!-- LATEST will work for bundles (guess this is the same than defining no version) --> <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.core/LATEST</bundle> <bundle start-level="30">mvn:org.apache.karaf.http/org.apache.karaf.http.command/LATEST</bundle> </feature> </features>
I debugged into the Plugin and saw that the version information are already available via the previously resolved descriptor but not taken when building the repoURI.
In a first attempt i adjusted the uri using the descriptor which made 'LATEST' work.
AbstractFeatureMojo.java
protected void retrieveDescriptorsRecursively(String uri, Set<String> bundles, Map<String, Feature> featuresMap) { Artifact descriptor; try { descriptor = resourceToArtifact(uri, true); } catch (MojoExecutionException e) { throw new RuntimeException(e.getMessage(), e); } if (descriptor != null) { // descriptor is resolved via Maven resolver ('latest'-Placeholder is replaced) resolveArtifact(descriptor, remoteRepos); descriptorArtifacts.add(descriptor); // adjust uri with version information from descriptor as URI is not resolved in the process (see subsequent comment) uri = uri.toLowerCase(); uri = uri.replace("/latest/", "/" + descriptor.getBaseVersion() + "/"); } if (includeMvnBasedDescriptors) { bundles.add(uri); } // translateFromMaven-Method just parses URI into the right format, it does not any resolving ('latest'-Placeholder won't be replaced) URI repoURI = URI.create(translateFromMaven(uri.replaceAll(" ", "%20"))); Repository repo = new Repository(repoURI, defaultStartLevel); for (Feature f : repo.getFeatures()) { featuresMap.put(f.getName() + "/" + f.getVersion(), f); } if (resolveDefinedRepositoriesRecursively) { for (String r : repo.getDefinedRepositories()) { retrieveDescriptorsRecursively(r, bundles, featuresMap); } } }
Attachments
Issue Links
- relates to
-
KARAF-5311 NPE in karaf-maven-plugin when specifying descriptor by file url
- Resolved
- links to