0

我有不同的独立 maven 项目,想用单个 pom 构建它。所以我正在使用以下pom

<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>
<groupId>a.b</groupId>
<artifactId>my-sdk</artifactId>
<name>my-sdk</name>
<version>1.0</version>
<packaging>pom</packaging>
<description>Generating SDK</description>

<modules>
    <module>project1</module>
    <module>project2</module>
    <module>project3</module>
</modules>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.9</version>
            <executions>
                <execution>
                    <id>process-sources</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <configuration>
                        <tasks>
                            <ant antfile="build.xml" target="init" />
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>jboss-repo</id>
        <url>http://repository.jboss.org/maven2</url>
    </repository>
</repositories>

我有以下问题:-

  1. Javadoc 没有生成,所以我做错了。如果我运行“mvn javadoc:javadoc package”命令,它会生成 java doc。但如果我运行“mvn package”,它不会。

  2. 在project2中有生成fat jar的汇编插件,它生成project2的jar但无法生成fat jar。如果我独立构建project2,它会成功生成fat jar。

以下部分来自 project2 pom 以生成胖 jar,如果我独立运行构建,它会成功运行

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <appendAssemblyId>false</appendAssemblyId>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>[MAIN CLASS]</mainClass>
                            </manifest>
                            <manifestEntries>
                                <Class-Path>.</Class-Path>
                            </manifestEntries>
                        </archive>
                    </configuration>
                    <goals>
                        <goal>assembly</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

有什么建议么。

4

1 回答 1

0

我会说检查你的两个问题的文档;-)

javadoc ( http://maven.apache.org/plugins/maven-javadoc-plugin/plugin-info.html )

javadoc:jarjavadoc:javadoc不应用于聚合器项目,请使用javadoc:aggregate或(在您的情况下)javadoc:aggregate-jar

程序集http://maven.apache.org/plugins/maven-assembly-plugin/assembly-mojo.html

首先,assembly:assembly已弃用,其次,它只能在命令行上使用。我想使用目标会有所帮助。

于 2013-09-26T18:18:43.193 回答