Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9168881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:44:16+00:00 2026-06-17T15:44:16+00:00

By default, Maven will grab all the dependency’s from the local repository (.m2 directory).

  • 0

By default, Maven will grab all the dependency’s from the local repository (.m2 directory). But instead, I want it to grab the dependencies from another location. Is this even possible?

I don’t want to do this with everything. I don’t want this to happen at the “root” or the parent level. I want this to happen at a more “deeper” pom level. There is more than once that is same dependent is being dependent. For each time, I want it to come from a different location. So, one will use the default maven configuration and get it from the .m2 directory, and the other will get it from a specific directory.


MY REASONS:

In the install phase, everything gets installed to the .m2 directory. In the package phase, I have everything get packaged into a target directory. (Am I not correct?)

My .m2 directory has more than needed. My target has my final project without the extra “things” that are included in the .m2 directory. Whatever is in the target directory is the final product. When I’m in the compile phase, I don’t want it to depend upon the .m2 directory, but instead the target since that is my real final project.


I’m using Maven 2.2.1 on Linux (Red Hat).

I’ve read somewhere that you can use the <scope> element with the value system under the <dependency> element in your pom.xml file. Then give the actual location in another element called <systemPath> under that <dependency>. I don’tif this answers my question, or if this something entirely different.

I know this goes against Maven’s recommendations, but I have my reasons.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:44:17+00:00Added an answer on June 17, 2026 at 3:44 pm

    Please read my answer to this different, but related, question first.

    In general, people have developed muscle memory when it comes to Maven. Case in point, almost everyone thinks this is how you build projects with Maven:

    $ mvn clean install
    

    Now that will build the project, but it also stores the built artifacts in the local repository.., this is fine if you are then going to work on a sub-module and want to safe rebuilding everything all the time, or if you are using an IDE that has a poor understanding of the reactor (newer versions of most IDEs do not have this issue)

    What you should probably be doing is

    $ mvn clean verify
    

    Or

    $ mvn clean package -DskipTests
    

    (The second one skips the tests because if you don’t care about ensuring the integration tests pass, you probably don’t care about the unit tests either)

    So to me it sounds like you are just typing the wrong command…

    Now there is a second possibility, namely you may be building a ‘transient, intermediary’ artifact that is not exposed as a transitive dependency… In that case you could add a <skip>true</skip> to the configuration for the maven-install-plugin in that specific module (also consider adding to maven-deploy-plugin) but you need to be damn sure that the module does not leak via a transitive dependency or all hell will break loose.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when i use maven war plugin, by default, this plug-in will copy all class
this is my pom.xml <repositories> <repository> <url>http://download.java.net/maven/2/</url> <id>hibernate-support</id> <layout>default</layout> <name>Repository for library Library[hibernate-support]</name> </repository>
By default maven will filter resources like this: <properties> <replace.me>value</replace.me> </properties> <some-tag> <key>${replace.me}</key> </some-tag>
Is it possible to set the location of the local Maven repository as argument
tl;dr-edition: I have a compilation I know that will fail, but want the subset
I want to ignore some build errors at a specific directory by using maven's
By default during the build process maven is removing the empty directories. Do you
When i try to run a maven plugin, i found that the default classpath
Environment: hudson/sonar/maven2 in ubuntu locally with default parameters And I got the log from
Default JVM uses maximum 1.5 GB RAM/JVM Java application. But my Server have 8

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.