How to create separate jar files for application, source and documentation (for central.sonatype.org)

Sonatype has a repository where I want to deploy the jar file, and they request separate files for the application, sources and javadocs:

Example:

example-application-1.4.7.pom
example-application-1.4.7.jar
example-application-1.4.7-sources.jar
example-application-1.4.7-javadoc.jar

In Scala SBT, I have a command called "package" that generates a jar file for the project, but only generates "example-application-1.4.7.jar".

Question . What do I need to do to create two other jar files?

+4
source share
1 answer

In Maven, to get additional artifacts -sourcesand -javadoc, add the following to your POM file:

<build>
    <plugins>
        <!-- additional plugin configurations, if any.. -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.10.3</version>
            <executions>
                <execution>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

:

mvn clean package

target.


.pom install, target. , pom.xml Maven , , .

mvn clean install

Maven ( ) path_to_cache/.m2/repository/your_groupId/your_artifactId/your_version/. .pom, ( Maven).


: , , jar , , , Maven.

, build pom:

<profiles>
    <profile>
        <id>prepare-distribution</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10.3</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

, :

mvn clean install -Pprepare-distribution

. -P , prepare-distribution.


Maven 3 super pom, ( javadoc), . :

mvn clean install -Prelease-profile

,

mvn clean install -DperformRelease=true

, , ( Maven 3 3.3.9) )

. POM

, , Maven Release Plugin, useReleaseProfile release:perform.


, maven ( ),

+3

All Articles