karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Grzegorz Grzybek (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-3347) 'LATEST' placeholder is not resolved correctly for descriptors and repositories
Date Fri, 21 Jul 2017 09:43:00 GMT

    [ https://issues.apache.org/jira/browse/KARAF-3347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16096068#comment-16096068
] 

Grzegorz Grzybek commented on KARAF-3347:
-----------------------------------------

I verified the problem and there are 3 places where {{LATEST}} (or {{RELEASE}}) may be used.

h4. {{<descriptor>}} element of karaf-maven-plugin configuration ({{add-features-to-repo}}
goal for Karaf < 4, {{features-add-to-repository}} goal for Karaf >= 4)

I needed tiny little change:
{noformat}
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AbstractFeatureMojo.java
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AbstractFeatureMojo.java
index af311d4..918f0a8 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AbstractFeatureMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/AbstractFeatureMojo.java
@@ -122,7 +122,7 @@ public abstract class AbstractFeatureMojo extends MojoSupport {
         if (includeMvnBasedDescriptors) {
             bundles.add(uri);
         }
-        Features repo = JaxbUtil.unmarshal(translateFromMaven(uri.replaceAll(" ", "%20")),
true);
+        Features repo = JaxbUtil.unmarshal(descriptor.getFile().toURI().toString(), true);
         for (Feature f : repo.getFeature()) {
             featuresMap.put(f.getId(), f);
         }
{noformat}

h4. {{<repository>}} reference in features.xml

I changed your example to (I needed pax-web 6):
{code:xml}
<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,7)">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>
{code}

I had to remove similar reference from standard karaf features, so after starting Karaf, I
had only:
{noformat}
karaf@root()> feature:repo-list
Repository               │ URL
─────────────────────────┼────────────────────────────────────────────────────────────────────
spring-4.2.0-SNAPSHOT    │ mvn:org.apache.karaf.features/spring/4.2.0-SNAPSHOT/xml/features
framework-4.2.0-SNAPSHOT │ mvn:org.apache.karaf.features/framework/4.2.0-SNAPSHOT/xml/features
standard-4.2.0-SNAPSHOT  │ mvn:org.apache.karaf.features/standard/4.2.0-SNAPSHOT/xml/features
{noformat}

Then I did:
{noformat}
karaf@root()> feature:repo-add file:///data/servers/apache-karaf-minimal-4.2.0-SNAPSHOT/x.xml
Adding feature url file:///data/servers/apache-karaf-minimal-4.2.0-SNAPSHOT/x.xml
karaf@root()> feature:repo-list
Repository                       │ URL
─────────────────────────────────┼────────────────────────────────────────────────────────────────────
standard-3.0.2                   │ file:///data/servers/apache-karaf-minimal-4.2.0-SNAPSHOT/x.xml
org.ops4j.pax.web-6.1.0-SNAPSHOT │ mvn:org.ops4j.pax.web/pax-web-features/LATEST/xml/features
spring-4.2.0-SNAPSHOT            │ mvn:org.apache.karaf.features/spring/4.2.0-SNAPSHOT/xml/features
framework-4.2.0-SNAPSHOT         │ mvn:org.apache.karaf.features/framework/4.2.0-SNAPSHOT/xml/features
standard-4.2.0-SNAPSHOT          │ mvn:org.apache.karaf.features/standard/4.2.0-SNAPSHOT/xml/features
karaf@root()> feature:list
Name                      │ Version          │ Required │ State       │ Repository
                      │ Description
──────────────────────────┼──────────────────┼──────────┼─────────────┼──────────────────────────────────┼───────────────────────────────────────────────────
http                      │ 3.0.2            │          │ Uninstalled │ standard-3.0.2
                  │ Implementation of the OSGI HTTP Service
pax-jetty                 │ 9.3.15.v20161220 │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│ Provide Jetty engine support
pax-jetty-http2           │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│ Optional additional feature to run Jetty with SPDY
pax-http-jetty            │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│
pax-http                  │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│ Implementation of the OSGI HTTP Service
pax-http-whiteboard       │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│ Provide HTTP Whiteboard pattern support
pax-war                   │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│ Provide support of a full WebContainer
pax-http-tomcat           │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│ Provide Tomcat support
pax-war-tomcat            │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│
pax-jsf-support           │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│
pax-jsf-resources-support │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│ Provide sharing of resources according to Servlet
undertow                  │ 1.3.25.1         │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│
pax-http-undertow         │ 6.1.0.SNAPSHOT   │          │ Uninstalled │ org.ops4j.pax.web-6.1.0-SNAPSHOT
│
...
{noformat}

As you can see, referenced {{mvn:org.ops4j.pax.web/pax-web-features/LATEST/xml/features}}
was correctly _resolved_ to {{6.1.0.SNAPSHOT}}.

h4. {{<bundle>}} elements in given feature

Similar to your case, it worked for me:
{noformat}
karaf@root()> feature:install -v http/3.0.2
Adding features: http/3.0.2
Changes to perform:
  Region: root
    Bundles to install:
      mvn:javax.mail/mail/1.4.4
      mvn:javax.servlet/javax.servlet-api/3.1.0
      mvn:org.apache.felix/org.apache.felix.metatype/1.1.2
      mvn:org.apache.felix/org.apache.felix.scr/2.0.12
      mvn:org.apache.felix/org.apache.felix.scr.compat/1.0.4
      mvn:org.apache.geronimo.specs/geronimo-jaspic_1.0_spec/1.1
      mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1
      mvn:org.apache.karaf.http/org.apache.karaf.http.command/LATEST
      mvn:org.apache.karaf.http/org.apache.karaf.http.core/LATEST
      mvn:org.apache.karaf.scr/org.apache.karaf.scr.command/4.2.0-SNAPSHOT
      mvn:org.apache.karaf.scr/org.apache.karaf.scr.management/4.2.0-SNAPSHOT
      mvn:org.apache.karaf.scr/org.apache.karaf.scr.state/4.2.0-SNAPSHOT
      mvn:org.apache.xbean/xbean-bundleutils/4.6-SNAPSHOT
      mvn:org.apache.xbean/xbean-finder/4.6-SNAPSHOT
      mvn:org.eclipse.jetty/jetty-client/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-continuation/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-http/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-io/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-jaas/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-jmx/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-jndi/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-plus/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-rewrite/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-security/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-jaspi/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-server/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-servlet/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-servlets/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-util/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-util-ajax/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-webapp/9.3.15.v20161220
      mvn:org.eclipse.jetty/jetty-xml/9.3.15.v20161220
      mvn:org.ow2.asm/asm-all/6.0_ALPHA
      mvn:org.ops4j.pax.web/pax-web-api/6.1.0-SNAPSHOT
      mvn:org.ops4j.pax.web/pax-web-jetty/6.1.0-SNAPSHOT
      mvn:org.ops4j.pax.web/pax-web-runtime/6.1.0-SNAPSHOT
      mvn:org.ops4j.pax.web/pax-web-spi/6.1.0-SNAPSHOT
...
{noformat}

This gave me following bundles:
{noformat}
karaf@root()> la -l|grep http\.                                                       
                                                                                         
                                                      11:36:21
42 │ Active   │  30 │ 4.0.0.SNAPSHOT   │ mvn:org.apache.karaf.http/org.apache.karaf.http.command/LATEST
43 │ Active   │  30 │ 4.2.0.SNAPSHOT   │ mvn:org.apache.karaf.http/org.apache.karaf.http.core/LATEST
51 │ Active   │  30 │ 9.3.15.v20161220 │ mvn:org.eclipse.jetty/jetty-http/9.3.15.v20161220
{noformat}

As you can see, {{mvn:org.apache.karaf.http/org.apache.karaf.http.command/LATEST}} was resolved
to {{4.0.0.SNAPSHOT}} and {{mvn:org.apache.karaf.http/org.apache.karaf.http.core/LATEST}}
to {{4.2.0.SNAPSHOT}}.

Maven metadata downloaded during resolution confirms it's correct:

{noformat}
$ cat ~/.m2/repository/org/apache/karaf/http/org.apache.karaf.http.core/maven-metadata-apache.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>org.apache.karaf.http</groupId>
  <artifactId>org.apache.karaf.http.core</artifactId>
  <versioning>
    <latest>4.2.0-SNAPSHOT</latest>
    <versions>
      <version>3.0.9-SNAPSHOT</version>
      <version>3.1.0-SNAPSHOT</version>
      <version>4.0.0.M4-SNAPSHOT</version>
      <version>4.0.10-SNAPSHOT</version>
      <version>4.1.2-SNAPSHOT</version>
      <version>4.2.0-SNAPSHOT</version>
    </versions>
    <lastUpdated>20170721060713</lastUpdated>
  </versioning>
</metadata>

$ cat ~/.m2/repository/org/apache/karaf/http/org.apache.karaf.http.command/maven-metadata-apache.xml
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>org.apache.karaf.http</groupId>
  <artifactId>org.apache.karaf.http.command</artifactId>
  <versioning>
    <latest>4.0.0-SNAPSHOT</latest>
    <versions>
      <version>3.0.9-SNAPSHOT</version>
      <version>3.1.0-SNAPSHOT</version>
      <version>4.0.0-SNAPSHOT</version>
    </versions>
    <lastUpdated>20161211081626</lastUpdated>
  </versioning>
</metadata>
{noformat}

[~jbonofre], [~gnt], [~chris@die-schneider.net], [~ffang] what do you think about PR that
fixes case #1? https://github.com/apache/karaf/pull/330

[~jbonofre] is this PR still valid? https://github.com/apache/karaf/pull/52

> 'LATEST' placeholder is not resolved correctly for descriptors and repositories
> -------------------------------------------------------------------------------
>
>                 Key: KARAF-3347
>                 URL: https://issues.apache.org/jira/browse/KARAF-3347
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-tooling
>    Affects Versions: 3.0.2
>            Reporter: Achim Finke
>            Assignee: Grzegorz Grzybek
>
> I slightly modified Karaf's standard feature to give you an idea about the configuration
leading to faults (see inline comments).
> {code:xml}
> <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>
> {code}
> {code:xml}
> <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>
> {code}
> 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.
> {code:title=AbstractFeatureMojo.java|borderStyle=solid}
> 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);
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message