Search code examples
mavenmaven-3

mvn download package files into current directory


can anybody please help why mvn command always download dependancy files into current directory? It should be stored into M2_HOME right?

I have tried

mvn package
mvn help:system

$M2_HOME has been set correctly

C:\> mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Users\Documents\bin\apache-maven-3.6.3\bin\..
Java version: 1.8.0_252, vendor: Azul Systems, Inc., runtime: C:\Users\Documents\bin\Zulu\zulu-8\jre
Default locale: en_SG, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Solution

  • @khmarbaise, thank you for your reply. I tried to follow your advice but problem persists.

    First I notice my $HOME variable is not set but $JAVA_HOME is good

    So I set up $HOME variable and restarted command prompt but result is still same - 'mvn package' still downloads packages to current working directory instead of $HOME/.m2/repository.

    Secondly I checked $HOME/.m2/settings.xml file. Do you see any issues below?

    <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/>
        <interactiveMode/>
        <usePluginRegistry/>
        <offline/>
        <pluginGroups/>
        <servers/>
        <mirrors>
            <mirror>
                <id>xxx-maven</id>
                <mirrorOf>central</mirrorOf>
                <name>xxx maven repo</name>            <url>https://xxx/nexus/repository/repo/</url>
            </mirror>
        </mirrors>
        <profiles/>
        <activeProfiles/>
    </settings>