Maven is a plug-in execution framework, the plug-ins are classifiers in two types:
- Build plugins will be executed during the build and then, they should be configured in the <build/> element.
- Reporting plugins will be executed during the site generation and they should be configured in the <reporting/> element.
Build plugins
An example of build plugin is: <project>
...
<build>
<plugins>
<plugin>
<groupId>it.blogspot.informaticaamodomio</groupId>
<artifactId>maven-mybuild-plugin</artifactId>
<version>1.0</version>
<configuration>
<myString>a string</myString>
<myBoolean>true</myBoolean>
<myInteger>10</myInteger>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
The
example below uses the <executions> element, this element is used
when the plug-in participates in some phases of the build lifecycle:
<project>
...
<build>
<plugins>
<plugin>
<groupId>it.blogspot.informaticaamodomio</groupId>
<artifactId>maven-mybuild-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>execution1</id>
<phase>test</phase>
<configuration>
<myString>a string</myString>
<myBoolean>true</myBoolean>
<myInteger>10</myInteger>
</configuration>
<goals>
<goal>mygoal</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
The id "execution1" binds this configuration to the test phase.
You could configure the dependencies of the Build plugins with <dependencies> element:
You could configure the dependencies of the Build plugins with <dependencies> element:
<project>
...
<build>
<plugins>
<plugin>
<groupId>it.blogspot.informaticaamodomio</groupId>
<artifactId>maven-mybuild-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>execution1</id>
<phase>test</phase>
<configuration>
<myString>a string</myString>
<myBoolean>true</myBoolean>
<myInteger>10</myInteger>
</configuration>
<goals>
<goal>mygoal</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>it.blogspot.informaticaamodomio</groupId>
<artifactId>my-app</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
...
</project>
By
default, plugin configuration should be propagated to child POMs, so to
break the inheritance, you could uses the <inherited> element:
<project>
...
<build>
<plugins>
<plugin>
<groupId>it.blogspot.informaticaamodomio</groupId>
<artifactId>maven-mybuild-plugin</artifactId>
<version>1.0</version>
<inherited>false</inherited>
.......
</plugin>
</plugins>
</build>
...
</project>
Reporting plugins
As
first statement, configuring a reporting plugin in the
<reporting> or <build> elements in the pom does not have the
same behavior.
For example the "mvn site" uses only the parameters defined in the <configuration> element of each reporting Plugin specified in the <reporting> element, site always ignores the parameters defined in the <configuration> element of each plugin specified in <build>. So I suggest adding it only in <reporting> element.
For example the "mvn site" uses only the parameters defined in the <configuration> element of each reporting Plugin specified in the <reporting> element, site always ignores the parameters defined in the <configuration> element of each plugin specified in <build>. So I suggest adding it only in <reporting> element.
You
can configure a reporting plugin using the <reportSets> tag. This
is most commonly used to generate reports selectively when running mvn
site. Example:
If you want exclude all reports, use the following reportSets configuration:
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>${plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>project-team</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
...
</project>
<reportSets>
<reportSet>
<reports/>
</reportSet>
</reportSets>
<inherited>false</inherited>
No comments:
Post a Comment