Search code examples
javamavenjavadocmaven-javadoc-plugin

Specify manifest file for Javadoc plugin


I recently started using Javadocs and have already encountered an issue: to which I cannot find a duplicate of. I'm attempting to attach my own MANIFEST.MF file to the Javadoc JAR file; unfortunately, this hasn't been working. I've tried several things (including using the maven-jar-plugin's archive configuration) however none of these 'solutions' have worked for me. No errors are thrown (I've checked with the advanced program arguments), and it seems Maven just forces its own MANIFEST.MF file into the JAR despite my explicit instructions not to. Checking the logs within the console also tells me that the javadoc plugin hasn't been doing anything related with the manifest.

Here's what I have so far:

<plugins>
ommitted ....
    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-jar-plugin</artifactId>
       <version>3.0.2</version>
       <configuration>
          <archive>
              <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
          </archive>
       </configuration>
    </plugin>


    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-javadoc-plugin</artifactId>
       <version>2.10.4</version>
       <executions>
         <execution>
            <id>attach-javadocs</id>
            <phase>package</phase>
            <goals>
               <goal>jar</goal>
            </goals>
         </execution>
       </executions>
    </plugin>
.... ommitted
</plugins>

I'm running Apache Maven 3.3.9 and Apache Ant 1.9.7 if that has any relevance.

Thanks.


Solution

  • This way you do you will only set the MANIFEST.MF for the jar plugin but not for the javadoc-plugin which needed to be configured separately..like this:

    <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-javadoc-plugin</artifactId>
       <version>2.10.4</version>
       <configuration>
          <archive>
              <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
          </archive>
       </configuration>
       <executions>
         <execution>
            <id>attach-javadocs</id>
            <phase>package</phase>
            <goals>
               <goal>jar</goal>
            </goals>
         </execution>
       </executions>
    </plugin>