Publish to CodeArtifact

Hi,

For a new workspace I’ve created I’m trying to release some bundles to an AWS CodeArtifact repository but the maven-metadata.xml update is rejected as it’s using 1.0.0.SNAPSHOT as a version which CodeArtifact doesn’t seem to recognise as a snapshot version.

The error I get when running gradle release:

error : Release my.bundle.jar, into MavenBndRepository [localRepo=/Users/brampouwelse/.m2/repository, storage=Release, inited=true, redeploy=false], exception Could not store my-project/my.bundle/1.0.0.SNAPSHOT/maven-metadata.xml from /Users/brampouwelse/.m2/repository/my-project/my.bundle/1.0.0.SNAPSHOT/maven-metadata-707F2AA1.xml with TaggedData [tag=null, code=400, modified=Thu Jan 01 01:00:00 CET 1970, url=https://my-codeartifact-repo.d.codeartifact.eu-west-1.amazonaws.com/maven/snapshots/my-project/my.bundle/1.0.0.SNAPSHOT/maven-metadata.xml, state=OTHER, msg=maven-metadata.xml has 'version' field declared as '1.0.0.SNAPSHOT' which is not a SNAPSHOT version.This request is intended only for SNAPSHOT versions]

When consuming a snapshot version from maven bnd automatically changes the version from 1.2.3-SNAPSHOT to 1.2.3.SNAPSHOT, is there a way to get it to do the same but then the other way around when updating?

In an attempt to get it to work I’ve tried overriding the version with the -pom instruction, but results in even stranger behaviour :open_mouth:

What I’ve added:


-pom: groupid=com.example, \
  where=META-INF/maven/pom.xml, \
  version=1.2.3-SNAPSHOT

The artifacts are uploaded to the maven repo using the version from the bundle version, that version is in the pom I can get from the repo as well, the group id is ignored as well.

Below a snippet of the pom as it’s uploaded to the maven repo (that seems to ignore te -pom instruction) and then the pom as it’s in the bundle jar (that does seem to use the -pom instruction).

maven repo pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>my-project</groupId>
  <artifactId>my.bundle</artifactId>
  <version>1.0.0.SNAPSHOT</version>
  <description>my.bundle</description>
  <name>my.bundle</name>

bundle pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>my.bundle</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <description>my.bundle</description>
  <name>my.bundle</name>

I’m still using bnd 5.3.0 and have not yet upgraded to the latest 6.0.0 release.

Hope there is someone here that will come-up with some configuration option I’ve missed :wink:

Cheers,

Bram

Try the following instructions:

-maven-release: pom
-groupid: com.example
-pom: version=${versionmask;===s;${@version}}	

With this the proper pom file will be created and the versionmask macro will correct the Snapshot Version to something maven likes.

Thanks Jurgen,

That seems to do something, now it trips on another error :frowning: that seems to be a case sensitive md5 hash compare in CodeArtifact…

Somehow that was not an issue when I had the other issue :confused:

error : Release my.bundle.jar, into MavenBndRepository [localRepo=/Users/brampouwelse/.m2/repository, storage=Release, inited=true, redeploy=false], exception Could not store com/example/my.bundle/1.0.0-SNAPSHOT/maven-metadata.xml from /Users/brampouwelse/.m2/repository/com/example/my.bundle/1.0.0-SNAPSHOT/maven-metadata-707F2AA1.xml with TaggedData [tag=null, code=400, modified=Thu Jan 01 01:00:00 CET 1970, url=https://my-codeartifact-repo.d.codeartifact.eu-west-1.amazonaws.com/maven/snapshots/com/example/my.bundle/1.0.0-SNAPSHOT/maven-metadata.xml, state=OTHER, msg=Could not publish build '1' of version '1.0.0-SNAPSHOT' because of a content hash mismatch. The 'MD5' content hash of the asset 'my.bundle-1.0.0-20211021.130241-1.pom' is '4ff9a0b81c5e78a7ba7d10c98bd2e9a4' but the value provided in 'my.bundle-1.0.0-20211021.130241-1.pom.md5' is '4FF9A0B81C5E78A7BA7D10C98BD2E9A4']

That seems overly pedantic. I suggest you get the CodeArtifact people to relax this. Nexus accepts uppercase MD5 and SHA1 files.

It is …

For now I have created some way to get around this … Configured bnd to release to a local repo and then publish to the CodeArtifact repo with some help from bash and maven …

for pom in `find generated/release -name '*.pom' `; do \                                                                                                                                                                                                                                                                git:master*
  mvn deploy:deploy-file -DpomFile=${pom} \
    -Dfile=${pom/\.pom/\.jar} \
    -DrepositoryId=snapshots \
    -Durl=https://my-repo.d.codeartifact.eu-west-1.amazonaws.com/maven/snapshots/ \
   ; done