Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the recommended packaging for a "documentation" only module with Maven?

Tags:

maven

I do not want to have the documentation of a multi-module Maven project under site folder for Maven Site workflow. The documentation lives under project-docs with the project-parent. What's the best practice packaging for such module?

The setup is

  1. Packaging is now configured as jar
  2. There's a Maven plugin that generates HTML/PDF documentation in phase prepare-package under some directory (src/main/docs) of project-docs during build workflow.
  3. There's a default Maven assembly descriptor that generates a project-docs-NNN-default.zip.
  4. The default artifact of the project is an empty JAR file.

Regarding the (3) in above, the alternatives:

Packaging: pom

Does not support prepare-package as the probably most suitable phase. If then phase site is used, you cannot have the generated documentation inside the default install life cycle.

Packaging: jar

The empty JAR is useless!

like image 328
nobeh Avatar asked Jul 15 '14 02:07

nobeh


People also ask

What is a valid packaging type for a Maven project?

Some of the valid packaging values are jar , war , ear and pom . If no packaging value has been specified, it will default to jar .

Is it allowed to do documentation with Maven?

The first step in having a good documentation is to have an accurate and visible basic project information, Maven can provide this for the plugin as long as the information in the POM is complete, descriptive and accurate.

What is a module in a Maven project?

A Maven module is a sub-project. To create a Maven module you will need to already have a Maven project available. The parent project must have its Packaging option pre-configured to pom, for a module to be created and associated with it.


1 Answers

Since you do not want to use site generation for documentation, I think there is no other "maven official way" to perform it.

Packaging

From my point of view, you may use a standard POM packaging, zip it through maven-assembly-plugin and add a classfier (doc or everything else).

related questions

Here some information to accomplish it :

  • Maven best practice for creating ad hoc zip artifact.
  • Maven - Depend on assembled zip

Even if it's already OK, there is interesting point there.

pom.xml

<groupId>com.mycompany</groupId>
<artifactId>your-project</artifactId>
<version>1.1.0</version>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <id>doc-packaging</id>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <descriptors>
                            <descriptor>/src/main/assembly/doc.xml</descriptor>
                        </descriptors>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Assembly descriptor : It will produce this artifact : your-project-doc.zip :

  • this is (obviously) a zip archive
  • the "classifier" is doc (like assembly name)

Phase binding

Since pom doesn't have anything to prepare, you're right, there is no prepare-package phase (as per doc) . Indeed, your project aims to package doc ... so it would be correct to (re)bind your pdf plugin execution to package.

like image 60
Jean-Rémy Revy Avatar answered Oct 02 '22 22:10

Jean-Rémy Revy