ログイン
編集不可のページディスカッション情報添付ファイル

2013-03-30 22:29:59時点のリビジョン8

メッセージを消す
alstamber/AndroidDevelopment/PragmaticDevelopmentEnvironment

MMA

なにこれ

前提

プロジェクトの生成

プロジェクトのmavenize

pom.xmlの記述

基本的記述と依存解決

   1 <groupId>(開発するアプリのパッケージ名)</groupId>
   2 <artifactId>(一意なID)</artifactId>
   3 <version>(バージョン)</version>
   4 <packaging>apk</packaging>
   5 <name>(名前)</name>

<dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android-test</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>org.roboguice</groupId>
            <artifactId>roboguice</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>gueei</groupId>
            <artifactId>android-binding</artifactId>
            <version>v30-0.52</version>
        </dependency>
</dependencies>

プロファイルを使ったビルド設定の切り替え

<profiles>
        <profile>
            <id><プロファイルの ID></id>
            <activation>
                <プロファイルが有効化する条件>
            </activation>
            <このプロファイルでの設定>
        </profile>
        <profile>
            ...
        </profile>
</profiles>

mvn -P hoge,fuga

<activeByDefault>true</activeByDefault>

プラグイン

<build>
    ...
    <plugins>
      ...
      <plugin>
        <groupId>プラグインのgroupId</groupId>
        <artifactId>プラグインのartifactId</artifactId>
        <version>プラグインのバージョン</version>
        <configuration>
            プラグインに渡すパラメータ
        </configuration>
      </plugin>
      ...
    </plugins>
    ...
</build>

<build>
   <pluginManager>
    <plugins>
      <plugin>
        <groupId>デフォルトプラグインのgroupId</groupId>
        <artifactId>デフォルトのartifactId</artifactId>
        <version>デフォルトのバージョン</version>
      </plugin>
      ...
    </plugins>
  </pluginManager>
</build>

<pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jarsigner-plugin</artifactId>
                    <version>1.2</version>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.4.0</version>
                </plugin>
            </plugins>
</pluginManagement>

<plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <manifest>
                        <debuggable>true</debuggable>
                    </manifest>
                    <sdk>
                       <platform>13</platform>
                    </sdk>
                </configuration>
                <executions>
                    <execution>
                        <id>manifestUpdate</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>manifest-update</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>alignApk</id>
                        <phase>package</phase>
                        <goals>
                            <goal>zipalign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
</plugins>

<profile>
            <id>development</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <deployment.stage>In Development</deployment.stage>
            </properties>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources.development</directory>
                    </resource>
                </resources>
            </build>
</profile>

<profile>
            <id>production</id>
            <properties>
                <deployment.stage>In Production</deployment.stage>
            </properties>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources.production</directory>
                    </resource>
                </resources>
            </build>
</profile>

<profile>
            <id>release</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <resources>
                    <resource>
                        <directory>src/main/resources.production</directory>
                    </resource>
                </resources>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jarsigner-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>signing</id>
                                <goals>
                                    <goal>sign</goal>
                                    <goal>verify</goal>
                                </goals>
                                <phase>package</phase>
                                <inherited>true</inherited>
                                <configuration>
                                    <removeExistingSignatures>true</removeExistingSignatures>
                                    <archiveDirectory/>
                                    <includes>
                                        <include>${project.build.directory}/${project.artifactId}.apk</include>
                                    </includes>
                                    <keystore>${sign.keystore}</keystore>
                                    <alias>${sign.alias}</alias>
                                    <storepass>${sign.storepass}</storepass>
                                    <keypass>${sign.keypass}</keypass>
                                    <verbose>true</verbose>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                        <artifactId>android-maven-plugin</artifactId>
                        <inherited>true</inherited>
                        <configuration>
                            <sign>
                                <debug>false</debug>
                            </sign>
                            <zipalign>
                                <verbose>true</verbose>
                                <inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk>
                                <outputApk>${project.build.directory}/${project.artifactId}-signed-aligned.apk
                                </outputApk>
                            </zipalign>
                            <manifest>
                                <debuggable>false</debuggable>
                                <versionCodeAutoIncrement>true</versionCodeAutoIncrement>
                            </manifest>
                            <proguard>
                                <skip>true</skip>
                            </proguard>
                        </configuration>
                        <executions>
                            <execution>
                                <id>manifestUpdate</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>manifest-update</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>alignApk</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>zipalign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
</profile>

署名鍵の設定

<?xml version="1.0" encoding="UTF-8"?>
 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
          http://maven.apache.org/xsd/settings-1.0.0.xsd">
   <profiles>
     <profile>
       <id>android</id>
       <properties>
         <android.sdk.path>(SDKのパス)</android.sdk.path>
         <sign.keystore>(keystoreのパス)</sign.keystore>
         <sign.alias>(keyのalias)</sign.alias>
         <sign.storepass>(keystoreのパス)</sign.storepass>
         <sign.keypass>(keyのパス)</sign.keypass>
       </properties>
     </profile>
   </profiles>

   <activeProfiles>
     <activeProfile>android</activeProfile>
   </activeProfiles>
</settings>

プロファイルごとのリソースxmlを用意する

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <entry key="profile">development</entry>
</properties>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <entry key="profile">production</entry>
</properties>

android-bindingを使ってみる

   1 TextBox.Select(0,0)