this library provides abstraction that make it easy to make games that
run on both platforms with the same code.
I have a maven build working for this made of:
parent - pom with common info
- core module - just a jar with the common code
- android module - an android module using maven-android-plugin,
depends on the core
- desktop module - a jar module that depends on the core
the issue I am facing now, is how to avoid having to duplicate the
assets to work with android and desktop
right now I have the assets both in the desktop module, and in the
assets dir of the android module
One solution I see is to use a separate module for the assets, and then
declare them in some special way for the plugin to unpack into the
combined-assets/assets dir, or something like that.
Not really sure what would be the best way to signal that the artifact
contains assets and should be treated in that special way. Using a
different packaging would make it harder to use in the normal desktop
module. Perhaps declaring the artifact in the configuration of the
plugin instead of as a dependency.
thanks for your help.
Rub�n
That should be pretty easy to do. Just pull all the shared assets needed
for desktop and android app out into another jar packaging project. Then
in the desktop app declare it as normal dependency provided you want it to
be just on the classpath in the same way you had it in the originating
jar.
In the android project bind the dependency plugin goal "unpack" for the
assets artifact to an early lifecycle phase so it gets extracted to the
target folder for assests.. and voila. The android build will pull it in..
That should do it. Depending on assest structure and needs you could even
to that with multiple different ones and or getting them extracted to
different folders and so (e.g. even the drawable folder..)
manfred
http://www.simpligility.com
Another solution that I tried was using an execution of the antrun
plugin where I first delete the assets dir, and then copy the assets
from the asset module to the android one.
like this:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>prepare-package</phase>
<configuration>
<target>
<delete>
<fileset dir="assets">
<include name="**" />
</fileset>
</delete>
<copy todir="assets">
<fileset dir="../magick-assets/src/main/resources">
<include name="**" />
</fileset>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
this works perfectly when running from console, but I am having
intermitent problems when using it from eclipse with the m2eclipse
integration, lots of times it says that it can't find the apk when
trying to run the game.
The other thing that I tried and what I will use now, is set the
<assetsDirectory>../magick-assets/src/main/resources</assetsDirectory>
configuration to point to the module assets.
This solution works, but I feel really dirty by doing this to poor
maven, it is more like a workaround than a proper solution.
thanks for your help.
Rub�n
manfred
> --
> You received this message because you are subscribed to the Google Groups
> "Maven Android Developers" group.
> To post to this group, send email to
> maven-androi...@googlegroups.com.
> To unsubscribe from this group, send email to
> maven-android-deve...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/maven-android-developers?hl=en.
>
after some investigation, I found that in previous tests I had the
dependency to the assets artifact in the android module, so that made
the assets module to be build before the android one. After seeing that
the dependency:unpack worked I removed the unused dependency, and it
started to fail, didn't relate those two events at the time, so I
searched for other options.
A quick fix for this is declaring the assets module before the android
one, but that is a brittle solution and prone to be broken by mistake. I
you have by chance an old artifact of the same version installed in your
local repo the build will succeed but the assets artifact will be an old
one.
Another fix is declaring the dependency to the assets artifact but with
scope runtime, so it is not included in the apk, but again, don't like
that solution either.
for now unless I need some filtering or other maven processing of the
assets I will point the assets directory in the android module plugin to
the src/main/resources of the assets module, as it is way less
configuration and avoids an extra step making the build complete faster.
thanks for your help.
Ruben
Rubén