Hybrid View
-
14 Oct 2012 8:09 PM #1
Sencha cmd and Maven development
Sencha cmd and Maven development
Hi,
I have a Maven based web application which uses typical Maven directory structure. I have created an Ext JS 4.1.1a application to ${basedir}/src/main/webapp directory using Sencha Cmd 3.0.0.190.
For development purposes I use maven-jetty-plugin and generated index.html which uses Ext.Loader to load scripts dynamically. There's a bug http://www.sencha.com/forum/showthre...l=1#post897523 which is fortunately easy to fix.
During creating a war-package, on 'prepare-package' phase, I run 'secnha ant build' by using exec-maven-plugin to make a production build of ExtJS 4 app. I don't want to pollute ${basedir}/src/main/webapp directory so I have changed workspace.build.dir(in ${basedir}/src/main/webapp/.sencha/workspace/sencha.cfg) to ${basedir}/target. This works relatively fine. There are some bugs which are reported on the forum. For example some image urls generated are absolute not relative.
After succesful build, build directory contains index.html, all-classes.js and ext and resources directories. I use ant copy tasks to copy files back to ${basedir}/src/main/webapp directory so that they are included in war package.Code:<target name="-after-build"> <copy file="${workspace.build.dir}/all-classes.js" tofile="all-classes.js"/> <copy file="${workspace.build.dir}/index.html" tofile="index.jsp"/> </target>
However I am not sure what to do with the ext and resources directories. I just cannot copy them to ${basedir}/src/main/webapp because it already has those directories generated by Sencha Cmd and are used during development. 'sencha ant build' generated ext and resources directories are not identical with directories generated initially by 'sencha generate app'.
Is there anyone who has same kind of setup? How do you handle the situation?
-
15 Oct 2012 4:26 AM #2
I am doing something very similar and waiting for an updated version of Sencha command.
I think you can avoid the extra copy back into the webapp directory by just telling the war plugin about additional webResources (the sencha build directory).
-
30 Jan 2013 10:00 AM #3
would you mind posting the pertinent lines from your maven config?
-
15 Feb 2013 12:58 PM #4
Does this work now?
Does this work now?
I would like to do a very similar thing (integrate Sencha Cmd with Maven). Please post details of your solution if you were able to get it working. Thanks!
-
20 Mar 2013 6:22 PM #5
I ended up running maven only after I generated the zip first with the sencha command.
-
11 Apr 2013 10:08 AM #6
Here are a few things I've found. The approach I've tried so far is to use maven-antrun-plugin to invoke Sencha Cmd as an Ant Library. Check the Sencha API docs under Ant Integration for some helpful details.
First, you need to define a cmd.dir property specifying where Sencha Cmd is located.
It may be helpful to have an environment variable to help define this path. Alternatively, you could copy/deploy Sencha Cmd to your project structure somewhere and exclude it from your war.Code:<properties> <cmd.dir>path/to/Sencha/Cmd</cmd.dir> </properties>
To make use of Sencha Cmd Ant tasks, you need to reference the sencha.jar file via a taskdef. You can then use <x-sencha-command> tasks to invoke Sencha Cmd as needed. Since Sencha Cmd is Ant driven, it sometimes bootstraps using a build.xml file located with the web app files. This build file is likely in a different location than your pom.xml file, meaning Ant wouldn't normally be able to see its build.xml file when run via Maven since the working directory would be based on the location of the pom file. To fix this issue, specify a dir attribute on the <x-sencha-cmd> tag to set the working directory for Sencha Cmd invocations. When using <x-sencha-command>, the arguments are placed in the body text, one argument per line. Spaces are trimmed at both ends, so indent level is not significant but recommended to clarify the command structure.
If you need more customization beyond the default build, you could try the various "sencha compile" commands.Code:<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>compile</id> <phase>compile</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <taskdef resource="com/sencha/ant/antlib.xml" classpath="${cmd.dir}/sencha.jar"/> <x-sencha-command dir="${basedir}/src/main/webapp"> app build </x-sencha-command> </target> </configuration> </execution> </executions> </plugin>
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote