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

问题描述 投票:1回答:1

我想从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>
maven intellij-idea javadoc maven-javadoc-plugin
1个回答
1
投票

您已将插件添加到未执行的<pluginManagement>中。

通过maven-plugins生成javadocsource code 你必须把它放在<plugins>direct内:

<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>
© www.soinside.com 2019 - 2024. All rights reserved.