不能通过maven-plugins既不生成javadoc也不生成源代码?

时间:2017-06-13 08:09:17

标签: maven intellij-idea javadoc maven-javadoc-plugin

我想从javadoc IDE中的代码生成Intellij idea 我一步一步地走过This link。但是我得不到合适的结果。

但是在执行mvn package之后,目标文件夹下没有attach-source-javadoc-1.0-SNAPSHOT-javadoc.jarattach-source-javadoc-1.0-SNAPSHOT-sources.jar文件。

这是整个pom文件:

  <?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>

1 个答案:

答案 0 :(得分:1)

您已将插件添加到<pluginManagement&gt;没有执行。

通过maven-plugins生成javadocsource code 你必须直接把它放在<plugins>里面:

<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>