Question

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?

Was it helpful?

Solution

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..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top