Apply Maven mirror to archetypes - maven

In my settings.xml, I redirected everything to my own repository by setting
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://dox4453:8084/nexus/content/groups/public</url>
</mirror>
</mirrors>
But when I use the archetype:generate, I get a warning:
[WARNING] Error reading archetype catalog http://repo.maven.apache.org/maven2
Does this mirroring not apply to archetypes? Or is there something that can overwrite the mirror settings?

Related

How can I whitelist my private nexus on maven 3.8?

It seems like maven 3.8 has introduced some kinf of MITM attack protection, doing that it drops all the connections to the private repositories (such as nexus sonatype and so on). Here it is what happens when I try to download dependencies that are hosted into my private repository
And it stays there, waiting forever...
The private repositories are defined into the settings.xml file and everything worked perfectly (with mvn 3.6.3) until maven 3.8.
How can I put such private repositories in the "maven trusted" ones?
Here it is the settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>first-profile</id>
<repositories>
<repository>
<id>my-nexus</id>
<url>http://nexus.mycompany.com:8081/repository/dev/</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>my-nexus</id>
<username>username</username>
<password>password</password>
</server>
</servers>
<activeProfiles>
<activeProfile>first-profile</activeProfile>
</activeProfiles>
</settings>
Overriding the shipped mirror tag from /opt/maven/conf/settings.xml by placing a new variant into the user's settings.xml, only adding local repo ids to be not considered by the mirrorOf rule, worked for me.
Maven 3.8.x
<settings>
<mirrors>
<!-- a copy of /opt/maven/conf/settings.xml, so can override with exception rules -->
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>!my-repo1,!my-repo2,external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
</mirrors>
</settings>

doesnot use the provided mirror in settings.xml

I need to download a dependency "proxy-vole" from maven and it is present on "https://artifacts.alfresco.com/nexus/content/groups/public"
So I have mentioned the above url as mirror in my setting.xml in maven but everytime I run the project from maven ,it tries to download the jar file from other url (mirror 2) where this depency doesnot exists. and i get error.
my setting.xml is :
<mirrors>
<mirror>
<id>maven.alfresco</id>
<mirrorOf>alfresco-public</mirrorOf>
<name>alfresco artifacts repository</name>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>FTRDProxy_central</id>
<mirrorOf>central</mirrorOf>
<name>FTRD Maven Proxy mirroring central (maven 2) repository</name>
<url>url for mirror2</url>
</mirror>
<mirror>
<id>maven.apache</id>
<mirrorOf>maven2</mirrorOf>
<name>Apache Maven Proxy mirroring central (maven 2) repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</mirror>

Maven multiple repositories - jcenter, nexus

I am trying to set up maven with 2 repositories - jcenter & nexus. From nexus, we don't have the ability to proxy to jcenter. Hence I need a set up which can do the following-
If a artifact is found in nexus, download it.
If not found, go to jcenter to download artifact.
With the below settings.xml, it seems like maven only tries to download from central (which is set to bintray here, because its a super set of maven central). How can I tell maven to look in central and nexus?
Note- I have tried <mirrorOf>central, !nexus</mirrorOf>
<mirrors>
<mirror>
<id>bintray</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>nexus</id>
<mirrorOf>!bintray, *</mirrorOf>
<url>http://some/url/goes/here</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
</profile>
</profiles>
I got it working by specifying multiple repo's in my parent pom. multiple repos in settings.xml had no effect on maven.

Override mvn settings.xml in your pom.xml. Define only project specific repos

I have the following in .m2, disabling the default remote repo:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<id>my.mirror</id>
<name>My Mirror</name>
<url>https://repo.maven.apache.org/alwaysfail</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
Now I added this in my project pom.xml
<repositories>
<repository>
<id>myproject.repo</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
But it does not pick up my project specific remote repo and start downloading, what am I doing wrong?
setting.xml allows you to override definitions in pom.xml, not the other way round. If you want to not use the overriding in settings.xml in a particular build, you could prepare another settings file and call it explicitly:
$ mvn install -s /path/to/no-repo-override.xml

Maven doesn't locate dependecies in secondary mirrors

I have a maven project with dependencies to the central repository and several to a local artifactory repository. When I try to run mvn rpm:rpm the dependencies related to the central repository are resolved, but those related to the local repository aren't.
My configuration looks like (schematically):
<mirrors>
<mirror>central</mirror>
</mirrors>
<profiles>
<profile>
<repository>local-repo1</repository>
<repository>local-repo2</repository>
</profile>
</profiles>

Resources