5 Replies Latest reply: Nov 28, 2011 4:21 AM by Mickaël Leduque RSS

Using current maven settings.xml

Mickaël Leduque Newbie

Hello,

I'm trying to use the maven dependency resolution with shrinkwrap and I need to retrieve the settings from the current maven execution.

 

Those are integration test cases run under maven. In those tests, I need to get artifacts as dependencies. I can't hardcode a settings.xml location (or a settings.xml as resource) because this location changes between developer machines and with the locations on the CI server.

 

But if I don't tell where the setttings.xml is, aether won't use my local repository.

 

How do I tell shrinkwrap to reuse the same settings.xml file as the running maven ?

  • 1. Re: Using current maven settings.xml
    Karel Piwko Master

    Hi Mickael,

     

    unfortunately you can't use the same settings as the running Maven, because of surefire not passing that information. See http://jira.codehaus.org/browse/SUREFIRE-790.

     

    However, SWR has a workaround, you're able to set settings.xml via a system property, which is less convenient but will allow developer to change the path without touching tests.

     

    You can set both path to settings.xml and path to local repository via following system properties:

     

    org.apache.maven.user-settings

    maven.repo.local

     

     

    See

    https://github.com/shrinkwrap/resolver/blob/master/impl-maven/src/test/java/org/jboss/shrinkwrap/resolver/impl/maven/ProfilesUnitTestCase.java#L73

     

    Please note that you have to get them propagated to Surefire configuration, e.g.

     

    <properties>

         <org.apache.maven.user-settings>default/value</org.apache.maven.user-settings>

    </properties>

     

    <plugin>

                    <groupId>org.apache.maven.plugins</groupId>

                    <artifactId>maven-surefire-plugin</artifactId>

                     <version>2.9</version><!-- or upper -->

                            <configuration>

                                <systemPropertyVariables>

                                       <org.apache.maven.user-settings>${org.apache.maven.user-settings}</org.apache.maven.user-settings>

                                 </systemPropertyVariables>

                            </configuration>

    </plugin>

     

    Then you can do:

     

    mvn -s settings.xml -Dorg.apache.maven.user-settings=settings.xml clean package

     

    and both your test and the running maven will use the same settings.xml file.

     

    By the way, I'm just curious, what version of ShrinkWrap Maven Resolver are you using?

     

    Karel

  • 2. Re: Using current maven settings.xml
    Karel Piwko Master

    Just a note,  SWR means ShrinkWrap Maven Resolver, it's just much shorter to write

  • 3. Re: Using current maven settings.xml
    Mickaël Leduque Newbie

    OK, thanks. I was under the impression that this wouldn't be possible, but kept searching nonetheless.

    I once tried setting org.apache.maven.user-settings, but it didn' t work because  hadn't done the surefire configuration stuff. I'll try that now.

     

    The SWR version I used were first the default one imported along with arquillian (1.0.0-alpha12 I believe), but that wasn't very convenient, so I bumped it to 1.0.0-beta? to finally go straight to 1.1.0-alpha-1.

     

    The last version bump was because I wanted to try the Maven.dependency(...) syntax, but as far as I know, this doesn't allow to do useCentralRepo=false.

  • 4. Re: Using current maven settings.xml
    Mickaël Leduque Newbie

    Someone seems to expect the same thing as me :

    http://jira.codehaus.org/browse/SUREFIRE-790

     

    Though given the comments I have few hopes.

  • 5. Re: Using current maven settings.xml
    Mickaël Leduque Newbie

    Ah sorry, Karel, you would be aware of it