基于assembly打包
-
正确方式:安装sofa插件后,创建sofa动态模块project,使用命令:mvn clean package -Dskip=test
-
工具:intelij idea
pom中指定assembly
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<finalName>${dynamic.module.name}</finalName>
<descriptors>
<descriptor>src/main/resources/assemble/assembly.xml</descriptor>
</descriptors>
<attach>false</attach>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
打包配置文件不一定非要放在 resources/assemble 目录下,可以直接修改原模块中的 assembly.xml 配置文件,然后将 POM 中打包插件的 descriptor 指向正确的 assembly.xml 文件即可
排除jar打包
原因:由于动态模块zip包是否需要依赖的jar包,可以通过全局配置allowImportedJar设置,如果为false,当zip包目录结构中存在jar包,就会报错,因此需要打包时,排除jar。
方法:在assembly.xml中加入<exclude>*</exclude>标签
<id>dynamicdemo</id>
<formats>
<format>zip</format>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<excludes>
<exclude>com.alipay.sofa:sofa-dynamic-module-*</exclude>
<exclude>com.alipay.sofa:sofa-runtime-*</exclude>
<exclude>com.alipay.sofa.runtime:*</exclude>
<exclude>com.alipay.sofa:sofa-rpc-*</exclude>
<exclude>com.alipay.cloudengine.*</exclude>
<exclude>com.alipay.drm:drm-client</exclude>
<exclude>com.alipay.system:alipay-system-event</exclude>
<exclude>com.taobao.notify:notify-tr-*</exclude>
<exclude>org.codehaus.xfire:xfire-all</exclude>
<exclude>org.apache.velocity:com.springsource.org.apache.velocity</exclude>
<exclude>org.apache.velocity:velocity</exclude>
<exclude>velocity:velocity</exclude>
<exclude>*</exclude>
</excludes>
<!-- <outputDirectory>lib</outputDirectory>-->
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>target/classes/</directory>
<outputDirectory>classes</outputDirectory>
</fileSet>
</fileSets>
zip包错误
全局配置,bundle验证开启,zip包已经上传,但是依然找不到文件
以下为错误方式
-
zip的打包方式有问题,比如windows本地使用打包工具打包
-
直接修改zip包名称
-
打包方式错误,直接对class、lib文件打包