maven 学习笔记(七)-(完整Android项目多渠道打包、签名、混淆进阶)

       一、签名 

      1.在文件pom.xml添加一下内容

<?xml version="1.0" encoding="UTF-8"?>
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
  <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <platform.version> 4.1.1.4
        </platform.version>

        <annotations.version>4.1.1.4</annotations.version>
        <android.plugin.version>4.0.0-rc.2</android.plugin.version>
        <keystore.filename>keystore/android-demo.keystore</keystore.filename>
        <keystore.storepass>demo2015</keystore.storepass>
        <keystore.keypass>demo2015</keystore.keypass>
        <keystore.alias>android-demo.keystore</keystore.alias>
    </properties>

  <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jarsigner-plugin</artifactId>
                        <version>1.2</version>
                        <executions>
                            <execution>
                                <id>sign</id>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <phase>package</phase>
                                <inherited>true</inherited>
                                <configuration>
                                    <includes>
                                        <include>${project.build.outputDirectory}/*.apk</include>
                                    </includes>
                                    <!-- 移除已存在的签名(android debug的签名) -->
                                    <removeExistingSignatures>true</removeExistingSignatures>
                                    <keystore>${keystore.filename}</keystore>
                                    <storepass>${keystore.storepass}</storepass>
                                    <keypass>${keystore.keypass}</keypass>
                                    <alias>${keystore.alias}</alias>

                                </configuration>
                            </execution>
                        </executions>
                    </plugin>




      2.打包自动传递到ftp服务器配置,在pox.xml添加一下内容

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>wagon-maven-plugin</artifactId>
                <version>1.0-beta-4</version>
                <executions>
                    <execution>
                        <id>upload_apk</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>upload-single</goal>
                        </goals>
                        <configuration>
                            <serverId>ftp-repository</serverId>
                            <url>ftp://demo.de.com:2690/ftproot/update/app/android/demo</url>
                            <fromFile>${basedir}/target/${project.artifactId}-${manifest.metadata.id}-${project.version}.apk</fromFile>
                            <toFile>${project.name}_${project.version}_${app.channel}.apk</toFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>



3.多渠道打包,在pox.xml添加一下内容

        <!-- 渠道profiles -->
        <profile>
            <id>channel-test</id>

            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <manifest.metadata.id>test</manifest.metadata.id>
                <manifest.metadata.channel>test market</manifest.metadata.channel>
            </properties>
        </profile>
        <profile>
            <id>channel-baidu</id>
            <properties>
                <manifest.metadata.id>baidu</manifest.metadata.id>
                <manifest.metadata.channel>baidu</manifest.metadata.channel>
            </properties>
        </profile>




3.pom.xml文件如下如下:

<?xml version="1.0" encoding="UTF-8"?>

<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
    <groupId>com.special.demo</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>dem
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值