Android Maven Konfigurasyonu

21-07-2013
Android uygulamalarını Maven ile geliştirmek için gerekli olan ayarları yapmak gerekmektedir. Maven'in varsayılan klasör yapısından biraz farklı olan aşağıdaki klasör yapısı kullanılarak Android uygulamamızı Maven ile yapabiliriz. Bunun için gerekli olan konfigurasyonları sırasıyla inceleyelim:

Android-Maven klasör yapısı:

  • ProjeAdi
    • res
      • drawable-hdpi
      • drawable-ldpi
      • drawable-mdpi
      • layout
      • values
    • src
      • main
      • test
    • AndroidManifest.xml
    • pom.xml
Temel konfigurasyonların bulunduğu pom.xml dosyası:

<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <groupId>android_Maven</groupId>
    <artifactId>tutorial</artifactId>
    <version>1.0</version>
    <packaging>apk</packaging>
    <dependencies>
       <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>2.3.3</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>3.0.0</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
        </pluginManagement>
         <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <run>
                        <debug>true</debug>
                    </run>
                    <sdk>
                        <path>C:\PROGRA~1\Android\android-sdk</path>
                        <platform>15</platform>
                    </sdk>
                    <emulator>
                        <avd>16</avd>
                    </emulator>
                    <undeployBeforeDeploy>true</undeployBeforeDeploy>
                </configuration>
                <executions>
                    <execution>
                        <id>android-deploy</id>
                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
 
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.3.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.6</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.3.1</version>
            </plugin>
        </plugins>
    </build>
</project>


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="mucayufa.android.helloWorld"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:label="@string/app_name" android:icon="@drawable/icon">
        <activity android:name=".Main"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>


Tüm bu konfigürasyonların bulunduğu örnek projeyi indirmek için tıklayınız

© 2019 Tüm Hakları Saklıdır. Codesenior.COM