With Maven 3.8.2
I have a plugin that I download from a custom Maven repository:
$ mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get \
-DremoteRepositories=excelfore.private::::https://some_url \
-Dartifact=com.excelfore:appshack-maven-plugin:4.2133-RC1:maven-plugin
...
[INFO] BUILD SUCCESS
Now I just want to run the plugin:
$ mvn -e com.excelfore:appshack-maven-plugin:4.2133-RC1:run-self-test
which results into:
[ERROR] Plugin com.excelfore:appshack-maven-plugin:4.2133-RC1 or one of its dependencies could not be resolved: Failure to find com.excelfore:appshack-maven-plugin:jar:4.2133-RC1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
How do I tell Maven to just use the files it's downloaded earlier?
I've tried -o
, this just changes to:
[ERROR] Plugin com.excelfore:appshack-maven-plugin:4.2133-RC1 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact com.excelfore:appshack-maven-plugin:jar:4.2133-RC1 has not been downloaded from it before. -> [Help 1]
-npu
doesn't seem to do anything, it shows a warning about this option being deprecated, and the error is the same.
Using -X
I can see these messages:
[DEBUG] Using local repository at /home/vps/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /home/vps/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project org.apache.maven:standalone-pom:pom:1: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Verifying availability of /home/vps/.m2/repository/com/excelfore/appshack-maven-plugin/4.2133-RC1/appshack-maven-plugin-4.2133-RC1.pom from [central (https://repo.maven.apache.org/maven2, default, releases)]
[WARNING] The POM for com.excelfore:appshack-maven-plugin:jar:4.2133-RC1 is missing, no dependency information available
[DEBUG] Verifying availability of /home/vps/.m2/repository/com/excelfore/appshack-maven-plugin/4.2133-RC1/appshack-maven-plugin-4.2133-RC1.jar from [central (https://repo.maven.apache.org/maven2, default, releases)]
Of course all the files are there, and I even verified that SHA1 sums match:
[vps@hornet]~$ ll ~/.m2/repository/com/excelfore/appshack-maven-plugin/4.2133-RC1/
-rw-rw-r--. 1 vps 317291 Aug 19 12:43 appshack-maven-plugin-4.2133-RC1.jar
-rw-rw-r--. 1 vps 341 Aug 19 12:43 appshack-maven-plugin-4.2133-RC1.jar.lastUpdated
-rw-rw-r--. 1 vps 40 Aug 19 12:43 appshack-maven-plugin-4.2133-RC1.jar.sha1
-rw-rw-r--. 1 vps 3248 Aug 19 12:43 appshack-maven-plugin-4.2133-RC1.pom
-rw-rw-r--. 1 vps 341 Aug 19 12:43 appshack-maven-plugin-4.2133-RC1.pom.lastUpdated
-rw-rw-r--. 1 vps 40 Aug 19 12:43 appshack-maven-plugin-4.2133-RC1.pom.sha1
-rw-rw-r--. 1 vps 252 Aug 19 12:43 _remote.repositories
It seems that I'm missing something silly, and it seems that sometimes this works just fine, but I often run into this brick wall. I expect Maven not to try to synchronize artifacts that have been successfully downloaded.
I assume the problem is that Maven doesn't know about the private repository when it runs the plugin, but I need to run it outside of any project (i.e. no POM file), and AFAIU, there is no way to define repositories in the ~/.m2/settings.xml
(only servers, which won't help).
What is weirder, however, is that this works with snapshots.
$ mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get \
-DremoteRepositories=excelfore.private::::https://some_url \
-Dartifact=com.excelfore:appshack-maven-plugin:4.2132-SNAPSHOT:maven-plugin
...
[INFO] BUILD SUCCESS
$ /opt/maven/apache-maven-3.8.2/bin/mvn -X \
com.excelfore:appshack-maven-plugin:4.2132-SNAPSHOT:run-self-test
...
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /home/vps/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project org.apache.maven:standalone-pom:pom:1: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[DEBUG] Could not find metadata com.excelfore:appshack-maven-plugin:4.2132-SNAPSHOT/maven-metadata.xml in local (/home/vps/.m2/repository)
[DEBUG] Could not find metadata com.excelfore:appshack-maven-plugin:4.2132-SNAPSHOT/maven-metadata.xml in local (/home/vps/.m2/repository)
[DEBUG] Could not find metadata com.excelfore:appshack:4.2132-SNAPSHOT/maven-metadata.xml in local (/home/vps/.m2/repository)
[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: org.apache.maven:standalone-pom:pom:1
[DEBUG] Tasks: [com.excelfore:appshack-maven-plugin:4.2132-SNAPSHOT:run-self-test]
Judging by the debug output, it doesn't do this "availability verification" with snapshots. However, using -U
flag makes absolutely no difference.