I'm starting with maven and is not all clear what to put in mirror <mirrorOf></mirrorOf>
tag.
What I understood:
1> *
means "everything"
2> !
prepended to a name exclude that name from look-up path
3> central
is used whan mirroring maven central
Now what I want to do is to mirror a repository that is not maven central (teamdev's one in my case), hence I have no idea towards what the field should match: com.teamdev
, jxbrowser
or com.teamdev.jxbrowser
this is what is listed on temadev website as maven repo:
<repository>
<id>com.teamdev</id>
<url>https://europe-maven.pkg.dev/jxbrowser/releases</url>
</repository>
and
<dependency>
<groupId>com.teamdev.jxbrowser</groupId>
<artifactId>jxbrowser-cross-platform</artifactId>
<version>7.21.2</version>
<type>pom</type>
</dependency>
Each artifact stored in some maven remote repository, and to have it as dependency we should include this repository definition to the project pom.xml.
Most artifacts available in Central repository and it's defined per each pom.xml by super-pom.
com.teamdev
On this page temadev website mentioned, that in order to use this dependency:
<dependency>
<groupId>com.teamdev.jxbrowser</groupId>
<artifactId>jxbrowser-cross-platform</artifactId>
<version>7.21.2</version>
<type>pom</type>
</dependency>
you have to add
<repository>
<id>com.teamdev</id>
<url>https://europe-maven.pkg.dev/jxbrowser/releases</url>
</repository>
to your pom.xml <repositories>...</repositories>
.
Adding a mirror
And if you want to specify another location (artifacts download url) for com.teamdev
repository-id, you may specify it in your pom.xml without mirroring.
But if your dependency contains some <repository>
and downloads transitive dependencies from it, you have to add a mirror to specify another url.
in your settings.xml file add:
<settings>
...
<mirrors>
<mirror>
<id>com.teamdev-mirror</id>
<name>com.teamdev Mirror Repository</name>
<url>https://your-repository-url</url>
<mirrorOf>com.teamdev</mirrorOf>
</mirror>
</mirrors>
...
</settings>
is not all clear what to put in mirror tag
<mirrorOf>com.teamdev</mirrorOf>
matches the <id>com.teamdev</id>
in repository definition.
And this artifact jxbrowser-cross-platform
should be available in your https://your-repository-url
mirror with all other dependencies from the original repository.
And you have to refer your settings.xml
file when run maven commands, e.g. if settings.xml
present in the project root:
mvn clean compile -s settings.xml
or see more about settings reference here.