maven 学习笔记(五)-创建简单的eclipse+android+maven工程(打包为aar文件)

eclipse安装好maven插件已经集成了android maven插件,如果使用intelli创建maven的 android工程需先安装android-quickstart、android-release、android-with-test等archetype.

        使用eclipse创建项目流程如下图:

        1、选择maven项目类型

          





        2、选择android-quickstart快速创建工程









       3、创建成功后,项目资源结构图如下:





       4、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>simple-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>aar</packaging>
    <name>simple-demo</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <platform.version> 4.1.1.4
            </platform.version>
        <android.plugin.version>4.0.0-rc.2</android.plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>${android.plugin.version}</version>
                    <extensions>true</extensions>
                                        <executions>
                        <!-- <execution> <id>run</id> <goals> <goal>deploy</goal> <goal>run</goal> 
                            </goals> <phase>install</phase> </execution> -->
                        <execution>
                            <id>alignApk</id>
                            <phase>install</phase>
                            <goals>
                                <goal>zipalign</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                             <assetsDirectory>${project.basedir}/assets</assetsDirectory>
                        <resourceDirectory>${project.basedir}/res</resourceDirectory>
                        <!-- 
                        <androidManifestFile>${project.build.directory}/filtered-manifest/AndroidManifest.xml</androidManifestFile>
                         -->
                         <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
                        <nativeLibrariesDirectory>${project.basedir}/libs</nativeLibrariesDirectory>
                        <!-- <proguardConfig>proguard.cfg</proguardConfig> -->
                        <proguardConfig>proguard-project.txt</proguardConfig>
                        <proguardSkip>${project.build.proguardSkip}</proguardSkip>
                        <manifestDebuggable>${manifest.debuggable}</manifestDebuggable>

                        <release>${project.build.release}</release>
                        <run>
                            <debug>${project.build.debug}</debug>
                        </run>
                        <runDebug>${project.build.runDebug}</runDebug>
                        <sign>
                            <debug>${project.build.sign.debug}</debug>
                        </sign>
                        <undeployBeforeDeploy>false</undeployBeforeDeploy>
                        <mergeManifests>true</mergeManifests>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                                    </configuration>
            </plugin>
        </plugins>
    </build>
</project>






        5、项目运行配置




 


   



      5、运行打包aar文件结果如下:




7、android项目引用aar文件配置如下:

 

<dependency>
            <groupId>com.special.demo</groupId>
            <artifactId>simple-demo</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <type>aar<type>
        </dependency>




8、demo地址下载链接地址如下:

       https://github.com/spring5555/mvn-android-simple-dem






阅读更多
个人分类: maven
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭