1

I found my self with the "blocked mirror" error when building the maven project, we have a repository that works only on the local network so it does not have https, just a simple server (JFrog artificatory).

I can deploy to it, but I can't download the dependency in any other machine cause it always block the mirror.

Looking into it, one should be able to unblock the http with the mirror settings, either in the .m2 settings file or in the prject /.mvn/local-settings.xml

But I simply can't make it work. Either of them just keep spiting "blocked mirror"...

 Blocked mirror for repositories: [repo1 (http://192.168.90.87:8082/artifactory/repo1, default, releases+snapshots)] -> [Help 1]

project folder

project
  | -- .mvn
         | -- local-settings.xml
         | -- maven.config
  ...
  | -- pom.xml

maven.config

--settings ./.mvn/local-settings.xml

local-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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
    <mirrors>
        <mirror>
            <id>repo1-mirror/id>
            <mirrorOf>repo1</mirrorOf>
            <url>http://192.168.90.87:8082/artifactory/repo1</url>
            <blocked>false</blocked>
        </mirror>
    </mirrors>
</settings>

the url and repository id are ok cause I can deploy to it. If I move the local-settings content to the settings.xml in the {user}.m2/repository it changes nothing.

    <distributionManagement>
        <repository>
            <id>repo1</id>
            <name>repo1 deve test</name>
            <url>http://192.168.90.87:8082/artifactory/repo1/</url>
        </repository>
    </distributionManagement>

I'm running maven from the windows prompt with this line:

call R:\maven\bin\mvn --f R:\WorkSpace\App\project\pom.xml clean package

I have tried with -f and the folder but than the maven.config never find the local-settings

call R:\maven\bin\mvn -f R:\WorkSpace\App\project clean package

I'm using a fresh maven version that I have just downloaded from: apache-maven-3.8.1-bin

References: Unblock maven mirror

TylerH
  • 20,799
  • 66
  • 75
  • 101
P. Waksman
  • 979
  • 7
  • 21

1 Answers1

0

Well, I found, on windows, that if you run

R:
call R:\maven\bin\mvn --f R:\WorkSpace\App\project\pom.xml clean package

from some folder, for instance the root R:, it completely ignore the .mvn/maven.config

using -f and pointg to the folder

call R:\maven\bin\mvn -f R:\WorkSpace\App\project clean package

give an error cause it doesn't use the provided folder, for some odd reason (maybe a bug...), it try to find

r:\.mvn\local-settings.xml

which is odd, it founded the maven.config in the correctly folder, it should use the provided folder from -f path to find the settings reference. So for this case, what I had to do, is just first, move the execution path to the project folder, in this case

#move to project folder
r:
cd R:\WorkSpace\App\project\

#run maven
R:\maven\bin\mvn clean package

than it found the local-settings.xml and correctly allowed the blocked mirror to run, I test it by setting the block to true and it blocks.

No idea why it didn't work when using the settings.xml in the user folder .m2 though.

P. Waksman
  • 979
  • 7
  • 21
  • I think it is because you use Linux-like terminal tool in Windows, maybe Gitbash or Mingw64; I often found they will try to map the root of each disk as home dir (`~` in Linux), so they want to access `C:/.mvn/` or sth, because in Linux they want to access `~/.mvn`. That will fail. I think you can specify the setting fiile like `mvn --settings mySettings.xml clean install`. – WesternGun Oct 27 '21 at 07:16
  • Try Linux subsystem of Windows, WSL. I heard they are better. But cannot be sure. – WesternGun Oct 27 '21 at 07:18