多模块项目构建过程中的Maven构建错误

时间:2014-05-29 07:32:42

标签: java eclipse maven

我正在研究多模块Maven项目。在编译期间,我的 pom.xml 会抛出以下错误:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal
org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack (unpack) on project Test2: The parameters 'artifactItems' for goal
org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack are missing or invalid.

如何摆脱上述错误? Test2 项目的 pom.xml 如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <artifactId>Test1</artifactId>
    <groupId>com.photon.phresco</groupId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>

  <groupId>com.photon.phresco</groupId>
  <artifactId>Test2</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <name>Test2</name>
  <packaging>war</packaging>

  <dependencies>
    <dependency>
      <groupId>net.awired.js</groupId>
      <artifactId>almond</artifactId>
      <version>0.1.4</version>
      <type>war</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.awired.js</groupId>
      <artifactId>jquery</artifactId>
      <version>1.7.2</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>jslibraries.files</groupId>
      <artifactId>jslib_jquery-amd</artifactId>
      <version>1.7.1-alpha-1</version>
      <type>js</type>
    </dependency>
    <dependency>
      <groupId>jslibraries.files.history</groupId>
      <artifactId>jslib_jquery.hashable</artifactId>
      <version>1.0.0</version>
      <type>js</type>
    </dependency>
    <dependency>
      <groupId>jslibraries.files</groupId>
      <artifactId>jslib_xml2json-amd</artifactId>
      <version>1.1</version>
      <type>js</type>
    </dependency>
    <dependency>
      <groupId>jslibraries.files</groupId>
      <artifactId>jslib_jquery-ui-amd</artifactId>
      <version>1.8.16-alpha-1</version>
      <type>js</type>
    </dependency>
    <dependency>
      <groupId>jslibraries.files</groupId>
      <artifactId>jslib_jsonpath-amd</artifactId>
      <version>0.8.0</version>
      <type>js</type>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.7</version>
      <type>jar</type>
    </dependency>
    <dependency>
      <groupId>net.awired.js</groupId>
      <artifactId>qunit</artifactId>
      <version>1.12.0</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>jslibraries.files</groupId>
      <artifactId>jslib_yui</artifactId>
      <version>3.7.2</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.2.2</version>
      <type>jar</type>
    </dependency>
  </dependencies>

  <distributionManagement>
    <repository>
      <id>TestMultiModule-release</id>
      <url>http://host:port/repository/content/repositories/dep-3-2/</url>
    </repository>
    <snapshotRepository>
      <id>TestMultiModule-snapshot</id>
      <url>http://host:port/repository/content/repositories/snapshots/</url>
    </snapshotRepository>
  </distributionManagement>

  <build>
    <sourceDirectory>/src/main/java</sourceDirectory>
    <testSourceDirectory>/src/test/java</testSourceDirectory>
    <directory>do_not_checkin/target</directory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <excludeScope>provided</excludeScope>
              <includeTypes>jar</includeTypes>
              <outputDirectory>do_not_checkin/target/lib</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>compile</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-5</version>
        <executions>
          <execution>
            <id>create-war</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <appendAssemblyId>false</appendAssemblyId>
              <descriptors>
                <descriptor>conf/war-config.xml</descriptor>
                <descriptor>conf/zip-config.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>net.awired.jstest</groupId>
        <artifactId>jstest-maven-plugin</artifactId>
        <version>3.3.1.7000</version>
        <executions>
          <execution>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <reportDir>do_not_checkin/jstest/report</reportDir>
          <runnerType>ALMOND</runnerType>
          <coverage>true</coverage>
          <skipTests>${js.skipTest}</skipTests>
          <sourceExcludes>
            <sourceExclude>eshop/widgets/Init.js</sourceExclude>
            <sourceExclude>**/**.min.js</sourceExclude>
            <sourceExclude>**/**-min.js</sourceExclude>
          </sourceExcludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>yuicompressor-maven-plugin</artifactId>
        <version>1.3.0</version>
        <configuration>
          <skip>true</skip>
        </configuration>
        <executions>
          <execution>
            <id>yuicompressor-default</id>
            <goals>
              <goal>compress</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

1 个答案:

答案 0 :(得分:1)

您错过了artifactItems配置

        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>[ groupId ]</groupId>
              <artifactId>[ artifactId ]</artifactId>
              <version>[ version ]</version>
              <type>[ packaging ]</type>
              <classifier> [classifier - optional] </classifier>
              <overWrite>[ true or false ]</overWrite>
              <outputDirectory>[ output directory ]</outputDirectory>
              <destFileName>[ filename ]</destFileName>
            </artifactItem>
          </artifactItems>
          <!-- other configurations here -->
        </configuration>

您是否阅读过官方文档:

http://maven.apache.org/plugins/maven-dependency-plugin/usage.html

见这个例子:

      <executions>
            <execution>
                <id>default-cli</id>
                <configuration>
                    <artifactItems>
                        <artifactItem>
                            <!-- hardcode values, or use properties, depending on what you want
                                to do -->
                            <groupId>TestMaven</groupId>
                            <artifactId>TestMaven</artifactId>
                            <version>0.0.1-SNAPSHOT</version>
                            <type>[ packaging ]</type>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </artifactItem>
                    </artifactItems>
                    <!-- other configurations here -->
                </configuration>
            </execution>
        </executions>