Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven plugin dependency - using the source plugin in all my poms

I would like to configure the use of the maven source plugin for all our projects. The way our projects are currently configured we have a parent pom that is inherited by all the projects. So, in order for all projects to use the maven source plugin, I did the following:

  1. Defined the maven source plugin under build -> plugin management in the parent pom

                <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    
  2. In my project pom (the child pom), I have included the source plugin under build -> plugins

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
        </plugin>

Could someone please tell me if this is the best way to configure this? Is there any way you can avoid specifying the source plugin in the child pom?

like image 848
IceMan Avatar asked Oct 21 '25 21:10

IceMan


1 Answers

This is the best way.

To avoid having to add the plugin declaration in the child pom you could add it to the build/plugins section in the parent. The problem with that however is that EVERY child gets that invocation added even if it does not make sense if e.g. the child is a pom or ear packaging. You should therefore not do this..

like image 158
Manfred Moser Avatar answered Oct 24 '25 16:10

Manfred Moser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!