Broken maven, flexmojos, webapp integration in Idea 9.0.1?
I have a multi-module project where one module is a flex module and another is a webapp module. There are many others modules, but I think these are the relevant ones. I'm using maven and flexmojos to build a webapp. I'm trying to use the exploded artifact of the web module to back a locally run (via IDEA) tomcat configuration. I have set up tomcat to use the exploded artifact and everything works fine with respect to starting tomcat and using the exploded directory.
I'm having trouble understanding the correct way to build the exploded artifact. If I run everything from the maven command line (or the maven projects tab within IDEA), maven creates the swf and war appropriately and packages the swf in the correct location in the war. However, I'm not sure how to do things outside of maven so the exploded directory is created correctly.
1. For flex modules is the IDEA compile/make functionality (e.g. - right click on module and click compile or make?) broken? I'm not really sure how these relate to the maven compile goal (e.g. - in idea maven project tab running the compile goal). The maven compile goal from within IDEA works and will correctly generate the swf. However, trying to use the compile by right clicking on the module fails trying to find the playerglobal.swc. The maven compile places this file in the modules/target/classes/libraries. The IDEA compile doesn't though. I tried reimporting the maven project and seleting 'Build->Rebuild Project' but this still failed with the missing playerglobal file. I'm pretty sure this wasn't an issue in 9.0.0 (though in 9.0.0 I had to first run maven compile, then could compile with IDEA's module compile).
2. How do I get the swf generated by the flex module to be deployed to the correct exploded artifact? Adding the flex module's compiler output to the exploded artifact doesn't copy the swf, but does copy all the other crap that goes into generating the swf which I don't want copied over. I have a dependency on the swf artifact generated by the flex module and the Idea builds puts it in the lib directory of the war. With the depedency on the flex moduleAt least this was in 9.0.0 (can't try with 9.0.1 due to issue 1 above). Like I said before, just using maven will correctly create everything (calls the flexmojos plugin copy-flex-resources goal). I guess IDEA doesn't integrate with this?
I have read the post http://blogs.jetbrains.com/idea/2009/09/flexmojos-inmaia/ (and associated comments), which doesn't address these issues. Some comments dealt with copying the swf, but they didn't work for me (or I'm to dense to understand how to apply the comments to my 9.0.1 project).
Any help, references, pointers, etc are greatly appreciated!
Thanks,
Bob
Please sign in to leave a comment.
it looks like some content from Flex Mojos SDK it is missing, try to
recreate it / invalidate the caches
If your compile succeeds please ensure swf extension is mentioned in
compiler resource file masks
On 20.01.2010 21:18, B J wrote:
>
>
>
>
>
>
>
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
First of all, if you like using maven and can compile everything you need by maven you may turn off 'Before launch: Make' for your run configurations and use 'Before launch: Run Maven Goal' instead.
Second, here's an example of project configuration with Flex module as client side and Java module with Web facet as server side; it contains artifact, Tomcat and Flex run configurations (though nothing maven-specific): http://blogs.jetbrains.com/idea/2009/11/graniteds-projects-in-maia/ . It's not your case but may be you find anything useful there.
Now about compilation by IDEA.
This is not broken and was not changed since IDEA 9.0. Generally speaking Flex compilation by IDEA is not related to maven goals. IDEA runs fcsh (Flex Compiler SHell) and compiles sources according to Flex facet settings. Settings should be correct if you follow steps from http://blogs.jetbrains.com/idea/2009/09/flexmojos-inmaia/ , i.e.
- have <configurationReport>true</configurationReport> in flex-related pom.xml's
- mvn compile
- reimport maven modules
After that you have custom compiler configuration file (target/...-config-report.xml) and compilation by IDEA (i.e. by fcsh) should be very similar to what Flexmojos plugin does. Note: do not 'mvn clean' project before compilation by IDEA because it removes some required files including /target/classes/libraries/playerglobal.swc. And switch off Settings | Compiler | Clear output directory on rebuild for the same reason.
One example of artifact configuration by the link above. There the whole Flex module compile output is copied to the root of exploded directory. I think this wouldn't work for flexmojos projects because module output folder is /target/classes/ but swf is compiled to Facet output path which is just /target/. For your case it would probably be better to add one swf file to the root of the war. It will be copied each time when artifact is built.
Thanks for the response and the answers! It helps to understand what's going on under the covers a little so I know where I'm veering off the road. I had missed unchecking the 'clear output directories on compile' that you specified. Didn't know that option existed. Thanks. I don't want to run the maven goal for builds since it takes a lot longer and to do quick turnaround builds while testing something it makes me want to, well... So I want to do everything possible with Idea to have quick builds.
Thanks to your answers I think i'm back on the right path, but I still can't figure out the best way, using Idea, to package the exploded artifact to include my swf when I'm using flex-mojos. I've tried the following (better solutions are appreciated):
1. In exploded artifact settings, add 'directory content' to the artifact and specify the flex module's target directory. This copies a ton of unneeded stuff (classes, generated sources, etc, etc), but it also copies the swf (without having to explicitly name the swf since name will change depending on version being built)
2. In exploded artifact settings, add 'file' to the artifact and specify the swf in the flex module's target directory. This will copy only the needed file, but have to explicitly specify the name of the swf.
3. Create an ant build file with a target that copies the appropriate swf to the output dir. Will only copy the explicit needs (and can use filters to copy *.swf), but need to specify the output directory.
None of the above solutions will automatically re-copy the swf to the exploded artifact if the swf changes (e.g. - remake the swf). This would be ideal - and akin to how jars are automatically copied (which I love). Am I missing an option?
As a side note, adding the flex module's compile output to the artifact doesn't work since, as you stated, flexmojos puts the generated swf in root of the target directory, but the 'compile output' is target/classes. So this ends up copying all the config information and such that flexmojos puts in the classes directory into the exploded directory, but not the swf.
As always, thanks.
Bob
So far I can't figure out better solution than your number 2.
I would suggest you to check 'Build on make' at artifact configuration page. In this artifact will be rebuilt each time when you make your project (Ctrl+F9 or right click + Make Module).
I had the same problem in Idea 12, after importing an Eclipse/Maven project :
swf correctly compiled in the swf-module/target, but not deployed in the war-module/target (or as an old version, and not in debug mode).
Point 2 solved it.
You guys saved my day, thanks !