Tuesday, April 9, 2013

PlayN and eclipse - flash build issue

In my previous post I have described how to set up eclipse for gamedevelopment with PlayN and import the PlayN showcases. The Html and Java versions worked fine and  I tried to run the flash version (Run As -> Maven install) which failed with the following output: 
 [INFO] Scanning for projects...
[INFO]                                                                        
[INFO] ------------------------------------------------------------------------
[INFO] Building PlayN Showcase Flash 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ playn-showcase-flash ---
[INFO]
[INFO] --- maven-dependency-plugin:2.1:unpack (unpack) @ playn-showcase-flash ---
[INFO] Configured Artifact: com.adobe.flex:flex-sdk:4.1.0.16076_mpl:zip
[INFO] Unpacking /home/paul/.m2/repository/com/adobe/flex/flex-sdk/4.1.0.16076_mpl/flex-sdk-4.1.0.16076_mpl.zip to
  /home/paul/development/playn-samples/showcase/flash/target/flex4sdk
   with includes null and excludes:null
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) @ playn-showcase-flash ---
[INFO] Executing tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.359s
[INFO] Finished at: Mon Apr 08 08:13:27 CEST 2013
[INFO] Final Memory: 10M/108M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default) on project playn-showcase-flash: An Ant BuildException has occured: /home/paul/development/playn-samples/showcase/flash/target/flex4sdk/bin not found. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
My System Information:
  • OS: Ubuntu 12.04 LTS 32bit
  • Eclipse Indigo

 Resolving The Errors

We look at the first error Message,
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default) on project playn-showcase-flash: An Ant BuildException has occured: /home/paul/development/playn-samples/showcase/flash/target/flex4sdk/bin not found.
When browsing to the mentioned folder /home/paul/development/playn-samples/showcase/flash/target/flex4sdk it turns out that this folder is empty. Something must have gone wrong during unpacking or copying. An upper message tells us where we can find the right flex4sdk :
[INFO] Unpacking /home/paul/.m2/repository/com/adobe/flex/flex-sdk/4.1.0.16076_mpl/flex-sdk-4.1.0.16076_mpl.zip to
  /home/paul/development/playn-samples/showcase/flash/target/flex4sdk
   with includes null and excludes:null
We  browse to /home/paul/.m2/repository/com/adobe/flex/flex-sdk/4.1.0.16076_mpl/ unpack the flex-sdk-4.1.0.16076_mpl.zip and copy its content to the home/paul/development/playn-samples/showcase/flash/target/flex4sdk (You can also create a symlink).

We run the flash target again Run As->maven install on playn-showcase-flash. The previous message disappear. But the build still fails with the following output:
...
[INFO]
[INFO] --- gwt-maven-plugin:2.5.0:compile (default) @ playn-showcase-flash ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.534s
[INFO] Finished at: Mon Apr 08 08:30:57 CEST 2013
[INFO] Final Memory: 13M/173M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.5.0:compile (default) on project playn-showcase-flash: GWT Module org.jbox2d.GwtBox2D not found in project sources or resources. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
 The GWT Compiler tells us that the Module org.jbox2d.GwtBox2D is missing. This module should be located in the jbox-sources.jar. We take a look at the Maven Dependencies:
A playn-jbox-xx.jar is actually listed but this jar contains only binaries, but the GWT Compiler need the source files. We must add an maven dependency for the sourcefile archive.

Later I found out that this wasn't the last missing maven dependency, to resolve all missing dependencies i had to add the following dependencies to my playn-showcase-flash/pom.xml:
         <dependency>
            <groupId>com.googlecode.playn</groupId>
            <artifactId>playn-html</artifactId>
            <version>1.6</version>
            <classifier>sources</classifier>
        </dependency>

        <dependency>
            <groupId>com.googlecode.playn</groupId>
            <artifactId>playn-jbox2d</artifactId>
            <version>${playn.version}</version>
            <classifier>sources</classifier>
        </dependency>

        <dependency>
            <groupId>com.threerings</groupId>
            <artifactId>tripleplay</artifactId>
            <version>${playn.version}</version>
            <classifier>sources</classifier>
        </dependency>
        <dependency>
            <groupId>com.googlecode.playn</groupId>
            <artifactId>playn-flash</artifactId>
            <version>${playn.version}</version>
            <classifier>sources</classifier>
        </dependency>
Now all dependencies should be complete. But running (Run As-> Maven install) the flash target results in an other Build Failure. Which seems to be more serious:

[INFO] --- gwt-maven-plugin:2.5.0:compile (default) @ playn-showcase-flash ---
[INFO] Compiling module playn.showcase.ShowcaseFlash
[INFO]    Validating units:
[INFO]       Ignored 1 unit with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO]    Computing all possible rebind results for 'com.google.gwt.useragent.client.UserAgentAsserter'
[INFO]       Rebinding com.google.gwt.useragent.client.UserAgentAsserter
[INFO]          Checking rule <replace-with class='com.google.gwt.user.client.FlashUserAgentProperty'/>
[INFO]             [WARN] Unknown type 'com.google.gwt.user.client.UserAgentAsserter.UserAgentProperty' specified in deferred binding rule
[INFO]    Computing all possible rebind results for 'com.google.gwt.user.client.DocumentModeAsserter'
[INFO]       Rebinding com.google.gwt.user.client.DocumentModeAsserter
[INFO]          Checking rule <replace-with class='com.google.gwt.user.client.FlashUserAgentProperty'/>
[INFO]             [WARN] Unknown type 'com.google.gwt.user.client.UserAgentAsserter.UserAgentProperty' specified in deferred binding rule
[INFO]    Computing all possible rebind results for 'playn.showcase.flash.ShowcaseFlash'
[INFO]       Rebinding playn.showcase.flash.ShowcaseFlash
[INFO]          Checking rule <replace-with class='com.google.gwt.user.client.FlashUserAgentProperty'/>
[INFO]             [WARN] Unknown type 'com.google.gwt.user.client.UserAgentAsserter.UserAgentProperty' specified in deferred binding rule
[INFO] [ERROR] Unexpected internal compiler error
[INFO] java.lang.NoClassDefFoundError: com/google/gwt/dev/jjs/impl/TypeLinker
[INFO]     at com.google.gwt.dev.jas.JavaToActionScriptCompiler.precompile(JavaToActionScriptCompiler.java:530)
[INFO]     at com.google.gwt.dev.jas.JasCompiler.precompile(JasCompiler.java:41)
[INFO]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:278)
[INFO]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
[INFO]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:141)
[INFO]     at com.google.gwt.dev.Compiler.run(Compiler.java:232)
[INFO]     at com.google.gwt.dev.Compiler.run(Compiler.java:198)
[INFO]     at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
[INFO]     at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
[INFO]     at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
[INFO]     at com.google.gwt.dev.Compiler.main(Compiler.java:177)
[INFO] Caused by: java.lang.ClassNotFoundException: com.google.gwt.dev.jjs.impl.TypeLinker
[INFO]     at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
[INFO]     at java.security.AccessController.doPrivileged(Native Method)
[INFO]     at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
[INFO]     at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
[INFO]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
[INFO]     at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
[INFO]     ... 11 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE


The line Caused by: java.lang.ClassNotFoundException: com.google.gwt.dev.jjs.impl.TypeLinker
tells us that the class TypeLinker is missing. After spending several time googling I found out that this problem won't be easy to fix since the flash target of PlayN 1.6 is not compatible to gwt 2.5 which is curiously  used by PlayN 1.6. Another curious thing is that the PlayN Developers seem to know about this problem:

I found the following comment on http://code.google.com/p/playn/wiki/PlatformStatus:

"Using Flash currently requires some fiddling because the GWT plugin that translates Java to ActionScript has fallen out of date with GWT. Thus one has to roll back to an older version of GWT (pre-2.4) to use the Flash backend. "
Because of this message I spent a whole day trying to switch back to gwt 2.3 without success.  It's quite hard because the flash target depends on artifacts witch seem to depend on gwt2.5. No matter what gwt version you include there are still some classes missing.


 Notes

  • I've decided to post this article even though I didn't find a solution, with the hope the first part may be still useful for somebody.
  • Leave your comments if you have any ideas on how this problem can be solved
  • If flash support is essential for your project you should try PlayN 1.4 is seems to be the last version which supports the flash target

No comments:

Post a Comment