3

I have this small module, which contains only some property file. The property file resides in the root of the project and needs to stay there. Nothing more. When uploading to Maven central via sonatype, a javadoc jar is mandatory so I had to create one.

So I don't have src/main/java or src/main/resources. How do I do it?

The javadoc plugin doesn't provide any options for this.

For the sources jar, just the same. Sonatype requires at least the presence of a sources jar, even if it is empty...

To date (december 2018) I could not find a working solution on the internet.

1 Answer 1

6

I've found this very simple trick! No extra plugins needed, just extend the current maven-jar-plugin with two extra executions, one for the javadoc and one for the sources:

        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>default-jar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
                <execution>
                    <id>javadoc-jar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classifier>javadoc</classifier>
                    </configuration>
                </execution>
                <execution>
                    <id>sources-jar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classifier>sources</classifier>
                    </configuration>
                </execution>
            </executions>
        </plugin>

When executing 'deploy' it will generate an extra empty javadoc and sources jar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.