Maven汇编参考父项目?

时间:2012-08-08 09:26:50

标签: maven maven-assembly-plugin

我正在尝试将我的程序集(从专用子项目运行)包含已由父项聚合的Javadoc。不幸的是,当我尝试在parentSet中包含父项时,它在程序集中被忽略,如下所示:

[WARNING] The following patterns were never triggered in this artifact inclusion
filter:
o  'com.company.foo.product:foo-java-product'

我怀疑这是因为父在技术上不是“模块”,但我想不出任何其他方式来引用父目标目录中的javadoc。我从子模块运行程序集的原因是,当从父pom.xml运行时,我无法使dependencySet工作(实际上与上面的类似错误)。

有人可以推荐一个解决方案吗?

这是我的程序集文件(已经成功获取了我想要的源代码和依赖项):

<assembly>
  <id>dist</id>
  <formats>
    <format>dir</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <moduleSets>
    <!-- Include Javadoc -->
    <moduleSet>
        <useAllReactorProjects>true</useAllReactorProjects>
        <includes>
            <include>com.company.foo.product:foo-java-product</include>
        </includes>
        <sources>
            <includeModuleDirectory>false</includeModuleDirectory>
            <fileSets>
                <fileSet>
                    <outputDirectory>docs/Javadoc</outputDirectory>
                    <directory>target/site</directory>
                </fileSet>
            </fileSets>
        </sources>
    </moduleSet>
    <!-- Include sources for sample project tests-->
    <moduleSet>
        <useAllReactorProjects>true</useAllReactorProjects>
        <includes>
            <include>com.company.foo.product:samples</include>
        </includes>
        <sources>
            <includeModuleDirectory>false</includeModuleDirectory>
            <fileSets>
                <fileSet>
                    <outputDirectory>source</outputDirectory>
                    <directory>src/test/java</directory>
                    <includes>
                        <include>com/company/foo/samples/Sample*.java</include>
                    </includes>
                </fileSet>
            </fileSets>
        </sources>
    </moduleSet>
  </moduleSets>
  <dependencySets>
    <!-- Include 3rd Party Dependencies -->
    <dependencySet>
        <excludes>
            <exclude>com.company.foo.product:common</exclude>
            <exclude>com.company.foo.product:consumer</exclude>
            <exclude>com.company.foo.product:publisher</exclude>
            <exclude>com.company.foo.product:samples</exclude>
        </excludes>
        <outputDirectory>lib</outputDirectory>
        <useProjectArtifact>false</useProjectArtifact>
    </dependencySet>
  </dependencySets>
</assembly>

这是app-distribution pom.xml

<project>
  <parent>
    <groupId>com.company.foo.product</groupId>
    <artifactId>foo-java-product</artifactId>
    <version>0.5-SNAPSHOT</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>app-distribution</artifactId>
  <name>app-distribution</name>
  <packaging>pom</packaging>
  <dependencies>
    <dependency>
        <groupId>com.company.foo.product</groupId>
        <artifactId>consumer</artifactId>
    </dependency>
    <dependency>
        <groupId>com.company.foo.product</groupId>
        <artifactId>publisher</artifactId>
    </dependency>
    <dependency>
        <groupId>com.company.foo.product</groupId>
        <artifactId>samples</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <descriptors>
                    <descriptor>assemblies/sources.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
  </build>
</project>

我的父pom.xml看起来像这样:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.company.foo.product</groupId>
  <artifactId>foo-java-product</artifactId>
  <version>0.5-SNAPSHOT</version>
  <packaging>pom</packaging>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>
  <modules>
    <module>Common</module>
    <module>Consumer</module>
    <module>Publisher</module>
    <module>Samples</module>
    <module>app-distribution</module>
  </modules>
  <build>
    <pluginManagement>
        <plugins>
            ...
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.8.1</version>
            <configuration>
                <quiet>true</quiet>
                <stylesheet>maven</stylesheet>
                <splitindex>true</splitindex>

            </configuration>
            <executions>
                <execution>
                    <id>javadoc-jar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!--
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <descriptors>
                    <descriptor>assemblies/sources.xml</descriptor>
                </descriptors>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        -->
    </plugins>

  </build>
  <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.company.foo.product</groupId>
            <artifactId>common</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.company.foo.product</groupId>
            <artifactId>publisher</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.company.foo.product</groupId>
            <artifactId>consumer</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.company.foo.product</groupId>
            <artifactId>samples</artifactId>
            <version>${project.version}</version>
        </dependency>
  </dependencyManagement>
</project>

0 个答案:

没有答案