Removing surefire plugin
Asked Answered
K

0

6

I have the following parent 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>my_group</groupId>
    <artifactId>my_artifact</artifactId>
        <version>0.0.1</version>
    <packaging>pom</packaging>
    <modules>
        <module>../common-module</module>
    </modules>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <https.website>http://intosimple.blogspot.com</https.website>
        <snapshot.version>0.0.1</snapshot.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

And the corresponding child POM is as follows:

<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>
    <parent>
        <groupId>My_group1</groupId>
        <artifactId>my_artifact_1</artifactId>
        <version>0.0.1-</version>
        <relativePath>../base/pom.xml</relativePath>
    </parent>
    <artifactId>some_module</artifactId>
    <properties>
        <jdk.version>1.8</jdk.version>
        <jacoco.version>0.7.5.201505241946</jacoco.version>
    </properties>
    <dependencies>
        <!-- some packages here-->
    </dependencies>
    <build>
        <finalName>my_artifact_1</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.version}</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-check</id>
                        <phase>test</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule implementation="org.jacoco.maven.RuleConfiguration">
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit implementation="org.jacoco.report.check.Limit">
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>0.0400</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                        </configuration>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>

                            <dataFile>target/jacoco.exec</dataFile>

                            <outputDirectory>target/jacoco-ut</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <systemPropertyVariables>
                        <jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Even though, there is no mention of surefire plugin, the effective POM somehow is getting that. Could it be coming from any dependency?

I doubt that surefire might be causing Jacoco to fail. I want to remove it completely. What is right way of doing it?

Klemperer answered 20/9, 2018 at 21:7 Comment(5)
try running mvn dependency:tree in your child project, which will give you what brings the surefire plugin in a hierarchical way. Then, you can remove it using <exclude> element in pom.xml.Tillion
surefire is not included in that.Klemperer
If it is not there, then it is not there. IDEs can be wrong at times. For a maven project, mvn is the ultimate source of truth.Tillion
surefire is a maven plugin which is showing up in mvn help:effective-pom. as it is not a dependency, it is probably not showing up in the dependency tree.Klemperer
Hey @dknight, how did you solve that eventually? I am having a similar problem. Essentially, it is being inherited from another plugin I am using to build scala code. It's coming from this plugin: <artifactId>scala-maven-plugin</artifactId>Ferbam

© 2022 - 2024 — McMap. All rights reserved.