Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up Maven to override a settings file for another when running a test?

See the following Maven generated project

target
    classes
    test-classes
src
    main
        java
        scripts
        resources
            datasource-settings.xml
    test
        java
        resources
            datasource-settings.xml

I would like, when running a test, to use the settings found in test/resources/datasource-settings.xml instead of main/resources/datasource-settings.xml. Is it possible ? If so, what should i do to get my goal ?

like image 382
Arthur Ronald Avatar asked Feb 18 '10 02:02

Arthur Ronald


People also ask

Where does Maven keep settings xml?

The Maven settings file, settings. xml , is usually kept in the . m2 directory inside your home directory.


1 Answers

Resources placed in ${basedir}/src/test/resources (the default location) will be automatically added to the class path set up by Maven for your unit tests and take precedence over resources placed in ${basedir}/src/main/resources. So what you want to do is actually just the default behavior.

like image 187
Pascal Thivent Avatar answered Oct 08 '22 17:10

Pascal Thivent