How to use profiles with Maven and Android properly? -


my target use 2 different profiles different deployment phases (development, release), since release has example debug flag false while development has debug flag true. when build without profiles, works without problems. when put build section profile, eclipse complains following message: "project build error: unknown packaging: apk", although build works.

my questions are:

  • how can rid of error message when using profiles (there solutions @ work, not when using profiles).
  • is possible configure common configuration build base 2 profiles while "overriding" configs in profile itself? example profile 1 has <debug>true</debug> , profile 2 has <debug>false</debug> or have write whole build section in both profiles?

here pom.xml

<?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.mydomain</groupid>     <artifactid>myartifact</artifactid>     <version>1.0.0-snapshot</version>     <packaging>apk</packaging>     <name>my app</name>      <properties>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>         <platform.version>4.4.2</platform.version>         <android.version>19</android.version>         <android.plugin.version>3.8.2</android.plugin.version>         <java.version>1.6</java.version>         <android.sdk.path>/opt/android-sdk-linux</android.sdk.path>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>         <project.reporting.outputencoding>utf-8</project.reporting.outputencoding>         <junit.version>4.8.2</junit.version>         <mockito.version>1.9.5</mockito.version>         <jackson.version>1.9.13</jackson.version>         <hamcrest.version>1.3</hamcrest.version>         <annotations.version>4.1.1.4</annotations.version>         <supportv4.version>r13</supportv4.version>     </properties>      <dependencies>         <dependency>             <groupid>com.google.android</groupid>             <artifactid>android</artifactid>             <version>${platform.version}</version>             <scope>provided</scope>         </dependency>         <dependency>             <groupid>com.google.android</groupid>             <artifactid>support-v4</artifactid>             <version>${supportv4.version}</version>         </dependency>         <dependency>             <groupid>com.nineoldandroids</groupid>             <artifactid>library</artifactid>             <version>2.4.0</version>         </dependency>         <!-- lint annotations -->         <dependency>             <groupid>com.google.android</groupid>             <artifactid>annotations</artifactid>             <version>${annotations.version}</version>         </dependency>          <dependency>             <groupid>org.codehaus.jackson</groupid>             <artifactid>jackson-mapper-asl</artifactid>             <version>${jackson.version}</version>         </dependency>          <!-- non android tests --><!-- hamcrest must before junit due build errors -->         <dependency>             <groupid>org.hamcrest</groupid>             <artifactid>hamcrest-all</artifactid>             <version>${hamcrest.version}</version>             <scope>test</scope>         </dependency>          <dependency>             <groupid>junit</groupid>             <artifactid>junit</artifactid>             <version>${junit.version}</version>             <scope>test</scope>         </dependency>          <dependency>             <groupid>org.mockito</groupid>             <artifactid>mockito-all</artifactid>             <version>${mockito.version}</version>             <scope>test</scope>         </dependency>          <dependency>             <groupid>org.powermock</groupid>             <artifactid>powermock-api-mockito</artifactid>             <version>1.5.1</version>         </dependency>          <dependency>             <groupid>org.powermock</groupid>             <artifactid>powermock-module-junit4</artifactid>             <version>1.5.1</version>         </dependency>     </dependencies>      <profiles>         <profile>             <id>devel</id>                 <build>                 <finalname>${project.artifactid}</finalname>                  <plugins>                     <plugin>                         <artifactid>maven-compiler-plugin</artifactid>                         <version>2.5.1</version>                         <configuration>                             <source>${java.version}</source>                             <target>${java.version}</target>                         </configuration>                     </plugin>                     <plugin>                         <artifactid>maven-jarsigner-plugin</artifactid>                         <version>1.2</version>                     </plugin>                     <plugin>                         <artifactid>maven-resources-plugin</artifactid>                         <version>2.5</version>                         <configuration>                             <encoding>utf-8</encoding>                         </configuration>                     </plugin>                     <plugin>                         <groupid>com.jayway.maven.plugins.android.generation2</groupid>                         <artifactid>android-maven-plugin</artifactid>                         <version>${android.plugin.version}</version>                         <extensions>true</extensions>                         <configuration>                             <androidmanifestfile>${project.basedir}/androidmanifest.xml</androidmanifestfile>                             <assetsdirectory>${project.basedir}/assets</assetsdirectory>                             <resourcedirectory>${project.basedir}/res</resourcedirectory>                             <nativelibrariesdirectory>${project.basedir}/src/main/native</nativelibrariesdirectory>                             <sdk>                                 <platform>${android.version}</platform>                                 <path>${android.sdk.path}</path>                             </sdk>                             <undeploybeforedeploy>false</undeploybeforedeploy>                             <sign>                                 <debug>true</debug>                             </sign>                         </configuration>                     </plugin>                 </plugins>             </build>             </profile>     </profiles> </project> 

i think looking for:

<profiles>     <profile>         <id>development</id>         <properties>             <debug>true</debug>         </properties>     </profile>     <profile>         <id>release</id>         <properties>             <debug>false</debug>         </properties>     </profile> </profiles>  <build>     <finalname>${project.artifactid}</finalname>      <plugins>         <plugin>             <artifactid>maven-compiler-plugin</artifactid>             <version>2.5.1</version>             <configuration>                 <source>${java.version}</source>                 <target>${java.version}</target>             </configuration>         </plugin>         <plugin>             <artifactid>maven-jarsigner-plugin</artifactid>             <version>1.2</version>         </plugin>         <plugin>             <artifactid>maven-resources-plugin</artifactid>             <version>2.5</version>             <configuration>                 <encoding>utf-8</encoding>             </configuration>         </plugin>         <plugin>             <groupid>com.jayway.maven.plugins.android.generation2</groupid>             <artifactid>android-maven-plugin</artifactid>             <version>${android.plugin.version}</version>             <extensions>true</extensions>             <configuration>                 <androidmanifestfile>${project.basedir}/androidmanifest.xml</androidmanifestfile>                 <assetsdirectory>${project.basedir}/assets</assetsdirectory>                 <resourcedirectory>${project.basedir}/res</resourcedirectory>                 <nativelibrariesdirectory>${project.basedir}/src/main/native</nativelibrariesdirectory>                 <sdk>                     <platform>${android.version}</platform>                     <path>${android.sdk.path}</path>                 </sdk>                 <undeploybeforedeploy>false</undeploybeforedeploy>                 <sign>                     <debug>${debug}</debug>                 </sign>             </configuration>         </plugin>     </plugins> </build> 

this way have 1 common build tag , 2 profiles, each profile specified whether debug or not via properties tag. when building specify profile this: -pdevelopment or -prelease. hope helps.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -