Maven and flex compile problem
I tried to compile using maven-flex2-plugin
plugin with maven here is the error I got:
D:\PROJECTS\flex\Reports>mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Reports Maven Flex
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory D:\PROJEKTI\flex\Reports\target
[INFO] [flex2:compile-swf {execution: default-compile-swf}]
[INFO] Attaching licenses.
[INFO] Adding Extra Parameters: []
[INFO] Failed to invoke null with parameters: [+flexlib=C:\Program Files\Adobe\A
dobe Flash Builder 4\sdks\4.1.0\frameworks, -load-config, C:\Program Files\Adobe
\Adobe Flash Builder 4\sdks\4.1.0\frameworks\flex-config.xml, -source-path, D:\P
ROJEKTI\flex\Reports\src\main\flex, -output, D:\PROJEKTI\flex\Reports\target\Rep
orts-0.0.1-SNAPSHOT.swf, -compiler.locale, en_US, -use-network, -compiler.debug=
false, --, Main.mxml]
[INFO] java.lang.ClassNotFoundException: flex2.tools.Compiler
[INFO] at java.net.URLClassLoader$1.run(Unknown Source)
[INFO] at java.security.AccessController.doPrivileged(Native Method)
[INFO] at java.net.URLClassLoader.findClass(Unknown Source)
[INFO] at java.lang.ClassLoader.loadClass(Unknown Source)
[INFO] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[INFO] at java.lang.ClassLoader.loadClass(Unknown Source)
[INFO] at net.israfil.mojo.flex2.StreamedParameterExecutableWrapper.main(Stream
edParameterExecutableWrapper.java:58)
[INFO] Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNot
FoundException: flex2.tools.Compiler
[INFO] at net.israfil.mojo.flex2.StreamedParameterExecutableWrapper.main(Stream
edParameterExecutableWrapper.java:66)
[INFO] Caused by: java.lang.ClassNotFoundException: flex2.tools.Compiler
[INFO] at java.net.URLClassLoader$1.run(Unknown Source)
[INFO] at java.security.AccessController.doPrivileged(Native Method)
[INFO] at java.net.URLClassLoader.findClass(Unknown Source)
[INFO] at java.lang.ClassLoader.loadClass(Unknown Source)
[INFO] at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[INFO] at java.lang.ClassLoader.loadClass(Unknown Source)
[INFO] at net.israfil.mojo.flex2.StreamedParameterExecutableWrapper.main(Stream
edParameterExecutableWrapper.java:58)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Result of flex2.tools.Compiler execution is: '1'.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Wed Oct 20 21:57:20 CEST 2010
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------
Here is my pom :
<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.test.flex</groupId>
<artifactId>Reports</artifactId>
<packaging>swf</packaging>
<version开发者_开发问答>0.0.1-SNAPSHOT</version>
<name>Reports Maven Flex</name>
<url>http://maven.apache.org</url>
<properties>
<flex.home>C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\4.1.0</flex.home>
</properties>
<build>
<sourceDirectory>src/main/flex</sourceDirectory>
<plugins>
<plugin>
<groupId>net.israfil.mojo</groupId>
<artifactId>maven-flex2-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<flexHome>${flex.home}</flexHome>
<useNetwork>true</useNetwork>
<main>Main.mxml</main>
</configuration>
</plugin>
</plugins>
<defaultGoal>install</defaultGoal>
</build>
</project>
Has anyone encountered this problem ? is there solution ? is there a better way? I want to run my flex application on server as war
I will not tell you how to fix your problem but I will tell you some my expirience about developing Flex app. (We develop huge Flex apps for banks.)
At the very begining we also tried to adopt maven for everything (maven is great tool indeed). We have tried flex-mojos and other plugins but each of them had problems that we couldn't overcome.
So, now our best practice is the following: We use maven for the following pasks: retrieve dependencies, installing artifacts to the local repo and deploying to the remote repo, but for all other tasks I use ant. Our scripts run on Mac and Windows. They consume much less memory than for example flex-mojos (it is important when you want to compile a lot of modules). They fully support CI servers and so far it seems the best possible sollution.
So, to save you time - try to use ant instead of maven for compilation and testing. (Flex SDK comes with Ant tasks that you can use).
All the best with Flex, Maven and Ant!
Just taking a very quick glance at the maven-flex2 project page, it seems that this plugin is only meant to build Flex2 projects (the project was last updated in 2008).. That could be your problem, as you're linking to the Flex4 sdk.
I agree with Florian's suggestion re: FlexMojos. It takes a bit of work to get it up and running, but when it works, it works great. We've been using it to build all our Flex/AIR projects for a while now.
精彩评论