This page (revision-48) was last changed on 28-Jul-2015 06:43 by Dieter Käppel

This page was created on 02-Jun-2009 22:02 by Dieter Käppel

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
48 28-Jul-2015 06:43 16 KB Dieter Käppel to previous
47 28-Jul-2015 06:43 16 KB Dieter Käppel to previous | to last
46 13-Apr-2015 18:43 15 KB Dieter Käppel to previous | to last
45 14-Mar-2014 23:25 15 KB Dieter Käppel to previous | to last
44 02-Mar-2014 16:05 15 KB Dieter Käppel to previous | to last
43 15-Oct-2013 08:07 14 KB Dieter Käppel to previous | to last
42 09-Aug-2013 04:32 14 KB Dieter Käppel to previous | to last
41 17-May-2013 10:26 13 KB Dieter Käppel to previous | to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 16 added 57 lines
!!!Plugins
!!Ant als Plugin
{{{
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo message="${os.family}"/>
<echo message="${os.arch}"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
}}}
!!Exec plugin
{{{
<pluginRepository>
<id>codehaus snapshot repository</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${env.GLASSFISH_HOME}/bin/asadmin</executable>
<arguments>
<argument>deploy</argument>
<argument>target/test.war</argument>
</arguments>
</configuration>
</plugin>
mvn exec:exec
}}}
At line 80 added 112 lines
!!Eigenes Plugin
Maven-Projekt das ein Artifakt zum Verwenden als Plugin erzeugt:
{{{
<project>
...
<packaging>maven-plugin</packaging>
...
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.5.8</version>
</dependency>
...
</dependencies>
...
</project>
}}}
Anlegen eines sogenannten Mojos (Maven-Pojo). Parameter können statisch mit defaults, aus Maven-Parametern durch Expressions oder aus der Plugin-Konfiguration injeziert werden.
{{{
/**
* @goal encode
* @phase generate-resources
*/
public class EncodingMojo extends AbstractMojo {
/*
* @parameter default-value="src/main/resources"
*/
protected File src;
/**
* @parameter expression="${project}"
* @readonly
*/
protected MavenProject project;
/**
* @parameter
* @required
*/
protected Resource resource;
/** @component */
private BuildContext buildContext;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
...
}
...
}
}}}
Bei Verwendung in Eclipse ab Indigo wird das Maven-Plugin von Eclipse selbst geliefert (M2E). Dies erfordert eine erweiterte Konfiguration des Plugins, da es sonst zu Fehlern im Lifecycle kommt. Dazu wird eine Datei angelegt /<project>/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
{{{
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>generate-schema</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
<runOnConfiguration>true</runOnConfiguration>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
}}}
!!Ausführung unterbinden
Möchte man zum Beispiel bei einem Projekttyp WAR unterbinden, dass das Ausführen des maven-war-plugins unterbunden wird, kann man die Phase none verwenden:
{{{
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
}}}
At line 79 removed 32 lines
!!!Exec plugin
{{{
<pluginRepository>
<id>codehaus snapshot repository</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${env.GLASSFISH_HOME}/bin/asadmin</executable>
<arguments>
<argument>deploy</argument>
<argument>target/test.war</argument>
</arguments>
</configuration>
</plugin>
mvn exec:exec
}}}
At line 143 removed 27 lines
!!!Ant als Plugin
{{{
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo message="${os.family}"/>
<echo message="${os.arch}"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
}}}
!!!Links
* EAR-Plugin [http://maven.apache.org/plugins/maven-ear-plugin/modules.html]
At line 354 removed 95 lines
!!!Eigenes Plugin
Maven-Projekt das ein Artifakt zum Verwenden als Plugin erzeugt:
{{{
<project>
...
<packaging>maven-plugin</packaging>
...
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-build-api</artifactId>
<version>0.0.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.5.8</version>
</dependency>
...
</dependencies>
...
</project>
}}}
Anlegen eines sogenannten Mojos (Maven-Pojo). Parameter können statisch mit defaults, aus Maven-Parametern durch Expressions oder aus der Plugin-Konfiguration injeziert werden.
{{{
/**
* @goal encode
* @phase generate-resources
*/
public class EncodingMojo extends AbstractMojo {
/*
* @parameter default-value="src/main/resources"
*/
protected File src;
/**
* @parameter expression="${project}"
* @readonly
*/
protected MavenProject project;
/**
* @parameter
* @required
*/
protected Resource resource;
/** @component */
private BuildContext buildContext;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
...
}
...
}
}}}
Bei Verwendung in Eclipse ab Indigo wird das Maven-Plugin von Eclipse selbst geliefert (M2E). Dies erfordert eine erweiterte Konfiguration des Plugins, da es sonst zu Fehlern im Lifecycle kommt. Dazu wird eine Datei angelegt /<project>/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
{{{
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>generate-schema</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>false</runOnIncremental>
<runOnConfiguration>true</runOnConfiguration>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
}}}
At line 475 added 3 lines
!!!Links
* EAR-Plugin [http://maven.apache.org/plugins/maven-ear-plugin/modules.html]