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 354371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:55:04+00:00 2026-05-12T11:55:04+00:00

I have defined a local mirror for all repositories in the settings.xml file: <mirror>

  • 0

I have defined a local mirror for all repositories in the settings.xml file:

<mirror>
  <id>myMirror</id>
  <mirrorOf>*</mirrorOf>
  <url>file://${mypath}/maven/.m2/repository</url>
</mirror>

I want that my mirror to point to a local path, in this case the path is:

file://${mypath}/maven/.m2/repository

Where ${mypath} is a variable that I pass when I invoke Maven:

 mvn -Dmypath="/D:/test" package

The problem is that Maven does not replace the variable when it is invoked. I can see that this error is happening by inspection of the build log. For example, Maven reports that it is downloading a file from file://${mypath}/maven/.m2/repository when the correct would be file:///D:/test/maven/.m2/repository.

I have also noted that Maven replaces correctly my variable when it is inserted in the url child tag of the repository tag:

<repository>
        <id>central</id>
        <url>http://${mypath}/maven/.m2/repository</url>
</repository>

The build works correctly when I replace the variable in my settings.xml by the complete URL like in the example below:

<mirror>
        <id>myMirror</id>
        <mirrorOf>*</mirrorOf>
        <url>file:///D:test/maven/.m2/repository</url>
</mirror>
  • 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-05-12T11:55:04+00:00Added an answer on May 12, 2026 at 11:55 am

    Property substitution into settings.xml doesn’t work as you would expect.

    It will substitute properties inside the profiles element (as you’ve seen it substitutes into your repository url, which would be defined inside a profile), but not to elements outside of profiles (as you’ve seen happening in the mirrors section). This distinction is made because the profile element in the settings.xml is a truncated version of the pom.xml profile element. It is a mechanism to allow configuration to be set into your POM, so property substitution is allowed within the profiles elements as they are effectively part of the POM.

    The parts of the settings outside of the profiles element represent the platform configuration, these aren’t supposed to be affected by individual builds, so are not substituted for command-line properties. This makes sense but isn’t really made clear anywhere.

    EDIT: in the settings page of mavens documentation, in the last sentence of the quick overview section (quite hidden) it states:

    Note that properties defined in profiles within the settings.xml cannot be used for interpolation.


    There is a workaround though, you can substitute environment variables into the settings.xml. If you set the environment variable:

    set M2_MIRROR=D:\test
    

    and configure the repository url as follows:

    <url>file://${M2_MIRROR}/maven/.m2/repository</url>
    

    Then invoke Maven as normal, the environment variable is substituted and your build should work as required.

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

Sidebar

Related Questions

I have a central repository and 3 users with local repositories that pull and
I have defined following control template for my custom control. <ControlTemplate TargetType={x:Type local:CustomControl}> <Grid
If I have have some overloaded ostream operators, defined for library local objects, is
I have defined CSS in MasterPage so that all pages can use the same
I have a function defined a local variable typed in CStringW, is it safe
I have a class (MockWI) that I have defined the following DataTemplate in app.xml
I have defined a .dir-locals.el file with the following content: ((python-mode . ((cr/virtualenv-name .
I have an issue where in I have defined dependancies in ivy.xml on our
I have an issue. I have defined in C file, read-line.c, a function print,
What can cause a org.gradle.api.internal.artifacts.ivyservice.ModuleVersionNotFoundException for maven dependencies installed (manually) in local repository? In

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.