简体   繁体   中英

How to create assemble with multi-module project in maven

I have multi-module Maven project. Part of modules are libraries and part are executables. I have created assemble module and attached it to the end of the module list. The assemble module configuration looks like this:

<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>

I have also created assembe file 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>

Unfortunately, then I run the assemble with mvn package. I receive this error:

Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single (make-assembly) on project assemble: Failed to create assembly: Error creating assembly archive bin: You must set at least one file.

Just solved that.

It turns out what my maven-assembly-plugin was just missing version number:

<version>2.5.5</version>

Also bin.xml was missing dependencies as well:

<useAllReactorProjects>true</useAllReactorProjects> 

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

After that everything star magically work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM