Snippets

Sebastian Sardina Use of Maven - Tips

Created by Sebastian Sardina last modified

Use of Maven - Tips

Testing configuration

We use the Maven Surefire Plugin with skipping by default:

     <properties>
        <skipTests>true</skipTests>
      </properties>

    <!-- JUNIT testing framework -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <!--<scope>test</scope>-->
    </dependency>

    <build>
        <testSourceDirectory>src/java/org/jpl7/test</testSourceDirectory>
        ...
        <plugin>
            <!-- Unit test execution -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.4</version>
            <configuration>
                <!-- Check this: https://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-tests.html -->
                <skipTests>${skipTests}</skipTests>
            </configuration>
       </plugin>
        ....
    </build>

Then, we can enable the tests via mvn surefire:test -DskipTests=false

Pass arguments to Maven

You can use the MAVEN_OPTS environmnt variable that will apply to all calls to Maven. For example:

export MAVEN_OPTS=-Djava.library.path=/usr/local/swipl-git/lib/swipl/lib/x86_64-linux/

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.