程序集插件不替代maven属性

时间:2014-06-02 11:40:40

标签: maven maven-3 maven-assembly-plugin

我试图让maven程序集插件自动添加文档 到产品的最终ZIP文件。 POM文件如下所示:

<!-- Build configuration. -->
  <build>
    <plugins>
      <!-- Assembly plugin. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <appendAssemblyId>false</appendAssemblyId>
              <includeProjectArtifact>false</includeProjectArtifact>
              <archiveBaseDirectory>/</archiveBaseDirectory>
              <descriptors>
                <descriptor>assembly.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Deploy plugin. 
           This artifact needs to be deployed.
           -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <configuration>
          <skip>false</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

assembly.xml如下所示:

<assembly 
  xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">

  <!-- Archive details. -->
  <id>fullzipfile</id>
  <formats>
    <format>zip</format>
  </formats>

  <!-- Component descriptors. -->
  <componentDescriptors>
    <componentDescriptor>assembly-gdbserver.xml</componentDescriptor>
    <componentDescriptor>assembly-gdbws.xml</componentDescriptor>
    <componentDescriptor>assembly-gothic.xml</componentDescriptor>
    <componentDescriptor>assembly-resources.xml</componentDescriptor>
    <componentDescriptor>assembly-weblogic.xml</componentDescriptor>
    <componentDescriptor>assembly-docs.xml</componentDescriptor>
  </componentDescriptors>
</assembly>

,assembly-docs.xml如下所示:

<component
  xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/component/1.1.2 http://maven.apache.org/xsd/component-1.1.2.xsd">
  <fileSets>
    <fileSet>
      <directory>${basedir}/Documentation</directory>
      <outputDirectory>Documentation</outputDirectory>
    </fileSet>
  </fileSets>
</component>

我让这个工作的唯一方法是用实际的全部替换$ {basedir} 我机器上Documentation文档目录的路径。这不适用于我们的CI 环境。我也试过$ {project.basedir}。

此时我的ZIP中的Documentation目录中没有任何内容。没有3 目录中存在的PDF文件将被复制。

1 个答案:

答案 0 :(得分:2)

删除pom.xml中的以下行

<archiveBaseDirectory>/</archiveBaseDirectory>

解决了这个问题。不知道为什么,但确实如此。