User Tools

Site Tools


misc:maven

Allgemein

mvn compile
mvn test
mvn -Dtest=org.my.MyClassTest test
mvn package
mvn -Dmaven.test.skip package   # skip compiling and running tests
mvn -DskipTests                 # compile tests, but don't run them
mvn clean install
mvn eclipse:eclipse
mvn eclipse:clean
  • package types: pom, jar, maven-plugin, ejb, war, ear, par
  • Ressource-Directories hinzufügen: xpath:build/resources/resource/directory

MAVEN_OPTS

Getting error “java.lang.OutOfMemoryError: PermGen space”?

export MAVEN_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=128m"

Misc

  • install Oracle JDBC Drivers
mvn install:install-file \
   -Dfile=$ORACLE_HOME/jdbc/lib/ojdbc14_g.jar \
   -DgroupId=com.oracle -DartifactId=oracle \
   -Dversion=10.2.0.2.0 -Dpackaging=jar -DgeneratePom=true

Snippets

JRebel Plugin

             <plugin>
                 <groupId>org.zeroturnaround</groupId>
                 <artifactId>jrebel-maven-plugin</artifactId>
                 <version>1.1.1</version>
                 <executions>
                     <execution>
                         <id>generate-rebel-xml</id>
                         <phase>process-resources</phase>
                         <goals>
                             <goal>generate</goal>
                         </goals>
                     </execution>
                 </executions>
             </plugin>

Copy Dependency to antrun Plugin

<plugin>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>reset-db</id>
            <phase>pre-clean</phase>
            <goals>
                <goal>copy</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.6</version>
                    </artifactItem>
                </artifactItems>
                <outputDirectory>${project.build.directory}/antrun-lib</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <id>reset-db</id>
            <phase>pre-clean</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <tasks>
                    <sql src="${project.basedir}/src/test/scripts/reset-db.sql"
                         autocommit="true"
                         driver="com.mysql.jdbc.Driver"
                         url="${root.jdbc.url}"
                         userid="${root.jdbc.user}"
                         password="${root.jdbc.password}"/>
                        <classpath>
                            <fileset dir="${project.build.directory}/antrun-lib" includes="*.jar"/>
                        </classpath>
                </tasks>
            </configuration>
        </execution>
    </executions>
</plugin>

Alternativly add 'classpathref=“maven.test.classpath”' to the sql task.

Tricks und Workarounds

Reading

Cons

misc/maven.txt · Last modified: 2014/07/13 16:33 by hgoebl