android-maven-plugin and resource filtering -
i'm newbie in maven , trying configure build android project android-maven-plugin. have application.properties file in assets directory contains different application settings. , want obtain values pom. in properties file define 1 property as
myfilteredproperty=${hellofrompom} and define same property in pom:
<properties> <hellofrompom>my property</hellofrompom> </properties> switched on filtering on assets dir
<build> ... <resources> <resource> <directory>${project.basedir}/assets</directory> <filtering>true</filtering> </resource> </resources> ... </build> and configure recources plugin in samples android-maven-plugin
<plugin> <artifactid>maven-resources-plugin</artifactid> <executions> <execution> <phase>initialize</phase> <goals> <goal>resources</goal> </goals> </execution> </executions> </plugin> but when i'm trying show toast in application property see ${hellofrompom} instead property.
in target directory generated maven see properties file in 2 places:
- /target/generated-sources/combined-assets/assets/application.properties
- /target/myapp-0.0.1-snapshot.apk\application.properties
first wrong, contains ${hellofrompom} instead property. second, inside apk file correct. when install apk on device show me wrong value ${hellofrompom}.
what did wrong?
edit
thanks answer, tryed it, error:
[error] error when generating sources. org.apache.maven.plugin.mojoexecutionexception: @ com.jayway.maven.plugins.android.phase01generatesources.generatesourcesmojo.generater(generatesourcesmojo.java:338) @ com.jayway.maven.plugins.android.phase01generatesources.generatesourcesmojo.execute(generatesourcesmojo.java:102) @ org.apache.maven.plugin.defaultbuildpluginmanager.executemojo(defaultbuildpluginmanager.java:101) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:209) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:153) @ org.apache.maven.lifecycle.internal.mojoexecutor.execute(mojoexecutor.java:145) @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:84) @ org.apache.maven.lifecycle.internal.lifecyclemodulebuilder.buildproject(lifecyclemodulebuilder.java:59) @ org.apache.maven.lifecycle.internal.lifecyclestarter.singlethreadedbuild(lifecyclestarter.java:183) @ org.apache.maven.lifecycle.internal.lifecyclestarter.execute(lifecyclestarter.java:161) @ org.apache.maven.defaultmaven.doexecute(defaultmaven.java:320) @ org.apache.maven.defaultmaven.execute(defaultmaven.java:156) @ org.apache.maven.cli.mavencli.execute(mavencli.java:537) @ org.apache.maven.cli.mavencli.domain(mavencli.java:196) @ org.apache.maven.cli.mavencli.main(mavencli.java:141) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.codehaus.plexus.classworlds.launcher.launcher.launchenhanced(launcher.java:290) @ org.codehaus.plexus.classworlds.launcher.launcher.launch(launcher.java:230) @ org.codehaus.plexus.classworlds.launcher.launcher.mainwithexitcode(launcher.java:409) @ org.codehaus.plexus.classworlds.launcher.launcher.main(launcher.java:352) @ org.codehaus.classworlds.launcher.main(launcher.java:47) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ com.intellij.rt.execution.application.appmain.main(appmain.java:120) caused by: com.jayway.maven.plugins.android.executionexception: android-040-001: not execute: command = cmd.exe /x /c ""c:\program files\android\android-sdk\platform-tools\aapt.exe" package -m -j d:\projects\myapp\target\generated-sources\r -m d:\projects\myapp\androidmanifest.xml -s d:\projects\myapp\target\filtered-assets --auto-add-overlay -a d:\projects\myapp\assets -i "c:\program files\android\android-sdk\platforms\android-8\android.jar"", result = 1 @ com.jayway.maven.plugins.android.commandexecutor$factory$1.executecommand(commandexecutor.java:215) @ com.jayway.maven.plugins.android.phase01generatesources.generatesourcesmojo.generater(generatesourcesmojo.java:336) ... 28 more [info] ------------------------------------------------------------------------ [info] build failure [info] ------------------------------------------------------------------------ [info] total time: 4.307s [info] finished at: wed jun 06 10:37:14 msk 2012 [info] final memory: 7m/16m [info] ------------------------------------------------------------------------ [error] failed execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.2.0:generate-sources (default-generate-sources) on project magent: mojoexecutionexception: android-040-001: not execute: command = cmd.exe /x /c ""c:\program files\android\android-sdk\platform-tools\aapt.exe" package -m -j d:\projects\myapp\target\generated-sources\r -m d:\projects\myapp\androidmanifest.xml -s d:\projects\myapp\target\filtered-assets --auto-add-overlay -a d:\projects\myapp\assets -i "c:\program files\android\android-sdk\platforms\android-8\android.jar"", result = 1 -> [help 1] [error] [error] see full stack trace of errors, re-run maven -e switch. [error] re-run maven using -x switch enable full debug logging. [error] [error] more information errors , possible solutions, please read following articles: [error] [help 1] http://cwiki.apache.org/confluence/display/maven/mojoexecutionexception
when comment <resourcedirectory>${project.build.directory}/filtered-assets</resourcedirectory> in pom, build finishing successfull, doesn't use filtered assests.
also try execute cmd.exe /x /c ""c:\program files\android\android-sdk\platform-tools\aapt.exe" package -m -j d:\projects\myapp\target\generated-sources\r -m d:\projects\myapp\androidmanifest.xml -s d:\projects\myapp\target\filtered-assets --auto-add-overlay -a d:\projects\myapp\assets -i "c:\program files\android\android-sdk\platforms\android-8\android.jar"" in command line , error: invalid resource directory name: d:\projects\myapp\target\filtered-assets/application.properties. wrong slash instead back-slash after filtered-assets. changing <resourcedirectory>${project.build.directory}/filtered-assets</resourcedirectory> <resourcedirectory>${project.build.directory}\filtered-assets</resourcedirectory> doesn't help.
p.s. plugins section looks this
<plugin> <artifactid>maven-resources-plugin</artifactid> <executions> <execution> <phase>initialize</phase> <goals> <goal>resources</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupid>com.jayway.maven.plugins.android.generation2</groupid> <artifactid>android-maven-plugin</artifactid> <version>3.2.0</version> <configuration> <sdk> <platform>8</platform> </sdk> <emulator> <avd>2.3.3_api-10</avd> </emulator> <undeploybeforedeploy>true</undeploybeforedeploy> <resourcedirectory>${project.build.directory}/filtered-assets</resourcedirectory> </configuration> <extensions>true</extensions> </plugin>
now works, change <resourcedirectory>${project.build.directory}/filtered-assets</resourcedirectory> <assetsdirectory>${project.build.directory}/filtered-assets</assetsdirectory>. results pom:
<properties> <myproperty>my property!!!!111</myproperty> </properties> <resources> <resource> <directory>${project.basedir}/assets</directory> <filtering>true</filtering> <targetpath>${project.build.directory}/filtered-assets</targetpath> <includes> <include>**/*.properties</include> </includes> </resource> </resources> <plugins> <plugin> <artifactid>maven-resources-plugin</artifactid> <executions> <execution> <phase>initialize</phase> <goals> <goal>resources</goal> </goals> </execution> </executions> </plugin> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupid>com.jayway.maven.plugins.android.generation2</groupid> <artifactid>android-maven-plugin</artifactid> <version>3.2.0</version> <configuration> <sdk> <platform>8</platform> </sdk> <emulator> <avd>2.3.3_api-10</avd> </emulator> <undeploybeforedeploy>true</undeploybeforedeploy> <assetsdirectory>${project.build.directory}/filtered-assets</assetsdirectory> </configuration> <extensions>true</extensions> </plugin>
Comments
Post a Comment