使用Jenkins进行android项目的自动构建(2)_项目管理_非技术区_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 非技术区 > 项目管理 > 使用Jenkins进行android项目的自动构建(2)

使用Jenkins进行android项目的自动构建(2)

 2014/5/21 14:09:41  pasco  博客园  我要评论(0)
  • 摘要:MavenandPOM1.什么是Maven?官方的解释是:http://maven.apache.org/guides/getting-started/index.html#What_is_Maven2.什么是POM官方的解释是:http://maven.apache.org/pom.html#What_is_the_POM3.POM的具体例子<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven
  • 标签:android 使用 项目

Maven and POM

 

1. 什么是Maven?

官方的解释是: http://maven.apache.org/guides/getting-started/index.html#What_is_Maven

 

2. 什么是POM

官方的解释是: http://maven.apache.org/pom.html#What_is_the_POM

 

3. POM的具体例子

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="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.example.demo</groupId>
    <artifactId>maven-demo</artifactId>
    <version>1.0.0</version>
    <packaging>apk</packaging>

    <dependencies>
        <!-- 加入android依赖,scope=provided -->
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <!-- 加入facebook依赖,type=aar -->
        <dependency>
            <groupId>fr.avianey</groupId>
            <artifactId>facebook-android-api</artifactId>
            <version>3.8.0</version>
            <type>aar</type>
        </dependency>
        <!-- 加入android support依赖 -->
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>support-v4</artifactId>
            <version>r7</version>
        </dependency>
        <!-- 加入junit依赖,scope=test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    
    <properties>  
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.build.timestamp.format>yyyy-MM-dd-HH-mm-ss</maven.build.timestamp.format><!-- 增加一个时间戳的属性,生成的apk名可以加入该属性 -->
    </properties>
    
    <profiles>  
        <profile>
            <id>dev</id>
            <properties>
                <package.type>dev</package.type><!-- 增加一个包类型的属性,mvn命令以参数-P传入,生成的apk名可以加入该属性 -->
            </properties>
            <build>
                <!-- 打包后替换apk中的指定文件 -->
                <!--
                <resources>
                    <resource>
                        <directory>res\values\dev</directory>
                        <targetPath>config</targetPath>
                        <includes>
                            <include>strings.*</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>res\layout</directory>
                        <filtering>true</filtering>
                        <includes>
                            <include>*.*</include>
                        </includes>
                    </resource>
                </resources>
                -->
            </build>
        </profile>

        <profile>
            <id>prod</id>
            <properties>
                <package.type>prod</package.type><!-- 增加一个包类型的属性,mvn命令以参数-P传入,生成的apk名可以加入该属性 -->
            </properties>
                <build><!--
                <resources>
                    <resource>
                        <directory>res\values\prod</directory>
                        <targetPath>config</targetPath> 
                        <includes>
                        <include>*.*</include>
                        </includes>
                    </resource>
                </resources>-->
            </build>
        </profile>
    </profiles>
  
    <build>
        <sourceDirectory>src</sourceDirectory><!-- 源代码目录 -->
        <testSourceDirectory>test</testSourceDirectory><!-- 测试代码目录 -->
        <finalName>${project.artifactId}_${project.version}_${package.type}_${maven.build.timestamp}</finalName><!-- 生成的apk文件名 -->
        <plugins>
            <!-- android-maven-plugin,打包apk -->
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.8.2</version>
                <configuration>
                    <sdk>
                        <platform>19</platform>
                        <!--
                        <path>D:\adt-bundle\sdk</path>
                        -->
                    </sdk>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                    <sign>
                        <debug>false</debug><!-- 生成未签名的apk -->
                    </sign>
                </configuration>
                <extensions>true</extensions>
                <inherited>true</inherited>
            </plugin>
            <!-- maven-jarsigner-plugin,用于创建签名 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jarsigner-plugin</artifactId>
                <version>1.3.2</version>
                <executions>
                    <execution>
                        <id>signing</id>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <phase>package</phase>
                        <inherited>true</inherited>
                        <configuration>
                            <archiveDirectory></archiveDirectory>
                            <includes>
                                <include>${project.artifactId}_${project.version}_${package.type}_${maven.build.timestamp}.apk</include><!-- 用于签名的apk -->
                            </includes>
                            <keystore>D:\keys\key.store</keystore><!-- keystore位置 -->
                            <storepass>123456</storepass><!-- store密码 -->
                            <keypass>123456</keypass><!-- key密码-->
                            <alias>maven_demo</alias><!-- alias -->
                            <verbose>false</verbose><!-- 是否输出过程讯息 -->
                            <!-- 指定加密算法 -->
                            <arguments>
                                <argument>-sigalg</argument><argument>MD5withRSA</argument>
                                <argument>-digestalg</argument><argument>SHA1</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

 

上一篇: 雷军:小米成功是学了马云的三大秘诀 下一篇: 没有下一篇了!
发表评论
用户名: 匿名