3

I am building my application with no problem:

mvn clean install -o

but when I remove repository from my default profile in .m2/settings.xml

<repositories>
    <repository>
        <id>ais3-repo</id>
        <name>My Repository</name>
        <url>some.url.to.work.artifactory</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <layout>default</layout>
    </repository>
    <repository>
        <id>icz-internal-repo</id>
        <url>some.url.to.work.artifactory</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

then I got error:

The repository system is offline but the artifact com.ibm.informix:ifxjdbc:jar:4.1 is not available in the local repository.

Why it is complaining about offline repository now? Even when I edit url to some nonsense it is still working. So what is the point of these repositories in offline maven mode when url is irelevant ?

PS:

in setting I have still defined local repository:

<localRepository>/home/user/.m2/repository</localRepository>

PS1:

ll /home/user/.m2/repository/com/ibm/informix/ifxjdbc/4.1

drwxrwxr-x 5 user user    4096 Jul 22  2014 ../
-rw-rw-r-- 1 user user 1057532 Jul  9  2014 ifxjdbc-4.1.jar
-rw-rw-r-- 1 user user    1366 Oct 14 15:11 ifxjdbc-4.1.jar.lastUpdated
-rw-rw-r-- 1 user user      57 Jul  9  2014 ifxjdbc-4.1.jar.sha1
-rw-rw-r-- 1 user user     417 Jul  9  2014 ifxjdbc-4.1.pom
-rw-rw-r-- 1 user user    1346 Oct 14 15:11 ifxjdbc-4.1.pom.lastUpdated
-rw-rw-r-- 1 user user      57 Jul  9  2014 ifxjdbc-4.1.pom.sha1
-rw-rw-r-- 1 user user     788 Sep 22  2014 ifxjdbc-4.1-sources.jar.lastUpdated
-rw-rw-r-- 1 user user     543 Sep 22  2014 m2e-lastUpdated.properties
-rw-rw-r-- 1 user user     249 Oct 15  2015 _maven.repositories
hudi
  • 15,555
  • 47
  • 142
  • 246
  • When working offline, the repositories are not taken into account, this is by design. If it works with `mvn clean install -o`, then all of the artifacts needed to build your project are in your local repo, as such, you cannot have *the artifact com.ibm.informix:ifxjdbc:jar:4.1 is not available in the local repository*. Either you changed the local repo, or you changed a dependency somewhere. Is `com.ibm.informix:ifxjdbc:jar:4.1` in your local repo under `/home/user/.m2/repository/com/ibm/informix/ifxjdbc/4.1`? – Tunaki Oct 14 '16 at 13:37
  • I edit my question so you can see output in PS1 – hudi Oct 14 '16 at 13:42
  • 1
    Can you try to remove all the `.lastUpdated` files and the `_maven.repositories`? But you shouldn't have that error running `mvn clean install -o` or removing some repositories in your settings... – Tunaki Oct 14 '16 at 13:48
  • ok deleting _maven.repositories helps me to solve this problem. thx a lot – hudi Oct 17 '16 at 08:35
  • Great, I'll write an answer for that. I found out the real cause. – Tunaki Oct 17 '16 at 08:45

1 Answers1

0

Maven repository is great concept and very useful when you are working on multiple maven projects. It saves time in downloading same and same jars if they are required by multiple projects.

When you build any maven project, first it looks into local repository for dependency jars, if not available then it downloads from repositories accessed through network(could be intranet or internet) and stores it in local repository.

Once downloaded, same jars will be used if required by any project in future. (Versions should match)

Pranalee
  • 3,389
  • 3
  • 22
  • 36
  • I do not understand your answer. Have you read the question? The OP is never leaving the offline mode. – tak3shi Oct 14 '16 at 14:08
  • Even if you are online, maven always refers local repository first. Network connection is required only to download jar to local repo. Once downloaded, its always used from local repo. – Pranalee Oct 17 '16 at 06:09
  • 1
    as you can see in my question this is not true. Maven is controling where did you downloaded this jars and you need to remove something if you are combining more profiles like me: http://stackoverflow.com/questions/16866978/maven-cant-find-my-local-artifacts – hudi Oct 17 '16 at 08:38