sofa 动态bundle打包

基于assembly打包

  1. 正确方式:安装sofa插件后,创建sofa动态模块project,使用命令:mvn clean package -Dskip=test

  2. 工具: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包已经上传,但是依然找不到文件

以下为错误方式

  1. zip的打包方式有问题,比如windows本地使用打包工具打包

  2. 直接修改zip包名称

  3. 打包方式错误,直接对class、lib文件打包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值