Katie
Katie

Reputation: 48208

Maven can't find my offline dependencies / local artifacts ("not available in the local repository")?

I'm trying to download all my depenandies and have them available offline, but when I run mvn -o test, it says The repository system is offline but the artifact commons-io:commons-io:jar:2.4 is not available in the local repository. However, I have this package in my ~/.m2/repository!

~/.m2/settings.xml

<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">
  <localRepository>${user.home}/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <usePluginRegistry>false</usePluginRegistry>
  <offline>true</offline>
</settings>

ls ~/.m2/repository/commons-io/commons-io/2.4/

 _maven.repositories
 commons-io-2.4.jar
 commons-io-2.4.jar.lastUpdated
 commons-io-2.4.jar.sha1
 commons-io-2.4.pom
 commons-io-2.4.pom.sha1

mvn -o test

[ERROR] Failed to execute goal com.github.temyers:cucumber-jvm-parallel-plugin:2.0.2:generateRunners (generateRunners) on project myproject: Execution generateRunners of goal com.github.temyers:cucumber-jvm-parallel-plugin:2.0.2:generateRunners failed: Plugin com.github.temyers:cucumber-jvm-parallel-plugin:2.0.2 or one of its dependencies could not be resolved:

The repository system is offline but the artifact commons-io:commons-io:jar:2.4 is not available in the local repository. -> [Help 1]

The problem

Basically maven says I don't have ~/.m2/repository/commons-io/commons-io/2.4/, but I do!

I tried this:

find ~/.m2/repository -name _maven.repositories -exec rm -v {} \;

but after deleting _maven.repositories, when I ran mvn -o test, the file came right back!

I have maven 3.0.5

Upvotes: 4

Views: 7161

Answers (1)

Katie
Katie

Reputation: 48208

These 3 things got it to work (thanks to @Tunaki)

  1. Put -o at the END of your mvn command. Example mvn test -o. When I used it at the beginning, it didn't work
  2. Delete all *.lastUpdated files.
    • find ~/.m2/repository -name *.lastUpdated -exec rm -v {} \;
  3. Delete all _maven.repositories files.
    • find ~/.m2/repository -name _maven.repositories -exec rm -v {} \;

Note: the settings.xml made no difference whether it was there or removed. So I don't think it did anything.

Upvotes: 6

Related Questions