13

I need to have a completely offline maven repository due to some limitations. According to http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException , only <pluginRepositories> are searched for plugins. So I am wondering how to configure maven to look up plugins in a local file system. I tried using "file://" prefix when setting <url> but it doesn't work.

DEBUG] Verifying availability of /home/dsun/.m2/repository/org/apache/karaf/tooling/features-maven-plugin/2.3.0/features-maven-plugin-2.3.0.jar from [central (http://repo1.maven.org/maven2, releases=true, snapshots=false, managed=false)]
[ERROR] Plugin org.apache.karaf.tooling:features-maven-plugin:2.3.0 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.karaf.tooling:features-maven-plugin:jar:2.3.0 is not available in the local repository. -> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.karaf.tooling:features-maven-plugin:2.3.0 or one of its dependencies could not be resolved: The repository system is offline but the artifact org.apache.karaf.tooling:features-maven-plugin:jar:2.3.0 is not available in the local repository.

dsun@localhost:> ls /home/dsun/.m2/repository/org/apache/karaf/tooling/features-maven-plugin/2.3.0/features-maven-plugin-2.3.0.jar
/home/dsun/.m2/repository/org/apache/karaf/tooling/features-maven-plugin/2.3.0/features-maven-plugin-2.3.0.jar

The settings.xml

<settings>      
<offline>true</offline>
  <profiles>
  <profile>
    <id>local</id>
    <pluginRepositories>
      <pluginRepository>
      <id>central</id>
      <url>file://${env.HOME}/.m2/repository</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>
   </profile>
 </profiles>
<activeProfiles>
  <activeProfile>local</activeProfile>
</activeProfiles>

<localRepository>${env.HOME}/.m2/repository</localRepository>

SunLiWei
  • 1,313
  • 4
  • 11
  • 30
  • 1
    I'm not sure, but maybe this post will be helpful for you: http://stackoverflow.com/questions/5141211/maven-without-remote-repository – Andrej Istomin Nov 21 '12 at 17:03
  • Your configuration could not work cause you are defining the source repository the same as the target repository (.m2/repository). You need to having an initial boot strap where to start from and after all your builds are working you can the setup. – khmarbaise Nov 21 '12 at 17:19
  • hi khmarbaise, could you explain it in details? what do you mean "source repository"? The needed plugin is already in my local repository. And I tried to remove all the lines in settings.xml except the , it also doesn't work. – SunLiWei Nov 21 '12 at 17:26

3 Answers3

10

Finally, I found the problem, there's a file called _maven.repositories in the plugin directory, after I delete the file, all works well!

More details, see the following links:

SunLiWei
  • 1,313
  • 4
  • 11
  • 30
  • I did not delete it, but changed its significant line to something like `artifact-name-1.2.pom>=` (just `>=`, nothing else). That did the trick for me. – icyerasor Mar 19 '20 at 16:02
8

Since Maven 3.1-alpha-1, the command line option -llr/--legacy-local-repository or the system property -Dmaven.legacyLocalRepo=true should help

See here for a general answer on working offline with maven

user1767316
  • 3,276
  • 3
  • 37
  • 46
0

This problem annoyed me so much that I patched the war plugin to have a disableOverlaying parameter. You may find it here - forked from the original : https://github.com/crowdcode-de/maven-war-plugin

gorefest
  • 849
  • 8
  • 22