Maven creating flat zip assembly

后端 未结 1 1830
清酒与你
清酒与你 2021-01-07 18:15

To Maven gurus out there: I\'m trying to package non-java project artifacts (.NET) into a single zip file. I\'m having 2 problems:

If I change packaging in my POM to

相关标签:
1条回答
  • 2021-01-07 18:47

    As you've seen, there isn't a zip packaging type, so it makes sense to use pom packaging as you've chosen to.

    You've encountered a bit of a hole in the assembly plugin's processing. You could resolve this by specifying multiple fileSets in the assembly with <outputDirectory>/<outputDirectory>, one for each directory you want to include, this is obviously a PITA, and probably not an acceptable solution.

    An alternative approach is to use the Ant copy task to copy all the DLLs into a staging directory, then include that directory in the assembly.

    The following configuration should do what you're after:

    The antrun-plugin configuration:

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.3</version>
        <executions>
          <execution>
            <phase>process-resources</phase>
            <configuration>
              <tasks>
                <copy todir="${project.build.directory}/dll-staging">
                  <fileset dir="${basedir}/${project.artifactId}">
                    <include name="**/Bin/Release/*.dll"/>
                    <include name="**/Bin/Release/*.pdb"/>
                  </fileset>
                  <flattenmapper/>
                </copy>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    

    The assembly:

     <assembly>
      <id>bin</id>
      <formats>
        <format>zip</format>
      </formats>
      <fileSets>
        <fileSet>
          <directory>${project.build.directory}/dll-staging</directory>
          <outputDirectory>/</outputDirectory>
          <includes>
            <include>*.dll</include>
            <include>*.pdb</include>
          </includes>
        </fileSet>
      </fileSets>
    </assembly>
    
    0 讨论(0)
提交回复
热议问题