2

As we all know that using mvn clean install will install the built package,eg jar, zip, pom, to local repo , but source and javadoc jar . Can I make some changes on pom.xml so that source and jardoc jar would be installed to local repo with mvn clean install

爱国者
  • 4,298
  • 9
  • 47
  • 66
  • possible duplicate of [Source and Javadoc jar generation](http://stackoverflow.com/questions/4023373/source-and-javadoc-jar-generation) – Nishant Feb 02 '12 at 16:37
  • No. I mean how to install source and javadoc artifact along with a single command `mvn install`, not how to generate source and javadoc artifact. By default, `mvn install` will not install source and javadoc artifact to local repo – 爱国者 Feb 02 '12 at 16:53

1 Answers1

6

Yes, what you want to do is to add the maven-source-plugin and maven-javadoc-plugin to your pom. This will cause the jar goal to execute automatically during the package phase without needing to specify it on the command line.

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
            <execution>
                <id>attach-sources</id>
                <goals>
                    <goal>jar</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <executions>
            <execution>
                <id>attach-javadocs</id>
                <goals>
                    <goal>jar</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    ...
<plugins>
BenjaminLinus
  • 2,100
  • 23
  • 24