You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by yuri <ya...@b-logic.by> on 2020/01/31 14:51:44 UTC
Does Cave work correctly with snapshots?
Hi!
Do Karaf 4.2.7 and Cave 4.2.1 work correctly with snapshot artifacts?
I've built a bundle "hello-bundle-1.0.BUILD-SNAPSHOT.jar", wrapped it in a
feature "hello-feature-1.0.BUILD-features.xml" and packed them in a kar
file.
Then i've exploded the kar file:
POST http://localhost:8181/cave/deployer/api/explode
url: file:/repo/caveRepo/hello-feature-1.0.BUILD-SNAPSHOT.kar
repository:
file:///dev/karaf/xxx/apache-karaf-4.2.7/data/cave/repository/caveRepo
then i've added feature repository to karaf and installed the feature, which
resulted in exception:
org.apache.karaf.features.internal.util.MultiException: Error:
Error downloading
mvn:my.test.project/hello-bundle/1.0.BUILD-SNAPSHOT
at
org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader.<init>(MavenDownloadManager.java:91)
...
Suppressed:
shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find
artifact my.test.project:hello-bundle:jar:1.0.BUILD-SNAPSHOT in
scmap-release (http://localhost:8181/repo/caveRepo/)
...
Cave repository contains this artifacts in
"my/test/project/hello-bundle/1.0.BUILD-SNAPSHOT/" directory:
resolver-status.properties
maven-metadata-caveRepo.xml.sha1
maven-metadata-caveRepo.xml
maven-metadata.xml.sha1
maven-metadata.xml.md5
maven-metadata.xml
hello-bundle-1.0.BUILD-20200131.141800-2-local.xml.sha1
hello-bundle-1.0.BUILD-20200131.141800-2-local.xml.md5
hello-bundle-1.0.BUILD-20200131.141800-2-local.xml
hello-bundle-1.0.BUILD-20200131.141800-1-SNAPSHOT.jar.sha1
hello-bundle-1.0.BUILD-20200131.141800-1-SNAPSHOT.jar.md5
hello-bundle-1.0.BUILD-20200131.141800-1-SNAPSHOT.jar
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
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
Re: Does Cave work correctly with snapshots?
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
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>.
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
Re: Does Cave work correctly with snapshots?
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
Do you have @snapshot on the repo in pax.url.mvn.cfg file ?
Regards
JB
On 31/01/2020 16:30, yuri wrote:
> If i manually copy the file
> "hello-bundle-1.0.BUILD-20200131.141800-1-SNAPSHOT.jar" and rename it to
> "hello-bundle-1.0.BUILD-SNAPSHOT.jar" in the cave repository, everything
> will work.
>
> It seems to me that when cave explodes the kar, it modifies the name of the
> artifact with timestamp and it's OK, but karaf searches for the name without
> timestamp... How can i make karaf to search for the artifact version with
> timestamp?
>
>
>
> --
> 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>.
If i manually copy the file
"hello-bundle-1.0.BUILD-20200131.141800-1-SNAPSHOT.jar" and rename it to
"hello-bundle-1.0.BUILD-SNAPSHOT.jar" in the cave repository, everything
will work.
It seems to me that when cave explodes the kar, it modifies the name of the
artifact with timestamp and it's OK, but karaf searches for the name without
timestamp... How can i make karaf to search for the artifact version with
timestamp?
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Re: Does Cave work correctly with snapshots?
Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,
That's not directly related to Cave, but from Maven.
For instance, if you take a look on
https://repository.apache.org/content/groups/snapshots/org/apache/karaf/apache-karaf/4.2.9-SNAPSHOT/
(powered by Nexus)
you will also see the timestamp for the SNAPSHOT.
So, it's exactly the same.
Does it work with you use 1.0-SNAPSHOT for instance ?
Regards
JB
On 31/01/2020 15:51, yuri wrote:
> Hi!
>
> Do Karaf 4.2.7 and Cave 4.2.1 work correctly with snapshot artifacts?
>
> I've built a bundle "hello-bundle-1.0.BUILD-SNAPSHOT.jar", wrapped it in a
> feature "hello-feature-1.0.BUILD-features.xml" and packed them in a kar
> file.
>
> Then i've exploded the kar file:
>
> POST http://localhost:8181/cave/deployer/api/explode
> url: file:/repo/caveRepo/hello-feature-1.0.BUILD-SNAPSHOT.kar
> repository:
> file:///dev/karaf/xxx/apache-karaf-4.2.7/data/cave/repository/caveRepo
>
> then i've added feature repository to karaf and installed the feature, which
> resulted in exception:
>
> org.apache.karaf.features.internal.util.MultiException: Error:
> Error downloading
> mvn:my.test.project/hello-bundle/1.0.BUILD-SNAPSHOT
> at
> org.apache.karaf.features.internal.download.impl.MavenDownloadManager$MavenDownloader.<init>(MavenDownloadManager.java:91)
> ...
> Suppressed:
> shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find
> artifact my.test.project:hello-bundle:jar:1.0.BUILD-SNAPSHOT in
> scmap-release (http://localhost:8181/repo/caveRepo/)
> ...
>
> Cave repository contains this artifacts in
> "my/test/project/hello-bundle/1.0.BUILD-SNAPSHOT/" directory:
>
> resolver-status.properties
> maven-metadata-caveRepo.xml.sha1
> maven-metadata-caveRepo.xml
> maven-metadata.xml.sha1
> maven-metadata.xml.md5
> maven-metadata.xml
> hello-bundle-1.0.BUILD-20200131.141800-2-local.xml.sha1
> hello-bundle-1.0.BUILD-20200131.141800-2-local.xml.md5
> hello-bundle-1.0.BUILD-20200131.141800-2-local.xml
> hello-bundle-1.0.BUILD-20200131.141800-1-SNAPSHOT.jar.sha1
> hello-bundle-1.0.BUILD-20200131.141800-1-SNAPSHOT.jar.md5
> hello-bundle-1.0.BUILD-20200131.141800-1-SNAPSHOT.jar
>
>
>
> --
> 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