How disable maven-surefire-plugin:2.22.2 (default-test) and able maven-failsafe-plugin? - spring

I need disable surefire (default-test of spring) because I'm course and they did the Integrations-Test through failsafe.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/target/classes</additionalClasspathElement>
</additionalClasspathElements>
<parallel>none</parallel>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
<execution>
<id>default-test</id>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
I tried to do with this but did't work
<execution>
<id>default-test</id>
<configuration>
<skip>true</skip>
</configuration>
</execution>
when I run the test this is the result, the test is execute in org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test
enter image description here

Related

Jacoco test coverage report is not generated

I have configured the maven jacoco plugin as follows in my pom.xml file
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<systemPropertyVariables>
<application.name>${run.application.name}</application.name>
<application.home>${run.application.home}</application.home>
<application.environment>${run.application.environment}</application.environment>
<spring.profiles.active>${run.application.environment}</spring.profiles.active>
</systemPropertyVariables>
<includes>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
</includes>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-plugin.version}</version>
<configuration>
<rules>
<rule>
<element>CLASS</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.85</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>check</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
I tried by setting different parameters but could not make it work.
Whenever I am running the test cases using mvn clean install or mvn jacoco:report I am not getting -- Skipping JaCoCo execution due to missing execution data file.
Update--
when I removed this param in maven-surefire-plugin
<argLine>
--illegal-access=permit
</argLine>
the reports were generated but not sure what is the reason behind it.

Have integration tests in jacoco-it directory

I have integration tests and they are executed fine, but Jacoco considers them as unit tests. How to tell Jacoco to see them as integration tests and display their graph coverage, not in the jacoco-ut directory, but it the jacoco-it directory ?
Here in the Maven configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<argLine>${surefireArgLine}</argLine>
<excludes>
<exclude>**/it/java/*.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>process-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-resource</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/it/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-it-resources</id>
<phase>pre-integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/it-classes</outputDirectory>
<resources>
<resource>
<directory>src/it/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>${failsafeArgLine}</argLine>
<testSourceDirectory>src/it/java</testSourceDirectory>
<testClassesDirectory>${project.build.directory}/it-classes</testClassesDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<configuration>
<skip>${maven.test.skip}</skip>
<output>file</output>
<append>true</append>
<excludes>
<exclude>**/config/*</exclude>
<exclude>**/dialect/*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<phase>process-test-classes</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
<propertyName>surefireArgLine</propertyName>
<includes><include>**/ut/*</include></includes>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
<includes><include>**/it/*</include></includes>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report-integration</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
UPDATE: I was missing this bit in the maven-failsafe-plugin plugin:
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
After having added it as in:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>${failsafeArgLine}</argLine>
<includes>
<include>**/it/**</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
the integration tests report shows the integration tests.
The final full configuration is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<argLine>${surefireArgLine}</argLine>
<includes>
<include>**/ut/**</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>add-test-source</id>
<phase>process-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/it/java</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-resource</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/it/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>${failsafeArgLine}</argLine>
<includes>
<include>**/it/**</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<configuration>
<skip>${maven.test.skip}</skip>
<output>file</output>
<append>true</append>
<excludes>
<exclude>**/config/*</exclude>
<exclude>**/dialect/*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<phase>process-test-classes</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report-integration</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
You misunderstood the pattern for the include tag of maven-failsafe-plugin. The pattern is used for the package name of the classes within the test classpath (see also https://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html).
The build-helper-maven-plugin includes all classes in src/it/java to the test classpath. Then the pattern of include tag in both test plugins (surefire, failsafe) filters the classes within this test classpath. These filtered classes are executed by the test plugins.
So the workflow is
Build-Helper-Plugin extends the set of the test classes that have to be compiled and executed. Therefore the source directive is used. The path location defined in this source directive is related to the Maven project path.
Compiler Plugin compiles the java classes.
Jacoco-Plugin should measure the coverage in the production classes with unit tests. Therefore, the normal agent has to be prepared before the tests are executed. You can specify which production code should be included or excluded in the coverage measurment (include/exclude directive). The pattern in these directives are package-based (shlashes are used instead of dots).
Surefire-Plugin executes the tests whose full-qualified class name match the pattern of the include directive. The pattern uses slashes instead of dots.
Now the Jacoco-Plugin should measure the coverage in the production classes with integration tests. Therefore, the integration agent has to be prepared before the tests are executed. And again, you can specify which production code should be included or excluded in the coverage measurment (include/exclude directive). The pattern in these directives are package-based (shlashes are used instead of dots).
The same for the Failsafe-Plugin. It executes the tests whose full-qualified class name match the pattern of the include directive. The pattern uses slashes instead of dots.

Maven Plugin for calling Maven Plugins?

does anyone know any maven plugin that can call other maven plugins in a generic way? What I am searching for is anything like a proxy mechanism for scheduling plugin executions in a specific order.
The key is that I have to migrate a huge legacy project to maven which has plenty of ant macros that have to run in a specific order but with maven it is not possible to invoke the same plugin twice in one and the same phase with preserving the execution order when I need to intercept the two executions by the exectuion of a second plugin.
Assume the following: I have plugin A (native2ascii) and plugin B (replacer). Now my execution order must be A,B,A in just one phase. Sure, I can write it like that but the effective pom would look like A,A,B.
So it would be nice to have a 'proxy-plugin' (P) which would simply invoke the configured plugins. This way you could configure P(A),P(B),P(A) in one phase and the effective pom would be able to preserve the execution order.
Thanks so far!
I've tried out Wim's proposal like in the following but it turned out that the execution ids have no impact on the effective pom. The two executions of the replacer plugin are still combined and run before the native2ascii plugin.
Here is my pom:
<build>
<plugins>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>step-1-replacer</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>src/main/order-test/test.txt</file>
<outputFile>target/test-replaced-1.txt</outputFile>
<replacements>
<replacement>
<token>t</token>
<value>xyz</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<executions>
<execution>
<id>step-2-native2ascii</id>
<phase>generate-sources</phase>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<workDir>target</workDir>
<includes>
<include>test-replaced-1.txt</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>step-3-replacer</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>target/test-replaced-1.txt</file>
<outputFile>target/test-replaced-2.txt</outputFile>
<replacements>
<replacement>
<token>f6</token>
<value>-</value>
</replacement>
<replacement>
<token>e4</token>
<value>></value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
And here is how it looks like in the effective pom (both replacer executions are run before the native2ascii execution):
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<id>step-1-replacer</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>src/main/order-test/test.txt</file>
<outputFile>target/test-replaced-1.txt</outputFile>
<replacements>
<replacement>
<token>t</token>
<value>xyz</value>
</replacement>
</replacements>
</configuration>
</execution>
<execution>
<id>step-3-replacer</id>
<phase>generate-sources</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>target/test-replaced-1.txt</file>
<outputFile>target/test-replaced-2.txt</outputFile>
<replacements>
<replacement>
<token>f6</token>
<value>-</value>
</replacement>
<replacement>
<token>e4</token>
<value>></value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<executions>
<execution>
<id>step-2-native2ascii</id>
<phase>generate-sources</phase>
<goals>
<goal>native2ascii</goal>
</goals>
<configuration>
<workDir>target</workDir>
<includes>
<include>test-replaced-1.txt</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
And here is the output of the build:
...
[INFO] --- replacer:1.5.3:replace (step-1-replacer) # build-order-test ---
[INFO] Replacement run on 1 file.
[INFO]
[INFO] --- replacer:1.5.3:replace (step-3-replacer) # build-order-test ---
[INFO] Replacement run on 1 file.
[INFO]
[INFO] --- native2ascii-maven-plugin:1.0-beta-1:native2ascii (step-2-native2ascii) # build-order-test ---
[INFO] Includes: [test-replaced-1.txt]
[INFO] Excludes: []
[INFO] Processing /home/shillner/work/workspaces/dev/build-order-test/target/test-replaced-1.txt
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
Take a look at mojo-executor plugin, it can be used to invoke other plugins - from pom.xml and also programmaticaly.
Example:
<plugin>
<groupId>org.twdata.maven</groupId>
<artifactId>mojo-executor-maven-plugin</artifactId>
<version>#project.version#</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>execute-mojo</goal>
</goals>
<configuration>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.0</version>
</plugin>
<goal>list</goal>
<configuration>
</configuration>
</configuration>
</execution>
</executions>
</plugin>
There is no official support, but we are using execution ids in alphabetical order and this works fine for many years already.
Example:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>step-0-copy-resources</id>
<goals>
<goal>resources</goal>
</goals>
<phase>package</phase>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>step-1-build-assembly</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/assembly/descriptor.xml</descriptor>
</descriptors>
<!-- don't attach assembly to be installed -->
<attach>false</attach>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<execution>
<id>step-2-build-installer</id>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${basedir}/BuildInstaller.groovy</source>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>step-3-attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${basedir}/target/project-${project.version}.tar.gz</file>
<type>tar.gz</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Notice how each <id/> starts with "step-x" with x a number.

Using Maven to build c++ in eclipse

My Project consists of multiple Java-Projects, one Java-JNI-C++ Project as a Bridge and one pure C++ Project keeping an algorithm library. I managed to write Maven build configurations for all 3 project kinds. So when I'm calling them on the commandline (Windows 7, 64bit) everything works great.
I do not use any make files or something like this. I use exec-maven-plugin to call my mingw 64bit installation without cygwin (and I also didn't at least knowingly install msys). So 2 pure commandline g++ commands each for the JNA and Library Project.
What I need now for a smooth development workflow is to be able to build and debug the this projects from within Eclipse but using the maven build scripts, since I don't want to put work into my poms and additionally configure the eclipse builder. This should be consistent! Furthermore should the error parsing in Eclipse be konsistent with the output of the maven build.
For my Java projects this works greatly out of the box. Eclipse picks up the maven config and CLEAN and BUILD produces exactly what it should. (Though I see that the Java Builder is still active in the project's properties. Why??). But I cannot get it to work with the CDT.
When I disable the C++ Builder Eclipse just builds with maven (what I want), but the clean commands do not work correctly. Also I get errors marked which are not errors by the compiler. Of course this should be consistent.
Are there tutorials for this use case?
I did not find information on that subject. I'm not sure if I'm generally going into a wrong direction missing best practices or something?!
Since this is my first s.o. question, please feel free to give me also feedback on my question. What I can provide I will ;-)
Some Information:
System Windows 7, 64bit
Eclipse Juno, m2e
Library POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>mylib</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyLib</name>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<versionRange>[1.1.1,)</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>compile-Windows_x64</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>g++</executable>
<workingDirectory>target/cpp/Windows_x64</workingDirectory>
<arguments>
<argument>-Wall</argument>
<argument>-m64</argument>
<argument>-c</argument>
<argument>-DAPI_EXPORT</argument>
<argument>-g3</argument>
<argument>-std=c++0x</argument>
<argument>../../../src/main/cpp/*.cpp</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>link-Windows_x64</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>g++</executable>
<workingDirectory>target</workingDirectory>
<arguments>
<argument>-shared</argument>
<argument>-s</argument>
<argument>-m64</argument>
<argument>-oMyLib_Windows_x64.dll</argument>
<argument>cpp/Windows_x64/*.o</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
</executions>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-resources</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testResources</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>default-site</id>
<phase>none</phase>
</execution>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
JNI POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>myprog</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyProg</name>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<versionRange>[1.1,)</versionRange>
<goals>
<goal>copy</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<versionRange>[1.1.1,)</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>get-library-headers</id>
<goals>
<goal>copy</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<fileset>
<directory>../MyLib/target/mylib-0.0.1-SNAPSHOT-dll.zip</directory>
<includes>
<include>headers/*</include>
</includes>
<outputDirectory>${project.build.directory}/myLib</outputDirectory>
</fileset>
</configuration>
</execution>
<execution>
<id>get-library</id>
<goals>
<goal>copy</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<fileset>
<directory>../MyLib/target/mylib-0.0.1-SNAPSHOT-dll.zip</directory>
<includes>
<include>*.dll</include>
</includes>
<outputDirectory>${project.build.directory}</outputDirectory>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<id>compile-Windows_x64</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>g++</executable>
<workingDirectory>target/cpp/Windows_x64</workingDirectory>
<arguments>
<argument>-Wall</argument>
<argument>-m64</argument>
<argument>-c</argument>
<argument>-g3</argument>
<argument>-std=c++0x</argument>
<argument>-I../../myLib/headers</argument>
<argument>../../../src/main/cpp/*.cpp</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>link-Windows_x64</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>g++</executable>
<workingDirectory>target</workingDirectory>
<arguments>
<argument>-m64</argument>
<argument>-s</argument>
<argument>-oMyProg_Windows_x64.exe</argument>
<argument>cpp/Windows_x64/*.o</argument>
<argument>MyLib_Windows_x64.dll</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
</executions>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-resources</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testResources</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Thankx
Eclipse does not use the Maven build. Instead it configures the JDT according to your POM. This is done through an M2E (Maven to Eclipse) connector. If you want the same to work for CDT, then you would need an M2E connector for that. I'm not aware of an existing one, so you would have to write an Eclipse plugin for that. See http://wiki.eclipse.org/M2E/Extension_Development for details on how to do that.
Of course, you could also use "execute" instead of "ignore" in your lifecycleMapping in the pom. But that would probably make for a pretty slow build, because the whole build would be triggered on each change. And still this wouldn't "magically" make the errors from Maven appear in your files.

maven-compiler-plugin exclude

I have a following problem.
I would like to exclude some .java files (**/jsfunit/*.java) during the test-compile phase and on the other side I would like to include them during the compile phase (id i start tomcat with tomcat:run goal)
My pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<!-- <excludes>
<exclude>**/*JSFIntegration*.java</exclude>
</excludes> -->
</configuration>
<executions>
<!-- <execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>**/jsfunit/*.java</include>
</includes>
</configuration>
</execution>-->
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<configuration>
<excludes>
<exclude>**/jsfunit/*.java</exclude>
</excludes>
</configuration>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
But it does not work : exclude in default-testCompile execution does not filter these classes.
If I remove the comments then all classes matched **/jsfunit/*.java would be compiled but only if I touch them!
To exclude files from the default-testCompile phase, you have to use <testExcludes>. So your example above would look like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<configuration>
<testExcludes>
<exclude>**/jsfunit/*.java</exclude>
</testExcludes>
</configuration>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>

Resources