I want to consume this snapshot from the staging repo, because it is not released yet (but voting started)
https://repository.apache.org/content/repositories/staging/org/freemarker/freemarker/2.3.33/
Thus it is not available yet here, but soon , once released: https://repository.apache.org/content/repositories/org/freemarker/freemarker/2.3.33/
I have setup my repo like this:
-plugin.6.Central: \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
snapshotUrl=https://repository.apache.org/content/repositories/staging/; \
releaseUrl=https://repo.maven.apache.org/maven2/; \
index=${.}/central.maven; \
readOnly=true; \
name="Maven Central"
In my central.maven
file I am referencing as:
org.freemarker:freemarker:2.3.33
I also tried using a separate repo only for staging (I removed releaseUrl
) and pointed to a central-staging.maven
. But no luck so far.
I started debugging into the code but before spending more time, I thought I’d ask.
Is my use case supported? If yes, how?
Staging repositories are very special. The look identical to a release repository but violate a very fundamental rule, the GAV points to non-final artifacts. This can mess up caching. I.e. it is not a snapshot repository.
In a snapshot repo, the artifacts are named very differently. Each archive, contains a timestamp in its name so you can have multiple versions. The metadata.xml
file provides an index. The Maven repository in bnd will require and use this index for snapshot urls.
So in this case, just move the URL to the releaseUrl
from the snapshotUrl
.
Thanks. As soon as you do it right, it works
Thanks for the hint that releaseUrl
accepts a comma separate list.
I was successful with the following repo and putting both urls in relaseUrl
:
-plugin.6.Central: \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl="https://repo.maven.apache.org/maven2/,https://repository.apache.org/content/repositories/staging/"; \
index=${.}/central.maven; \
readOnly=true; \
name="Maven Central"
But since, I want to have more fine grained control when the maven staging repo is used I ended up with two repo definitions - one for maven central and one for stuff which we want to pull in from staging.
-plugin.6.Central: \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl=https://repo.maven.apache.org/maven2/; \
index=${.}/central.maven; \
readOnly=true; \
name="Maven Central"
-plugin.6.Central.Staging: \
aQute.bnd.repository.maven.provider.MavenBndRepository; \
releaseUrl=https://repository.apache.org/content/repositories/staging/; \
index=${.}/central-staging.maven; \
readOnly=true; \
name="Maven Central Staging"
I prefer the two repos approach, since pulling from maven staging is a very rare case which we only need once every 5 years. So our regular central.maven
should not even try to pull from maven staging.
since your staging repo likely only has a few GAVs, you could also consider putting in a pmvn file …
You should be an expert in this now! -)