如何在maven

时间:2015-08-27 22:42:09

标签: java maven maven-assembly-plugin

我有多模块Maven项目。部分模块是库,部分是可执行文件。我创建了汇编模块并将其附加到模块列表的末尾。汇编模块配置如下所示:

<build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
    <!--   <version>1.1.3</version> -->
        <configuration>
          <descriptor>src/assembly/bin.xml</descriptor>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id> 
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins> 
  </build>

  <dependencies>
    <!-- all dependencies -->
  </dependencies>

我还创建了assembe文件src / assemble / bin.xml:

<id>bin</id>
  <formats>
    <format>dir</format> 
    <format>tar.gz</format> 
    <format>tar.bz2</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <fileSets>
    <fileSet>
      <directory>${project.basedir}</directory>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>README*</include>
        <include>LICENSE*</include>
        <include>NOTICE*</include>
        <include>properties*/</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}</directory>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>*.jar</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>${project.build.directory}/jars</directory>
      <outputDirectory>jars</outputDirectory>
    </fileSet>
  </fileSets> 
  <moduleSets>
    <moduleSet>
        <binaries>
        <unpack>false</unpack>
        <dependencySets>
          <dependencySet>
            <unpack>false</unpack>
            <scope>compile</scope>
            <outputDirectory>jars</outputDirectory>
          </dependencySet>
        </dependencySets>
      </binaries>   
    </moduleSet>
  </moduleSets>

不幸的是,然后我用mvn包运行汇编。我收到此错误:

无法执行目标org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:单个(make-assembly)项目汇编:无法创建汇编:创建汇编归档bin时出错:您必须至少设置一个文件。

1 个答案:

答案 0 :(得分:1)

刚刚解决了这个问题。

事实证明我的maven-assembly-plugin缺少版本号:

<version>2.5.5</version>

bin.xml也缺少依赖项:

<useAllReactorProjects>true</useAllReactorProjects> 

<includes>
  <include>org.rdswitchbaord.importers:import_ands</include>
  <!-- etc -->
</includes> 

之后,所有明星都神奇地工作。