Bos*_*one 20 zip maven-2 assemblies
对于那里的Maven大师:我正在尝试将非java项目工件(.NET)打包到一个zip文件中.我有两个问题:
如果我将POM中的包装更改为zip <packaging>zip</packaging>,我会收到以下错误消息:[INFO] Cannot find lifecycle mapping for packaging: 'zip'.
Component descriptor cannot be found in the component repository: org.apache.mav
en.lifecycle.mapping.LifecycleMappingzip.好的,没什么大不了的 - 我把它更改<packaging>pom</packaging>为去除在目标目录中创建的无用jar
我的主要问题是我打包成ZIP的文件嵌套在几个目录中,但我需要把它们放到ZIP的顶级目录中.这是我的汇编文件:
<assembly>
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${basedir}/${project.artifactId}</directory>
<includes>
<include>**/Bin/Release/*.dll</include>
<include>**/Bin/Release/*.pdb</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)
当我运行这个 - 我将获得ZIP文件,但文件将嵌套,从C:\开始,然后是完整路径.为了给你提供想法 - 项目将二进制文件转储到以下结构中
ProjectFoo\ProjectFoo\subproject1\Bin\Release\foo.dll,我需要ZIP\foo.dll
这是程序集插件配置:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
Run Code Online (Sandbox Code Playgroud)
也许我只需要使用antrun并执行ant zip任务?
Ric*_*ler 28
如您所见,没有拉链包装类型,因此您可以选择使用pom包装.
你在组装插件的处理过程中遇到了一些漏洞.您可以通过在程序集中指定多个fileSets来解决此问题<outputDirectory>/<outputDirectory>,对于要包含的每个目录,可以使用一个,这显然是PITA,可能不是可接受的解决方案.
另一种方法是使用Ant复制任务将所有DLL复制到临时目录,然后在程序集中包含该目录.
以下配置应该做你想要的:
antrun-plugin配置:
<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>
Run Code Online (Sandbox Code Playgroud)
大会:
<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>
Run Code Online (Sandbox Code Playgroud)