1

I want to generate javadoc from my code in Intellij idea IDE.
I'm going step by step by This link. but I don't get the appropriate result.

But after doing mvn package there was no neither attach-source-javadoc-1.0-SNAPSHOT-javadoc.jar nor attach-source-javadoc-1.0-SNAPSHOT-sources.jar files under target folder.

This is the whole pom file:

  <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <packaging>war</packaging>
        <groupId>gdg</groupId>
        <artifactId>dfgdfg</artifactId>
        <version>1.0-SNAPSHOT</version>
        <properties>
         ...........
    </properties>

    <dependencies>

         ...............
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <skip>true</skip>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>


                </plugin>
                </plugins>
            </pluginManagement>
        </build>

    </project>
Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
ShakibaZar
  • 727
  • 3
  • 9
  • 27
  • Additionally to @Jens answer I here add URLs as a reference [Generate **javadoc jar** for maven based project](https://www.mkyong.com/maven/generate-javadoc-jar-for-maven-based-project/) [Generate **source code** jar for maven based project](https://www.mkyong.com/maven/generate-source-code-jar-for-maven-based-project/) Also in each plugin, you can define a `` property. – Ahmed Nabil Mar 22 '19 at 16:50

1 Answers1

2

You have added the plugin to the <pluginManagement> which is not executed.

To generate both javadoc and source code via maven-plugins
You have to put this inside <plugins>directly:

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-sources</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <failOnError>false</failOnError>
            </configuration>
        </plugin>

    </plugins>
</build>
Ahmed Nabil
  • 17,392
  • 11
  • 61
  • 88
Jens
  • 67,715
  • 15
  • 98
  • 113