You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Jean-Baptiste Onofré <jb...@nanthrax.net> on 2020/02/01 04:57:23 UTC

Re: Does Cave work correctly with snapshots?

Hi,

Weird, it works for me, let me double check my maven/aether config.

Regards
JB

On 01/02/2020 00:06, yuri wrote:
> Yes, i have @snapshot on the repo in pax.url.mvn.cfg file:
> 
>      org.ops4j.pax.url.mvn.repositories= \
>          https://repo1.maven.org/maven2@id=central, \
> 	 http://localhost:8181/repo/caveRepo/@snapshots@id=scmap-release
> 
> Even though karaf still can't find snapshot artifacts after kar was
> exploded, i managed to download the artifact from cave to local repo with
> maven:
>      "mvn dependency:get -Dversion=1.0.BUILD-SNAPSHOT..."
> 
> 
> 
> Another issue: i uploaded snapshot artifact to cave with maven:
> 
>      "mvn deploy:deploy-file -DgroupId=org.springframework
> -DartifactId=spring-core -Dversion=5.2.4.BUILD-SNAPSHOT -Dpackaging=jar
> -Durl=http://localhost:8181/repo/caveRepo
> -Dfile={user.home}/.m2/repository/org/springframework/spring-core/5.2.4.BUILD-SNAPSHOT_tmp/spring-core-5.2.4.BUILD-SNAPSHOT.jar"
> 
> in cave repo i see this files (without timestamp now!):
> 
>      maven-metadata-local.xml
>      maven-metadata-local.xml.md5
>      maven-metadata-local.xml.sha1
>      resolver-status.properties
>      spring-core-5.2.4.BUILD-SNAPSHOT.jar
>      spring-core-5.2.4.BUILD-SNAPSHOT.pom
>      spring-core-5.2.4.BUILD-SNAPSHOT.jar.md5
>      spring-core-5.2.4.BUILD-SNAPSHOT.jar.sha1
>      spring-core-5.2.4.BUILD-SNAPSHOT.pom.md5
>      spring-core-5.2.4.BUILD-SNAPSHOT.pom.sha1
> 
> 
> then i tried to download this artifact from cave to local repo with maven:
> 
>      "mvn dependency:get
> -DremoteRepositories=http://localhost:8181/repo/caveRepo
> -DgroupId=org.springframework -DartifactId=spring-core
> -Dversion=5.2.4.BUILD-SNAPSHOT -Dtransitive=false"
> 
> and it failed:
> 
>      [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on
> project standalone-pom: Couldn't download artifact: Could not find artifact
> org.springframework:spring-core:jar:5.2.4.BUILD-20200131.224831-1 in temp
> (http://localhost:8181/repo/caveRepo)
> ...
>      [ERROR] from the specified remote repositories:
>      [ERROR]   central (https://repo.maven.apache.org/maven2, releases=true,
> snapshots=false),
>      [ERROR]   temp (http://localhost:8181/repo/caveRepo, releases=true,
> snapshots=true)
> ...
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Does Cave work correctly with snapshots?

Posted by yuri <ya...@b-logic.by>.
I've debugged a little and found out that
"org.eclipse.aether.internal.impl.SimpleLocalRepositoryManager.getPathForArtifact(
Artifact artifact, boolean local )" builds a path to the destination file in
the local maven repo like this (i've commented my values here):

        StringBuilder path = new StringBuilder( 128 );

        path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/'
); //GroupId=org\apache\karaf\examples

        path.append( artifact.getArtifactId() ).append( '/' );
//ArtifactId=karaf-bundle-example-client

        path.append( artifact.getBaseVersion() ).append( '/' );
//BaseVersion=4.3.0-SNAPSHOT

        path.append( artifact.getArtifactId() ).append( '-' );
//ArtifactId=karaf-bundle-example-client
        if ( local )
        {
            path.append( artifact.getBaseVersion() );
//BaseVersion=4.3.0-SNAPSHOT
        }
        else
        {
            path.append( artifact.getVersion() );
        }

        if ( artifact.getClassifier().length() > 0 )
        {
            path.append( '-' ).append( artifact.getClassifier() );
//Classifier=SNAPSHOT
        }

        if ( artifact.getExtension().length() > 0 )
        {
            path.append( '.' ).append( artifact.getExtension() );
//Extension=jar
        }

and the path results to:
"org\apache\karaf\examples/karaf-bundle-example-client/4.3.0-SNAPSHOT/karaf-bundle-example-client-4.3.0-SNAPSHOT-SNAPSHOT.jar".

In the local maven repo after kar explosion i see the files:

       _remote.repositories
       karaf-bundle-example-client-4.3.0-SNAPSHOT-local.xml
!!!    karaf-bundle-example-client-4.3.0-SNAPSHOT-SNAPSHOT.jar
       maven-metadata-local.xml
       maven-metadata-sdeployer.xml
       maven-metadata-sdeployer.xml.sha1
       resolver-status.properties

So i guess the problem is with "artifact.getBaseVersion()" implementation
which works correctly only if there is a timestamp in the artifact's
snapshot version.
Or if the artifact name in the local maven repo should contain timestamp,
the implementation of the
"org.apache.maven.repository.internal.LocalSnapshotMetadataGenerator.transformArtifact(
Artifact artifact )" method should be changed similar to the one in
"org.apache.maven.repository.internal.RemoteSnapshotMetadataGenerator" i
guess.

And one more thing. As you might notice, in
"org.apache.karaf.cave.deployer.service.DeployerServiceImpl.browseKar(...)"
method we resolve groupId by substring-ing the path to .jar file and
replacing slashes with dots:
       path = path.replace('/', '.');
but windows paths contain backslashes and groupIds on my machine look like
this:
       org\apache\karaf\examples



--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html