Search code examples
javamavenmaven-assembly-plugin

Include parents documentation into zip-file


I have a multimodule maven project and I want to create an ZIP-File in the end which contains an .ear and the documentation.

The documentation is made with docbkx and is part of the parent. The .ear file is made in a module.

My structure:

partent
|-src/docbkx
|-moduleEJB
|-moduleEAR

Where I am now?

  1. I can create an ZIP including my ear (using mvn clean package)
  2. I can create the PDF output of my documentation (using mvn clean site)

I want now to include the generated PDF of my documentation into my ZIP-file. How can I achieve that? I tried to include the target directory of my parent project but nothing happened - which seems logical because when I run mvn clean package the documentation PDF isn't made as it's part of the pre-sitelifecycle.

This is my assembly.xml

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
  <id>bin</id>
  <formats>
    <format>zip</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <includes>
        <include>*.ear</include>
      </includes>      
      <outputDirectory>/</outputDirectory>
    </fileSet>
    <fileSet>
      <directory>${parent.project.build.directory}/docbkx/pdf</directory>
      <includes>
        <include>*.pdf</include>
      </includes>      
      <outputDirectory>docs/</outputDirectory>
    </fileSet>        
  </fileSets>
</assembly>

This is the part of docbooks execution of my parent.pom:

            <executions>
                <execution>
                    <phase>pre-site</phase>
                    <goals>
                        <goal>generate-pdf</goal>
                    </goals>
                    <configuration>
                    </configuration>
                </execution>
            </executions>

Thanks in advance

edit: I also tried to change the phase of docbkx to compile but still nothing in my final zip.


Solution

  • I got it myself. As the parent project is the last to build I created a new project named documentation to create the PDF. I then added this to the zip using a fileset

    <fileSet>
      <directory>${project.build.directory}/../../documentation/target/docbkx/pdf</directory>
      <includes>
        <include>*.pdf</include>
      </includes>      
      <outputDirectory>docs/</outputDirectory>
    </fileSet>