Search code examples
maven

How to exclude a dependency coming from parent in POM file


I am pulling in dependencies from a parent and need most of the dependencies in there. But I also wish to be able to exclude 2 dependencies entirely. I am not able to edit the parent thus this needs to be excluded from my POM file. Is this even possible? I've seen examples for overrides and quite a bit of suggestion to fix the parent POM which as mentioned, I can't do at this time.

Using Maven 3.3.x

My POM file

<parent>
    <groupId>com.company.stuff</groupId>
    <artifactId>our-parent</artifactId>
    <version>1.7</version>
</parent>

<!-- other dependencies and build and plugins --> 

The parent in above pulls in following plugins which I wish to exclude entirely.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>${some.version}</version>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-checkstyle-plugin</artifactId>
    <version>${some.version}</version>
</plugin>

Is there a way around this? Please advice. Thanks.

Tried with Thiago's suggestion, same outcome.

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${checkstyle.version}</version>
                <executions>
                    <execution>
                        <id>maven-checkstyle-plugin</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins> 
    </build>

Solution

  • Why not just skip the plugin executions?

    You could set the skip parameter of both plugins to true.