Search code examples
mavendependabot

Other ways of disabling default maven plugins as via phase none?


For some of my projects I don't need the default maven plugins, as for an example I use there no or other compilers. Disabling these plugins saves execution time and build output in this case.

For the moment the only way to disable default maven plugins I found is the following:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>default-testCompile</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>

I have enabled dependabot on my code, which informs me now everytime, when there is a new version of the plugin, despite I don't use it.

If I delete the version, then maven gives warnings like the following: 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing.

So my question is: Are there other ways of disabling the standard maven plugins which does not need the pluging version number and does not generate such maven warnings?

Kind regards Torsten


Solution

  • If you don't build a JAR or WAR, you can set <packaging>pom</packaging> in the POM file, which leads to a minimum number of default plugins.

    Default plugins are set by the lifecycle, and the lifecycle is determined by the packaging. You can even define your own packaging <packaging>kleiber</packaging> with your own lifecycle and default plugins.