Maven 2.x Source Plugin

When source plugin is used, it should make sure it is invoked during install

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.0.3
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

I have a really hard time to make the source plugin work. When I just run "mvn install", the source plugin is ignored.

I tried to use executions (http://garbuz.com/sm/content.php/articles/maven2_deploying_sources/) but that also doesn't work reliably.

The only stable way I found so far is:

mvn source:jar install

but that's tedious. Isn't it possible to configure the plugin by default in such a way that, when it is used in the POM, it will be invoked automatically during "mvn install", "mvn deploy", etc?

Activity

Hide
Aaron Digulla added a comment -

Oh, I'm using Maven 2.0.4 and the source plugin is 2.0.1.

Show
Aaron Digulla added a comment - Oh, I'm using Maven 2.0.4 and the source plugin is 2.0.1.
Hide
Aaron Digulla added a comment -

Note: The executions (see link above) only work if they are in the POM of every module of your project.

Just defining this once in the parent pom doesn't work.

Show
Aaron Digulla added a comment - Note: The executions (see link above) only work if they are in the POM of every module of your project. Just defining this once in the parent pom doesn't work.
Hide
Jason van Zyl added a comment -

Using the following will get you what you want. I will update the documentation with this example.


<project>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<aggregate>false</aggregate>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</build>
</project>


Show
Jason van Zyl added a comment - Using the following will get you what you want. I will update the documentation with this example.

<project> <plugins> <plugin> <artifactId>maven-source-plugin</artifactId> <configuration> <aggregate>false</aggregate> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </build> </project>

Hide
Jason van Zyl added a comment -

This works just fine.

Show
Jason van Zyl added a comment - This works just fine.
Hide
Aaron Digulla added a comment -

Have you tried this using a parent POM?

Ie. move this code to the parent pom and then try to build the child project. You won't get a source JAR.

Also, it would be great if the source plugin would attach itself to the package phase automatically because when I use, why would I want it to run at any other time? The default should be what most users want.

Show
Aaron Digulla added a comment - Have you tried this using a parent POM? Ie. move this code to the parent pom and then try to build the child project. You won't get a source JAR. Also, it would be great if the source plugin would attach itself to the package phase automatically because when I use, why would I want it to run at any other time? The default should be what most users want.
Hide
Christian Sauer added a comment -

Hey,

may it be possible that this issue is still present in 2.0.6?
I' ve got a parent POM with following plugin config:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>

Building a component with a pom inheriting from the parent one, the build will still not create the source artifact!
I have to add the definition to each component for the sources jar being created ...
Any idea?

Cheers

Show
Christian Sauer added a comment - Hey, may it be possible that this issue is still present in 2.0.6? I' ve got a parent POM with following plugin config: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>2.0.3</version> <executions> <execution> <goals> <goal>jar</goal> <goal>test-jar</goal> </goals> </execution> </executions> </plugin> Building a component with a pom inheriting from the parent one, the build will still not create the source artifact! I have to add the definition to each component for the sources jar being created ... Any idea? Cheers

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: