Sencha CMD Ant integration for custom web application - sencha-cmd

We are trying to integrate the Sencha CMD to our custom application ant script( build.xml) inorder to do minification of js files. Could you please let us know the steps needs to be followed for minifcation of js files . It could be useful if you could provide sample file to achieve this. We tried the following steps as per the manual to just include the sencha.jar which resulted in error "init-sencha-cmd:
[taskdef] Could not load definitions from resource com/sencha/ant/antlib.xml."
I have added the target "init-sencha-cmd" as dependency to target "build" and a property build.dir (basedir="." configured in the start of xml)
<target name="build" depends="init, dependencies, pre-compile, compile, post-compile,init-sencha-cmd" description="Builds the project." />
<property name="build.dir" location="${basedir}"/>
<target name="init-antcontrib">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${Bundles.WebCharts.lib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
</target>
<target name="init-sencha-cmd" depends="init-antcontrib">
<taskdef resource="com/sencha/ant/antlib.xml" classpath="/Users/hatamm/bin/Sencha/Cmd/5.0.3.324/sencha.jar"/>
</target>

Related

Getting an error "Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found."

I am getting an error Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found. when I am trying to ant build on eclipse. So I downloaded ant-contrib-0.6.jar and kept it in my /lib location of apache ant, but it still does not resolve my issue. I have also tried by specifying the /lib location in my CLASSPATH system variable. How can I get around this error?
You can provide full path to the ant-contrib JAR explicitly using "classpath" element:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${path-to-ant-contrib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
EDIT: Link contributed by Djacomo:
http://ant-contrib.sourceforge.net/
One important thing missing from this StackOverflow page is that setting the correct ANT_HOME env var is absolutely vital and important, without this setting ant keeps telling the same error, regardless of where you copy the ant-contrib-1.0b3.jar on your file systems. This missing thing has costed me a few hours. =)
However I receive this error without eclipse, in the pure ant.
I fixed that this way:
Add the JAR to the Ant runtime classpath entries.
Window>Preferences>Ant>Runtime>Classpath
Add the JAR to either Ant Home Entries or Global Entries.
It would appear that you haven't installed the ant contrib jar into the correct lib directory. This can be difficult to do if you have several installations of ANT.
My suggestion is to install your ANT plugins into the "$HOME/.ant/lib" directory. You could go one step further and automate the process as follows:
<project name="ant-contrib-tasks" default="all">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="bootstrap">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
</target>
<target name="all">
<for param="file">
<fileset dir="." includes="*.txt"/>
<sequential>
<echo message="Found file #{file}"/>
</sequential>
</for>
</target>
</project>
Use the below mentioned code in your build xml:
<path id="ant.classpath">
<pathelement location="${ant.jarPath}/ant.jar" />
<pathelement location="${ant.jarPath}/ant-contrib-0.3.jar" />
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath refid="ant.classpath" />
</taskdef>
And in your build property file:
ant.jarPath=D:/antjars
And place ant.jar and ant-contrib-0.3.jar in directory:D:/antjars
Check you have read permissions for the ant-contrib jar file.
In our case after copying the file with another user it did not, giving the same error message.

.war file won't be updated

I have an old project, built using Google Web Toolkit in Eclipse. When I created it, I did the following steps, in order to get the .war file
GWT Compile Project
Run the following Ant script
<project name="The" basedir="." default="default">
<target name="default" depends="buildwar,deploy"></target>
<target name="buildwar">
<war basedir="war" destfile="The.war" webxml="war/WEB-INF/web.xml">
<exclude name="WEB-INF/**" />
<webinf dir="war/WEB-INF/">
<include name="**/*.jar" />
</webinf>
</war>
</target>
<target name="deploy">
<copy file="The.war" todir="." />
</target>
</project>
Get the .war file
Now, I had to change a port in my project, so I changed it in my code and did the same steps in order to get the .war
However, when I deploy my updated project in Tomcat, it still makes requests to the old port number (I found this reading catalina.out)
So, What can I do in order to get a new, fresh .war ???
You don't mention it, but did you change the ports in tomcat? I assume you did, but I just want to cover all possibilities.

script to execute the eclipse PDE Tools > Build site

i want to write a script to do the Build site of plugin Update site site.xml?
i could not find a way to do this?
i found very easy to build a plugin feature. I can automatically creat the ant file build.xml via eclipse but i could not find the same for the update site.xml
thank you all
stefania
Are you trying to build an Eclipse plugin from Ant? You want to use the Ant4Eclipse external add-on for Ant. It lets you build the run-configurations you've made in Eclipse (right click>run as>...) from your .project file. You can download it here and there is a tutorial here.
I attempted to do what you're asking at a previous job without using Ant4Eclipse, I don't remember how I got it working, but I do remember it being extremely difficult.
Edit: you can build an Eclipse update site from the command line, which can be run from Ant. There is some [possibly out of date] documentation here, but I found you a sample from an Apache projects build.xml:
<target name="build-site" depends="init">
<copy todir="target/eclipse-update-site/web" preservelastmodified="true">
<fileset dir="web"/>
</copy>
<copy todir="target/eclipse-update-site" file="index.html" preservelastmodified="true"/>
<copy todir="target/eclipse-update-site" file="site.xml" preservelastmodified="true"/>
<!-- copy all the features to the target -->
<copy todir="target/eclipse-update-site/features" preservelastmodified="true" >
<fileset dir="features"/>
</copy>
<!-- see http://wiki.eclipse.org/Update_Site_Optimization -->
<java jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher.jar" fork="true" failonerror="true"
maxmemory="256m">
<arg line="-application org.eclipse.update.core.siteOptimizer"/>
<arg line="-digestBuilder -digestOutputDir=target/eclipse-update-site"/>
<arg line="-siteXML=target/eclipse-update-site/site.xml"/>
</java>
</target>

Using Guava with GWT

Could someone tell me what I need to do to enable Guava support in GWT.
I have downloaded Guava R07 and in there there are the following two files:
guava-r07.jar
guava-r07-gwt.jar
I have a few questions regarding this:
Where do these files go? I am guessing that the standard Jar is made available to my IDE for coding, and that both are made available to the GWT compiler for building the JavaScript?
Do I need to add all the .gwt.xml files from the -gwt.jar into my project's main gwt.xml file or only the portions I need?
There are other Jars on the trunk of the Guava&GWT project (ie not in the download, such as one for jsr305) which I think I may need, but I'm not sure.
Sorry, normally I don't have trouble with this kind of thing, but I can't quite work out what goes where.
FYI I'm using GWT 1.6 for the time being, but am hoping to move to 2 soon. If Guava isn't compatible with 1.6 that is not a problem.
Update
I have the following files in a folder called gwtlib:
guava-r07-gwt.jar
guava-r07.jar
jsr305-1.3.9.jar
And my Ant script does the following:
<path id="project.class.path">
<fileset dir="gwtlibs" includes="guava-r07.jar"/>
<fileset dir="gwtlibs" includes="guava-r07-gwt.jar"/>
<fileset dir="gwtlibs" includes="jsr305-1.3.9.jar"/>
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
</path>
<target name="gwtc">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="app"/>
<path refid="project.class.path"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg value="-localWorkers"/>
<arg value="2"/>
<arg value="-war"/>
<arg value="gwt-public"/>
<arg value="Main"/>
</java>
</target>
Running the above command, I get the following errors:
Errors in 'jar:file:///project/gwtlibs/guava-r07-gwt.jar!/com/google/common/collect/Constraints.java'
Line 254: The method subList(int, int) is undefined for the type List
Without the jsr jar on the classpath, I get the following errors:
The import javax.annotation cannot be resolved
Nullable cannot be resolved to a type
Thanks
Rich
Add these jars to your classpath. If you're using IDE, add them to your Build Path by right-clicking "Referenced Libraries" in your Package Exporer, select "Configure Build Path" and add them as external JARs.
You only need to inherit the modules you plan on using in your .gwt.xml file. For example, if you only use the common.collect package, just add <inherits name="com.google.common.collect.Collect" />
You probably don't need jsr305.jar, but if you do, just add it the same way as you added the other jars.
Guava should work just fine with GWT 1.6, if it doesn't then it's probably a bug.
Guava isn't compatible with GWT 1.6. List.subList, in particular, is added to GWT in GWT 2. The earliest version that we fully supported is GWT 2.0.4

How can I automate (script) creating a war file in eclipse?

It's 5 button clicks to get eclipse to create a deployable war file for my eclipse project, I figure there's probably some eclipse command line option to do the same thing, so I can just write it into a script, but I'm not seeing it.
Use the Ant war task, set up a relevant build file and you can just hit the "external tools" button to execute it.
You could also setup a Maven build for your web project. Typing mvn package from the command line would then build the project for you.
For integration between Maven and Eclipse, see m2Eclipse and Maven Eclipse Plugin.
I cannot say anything about the WAR packaging itself, sorry.
But as I wrote in
How do I automatically export a WAR after Java build in Eclipse? : If you can describe the WAR packaging with an Ant script, you can have that Ant script being executed automatically after each change to your project. Use Project->Properties->Builders->Add->Ant Builder. Give that builder you custom Ant script and it will automatically be executed after the "normal" builders of your project.
You can even specify in the settings of the builder, if it shall only react on changes to specific files and so on.
The Ant builder is kind of a Swiss army knife for anything you want to automate in the project build without having to use the big tools like maven.
This Ant script should work for standard Dynamic Web Project structure of project:
Create Ant build.xml with replacing of two properties at begining:
<?xml version="1.0" encoding="UTF-8"?>
<project name="Deploy From Eclipse to JBoss" basedir="." default="deploy">
<!-- This replace with yours project name and JBoss location: -->
<property name="warfile" value="MyProject"/>
<property name="deploy" value="/home/honza/jboss-as-7.1.1.Final/standalone/deployments"/>
<target name="create">
<war destfile="${warfile}.war" webxml="WebContent/WEB-INF/web.xml" update="true">
<classes dir="build\classes"/>
<fileset dir="WebContent">
<exclude name="WEB-INF/web.xml"/>
</fileset>
</war>
</target>
<target name="copy">
<copy todir="${deploy}" overwrite="true">
<fileset dir=".">
<include name="${warfile}.war"/>
</fileset>
</copy>
</target>
<target name="clear">
<delete includeemptydirs="true">
<fileset dir="${deploy}" defaultexcludes="false">
<include name="${warfile}.*/**" />
</fileset>
</delete>
</target>
<target name="deploy">
<antcall target="create"/>
<antcall target="clear"/>
<antcall target="copy"/>
</target>
</project>
Now should command "ant" do WAR creation and copy them to the JBoss. JBoss automatically deploys wars which finds in deployment directory.
For automatic run after build (Project - Build) add this Buildfile here:
MyProject - Properties - New - Ant builder