Compiling GWT in Jenkins - gwt

I'm trying to set up Jenkins to build a GWT project, but I got this error
gwt-compile-module:
[java] Jul 01, 2014 2:08:59 PM java.util.prefs.FileSystemPreferences$1 run
[java] INFO: Created user preferences directory.
[java] Loading inherited module 'OBFUSCATE'
[java] [ERROR] Unable to find 'OBFUSCATE.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
I have gwt-user.jar, gwt-dev.jar, validation-api-1.0.0.GA-sources.jar and validation-api-1.0.0.GA.jar in the class path.
OBFUSCATE.gwt.xml must be some GWT base module but cannot find it anywhere.
Here is the snippet from build.xml:
<target name="gwt-compile-module" description="Build one GWT module - java to javascript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="${src.dir}"/>
<pathelement location="${build.dir}"/>
<path refid="project.classpath"/>
</classpath>
<jvmarg value="-Xmx1024M"/>
<arg value="-optimize"/>
<arg value="${optimize}"/>
<arg value="-localWorkers"/>
<arg value="${localWorkers}"/>
<arg value="-war" />
<arg value="${gwt.output.dir}" />
<arg value="${draftCompile}" />
<arg value="${gwt.modules}${gwt.module}"/>
<arg line="-style OBFUSCATE"/>
</java>
</target>

I guess you should rearrange your arg options and place <arg line="-style OBFUSCATE"/> before <arg value="${gwt.modules}${gwt.module}"/>:
<arg line="-style OBFUSCATE"/>
<arg value="${gwt.modules}${gwt.module}"/>

Related

how can I find eclipse's specific launcher.Main class

I need to specify launcer class of eclipse for ant build.
Here my-common.xml
<exec executable="${file.jvm.jdk1.7}" failonerror="false" timeout="180000000">
<arg value="-Xms256m" />
<arg value="-Xmx512m" />
<arg value="-cp" />
<arg value="${eclipse.startup.jar}" />
<arg value="org.eclipse.HOW TO FIND HERE.Main" />
...
Finally I found it at
Help>About Eclipse>Intallation Details>Configuration tab

Running an Ant-builded project as web-application

I'm trying to run a "project.zip" I've downloaded from the official GWT site about RPC and Hibernate at http://www.gwtproject.org/articles/using_gwt_with_hibernate.html .
The guide suggests:
"you can use Ant to build the project, as well as start up hosted mode
to see the UI and our Hibernate instance setup in the embedded Jetty
server."
So I have imported it on Eclipse with New > Project menu-> Java Project from Existing Ant Buildfile wizard.
My final goal is to run it on Eclipse as web-application, but it gives me every types of errors and above all there's no run as-> web application but only as ->ant build ! And all the War directory is missing in Eclipse.
How can change this Ant build project.zip to a normal project GWT? I'm amazed how an official Google guide can give so many problems!
If you need it this is the build.xml :
<?xml version="1.0" encoding="utf-8" ?>
<project name="Guestbook" default="build" basedir=".">
<!-- Define gwt.home, gwt.dev.jar, appengine.sdk.home -->
<property file="build.properties"/>
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="${gwt.home}/gwt-user.jar"/>
<!-- Add any additional non-server libs (such as JUnit) -->
<fileset dir="war/WEB-INF/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="libs" description="Copy libs to WEB-INF/lib">
<mkdir dir="war/WEB-INF/lib" />
<copy todir="war/WEB-INF/lib" file="${gwt.home}/gwt-servlet.jar" />
<!-- Add any additional server libs that need to be copied -->
<copy todir="war/WEB-INF/lib" flatten="true">
<fileset dir="lib/">
<include name="**/*.jar"/>
</fileset>
</copy>
</target>
<target name="javac" depends="libs" description="Compile java source">
<mkdir dir="war/WEB-INF/classes"/>
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.5" target="1.5" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
</target>
<!-- can add additional arguments like -logLevel INFO or -style PRETTY -->
<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.home}/${gwt.dev.jar}"/>
</classpath>
<!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
<jvmarg value="-Xmx256M"/>
<arg value="com.google.musicstore.MusicStore"/>
</java>
</target>
<target name="hosted" depends="javac" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.home}/${gwt.dev.jar}"/>
</classpath>
<jvmarg value="-Xmx256M"/>
<arg value="-startupUrl"/>
<arg value="MusicStore.html"/>
<arg value="com.google.musicstore.MusicStore"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
</java>
</target>
<target name="build" depends="gwtc" description="Build this project" />
<target name="clean" description="Cleans this project">
<delete dir="war/WEB-INF/classes" failonerror="false" />
<delete dir="war/musicstore" failonerror="false" />
</target>
</project>
run
ant
to build the project.
run
ant hosted
to run the project.
I'm confused by the concept of a normal GWT project ... I'm not sure to understand what it means. But if it means an eclipse-ready-GWT-project, you will probably be disappointed because as you noted yourself:
you can use Ant to build the project
It is an ant based project, not en eclipse project. You can call ant from eclipse, but there is no specic eclipse files (.project and .classpath) so that it can run with gwt eclipse plugin without configuring it yourself.

incorporate GWT compiler option when invoking ANT in Jenkins

I want to have gwt.args= -localWorkers 4 to make my builds faster but this option is not available in the project.properties file. So I was searching if I could have it worked for me.
Can I use GWT compilation arguments in Jenkins when invoking ant, not from property files?
Please help in light of your experience!
Assuming that your build.xml file has already been configured to use the gwt.args property:
<target name="gwtc" depends="javac" description="GWT compile to JavaScript">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
[...]
</classpath>
<jvmarg value="-Xmx256M"/>
<arg line="${gwt.args}"/>
<arg value="com.example.MyApp"/>
</java>
</target>
you only have to add that property to the jenkins build to set that variable appropriately.
You can specify compiler arguments in the ant file target and set it up in Jenkins
<target name="gwtc-dev" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>[...]</classpath>
<jvmarg value="-Xmx2048M"/>
<jvmarg value="-Xss8M"/>
<arg line="-draftCompile"/>
<arg line="-localWorkers"/>
<arg value="4"/>
</java>

Add Build Settings for xcodeuild in Ant Script

I want to run this working line of code in ant-script:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild ARCHS="armv7 armv7s" ONLY_ACTIVE_ARCH=NO -workspace \APPNAME.xcworkspace -scheme APPNAMETarget build
So far I have this:
<?xml version="1.0" encoding="utf-8"?>
<project name="APPNAME" default="debugbuild" basedir=".">
<target name="debugbuild">
<echo message="Building debug build of APPNAME" />
<exec executable="/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild" os="Mac OS X">
<arg value="-workspace"/>
<arg value="APPNAME.xcworkspace"/>
<arg value="-scheme"/>
<arg value="APPNAMETarget"/>
<arg value="build"/>
</exec>
</target>
</project>
But I also need to add Build Settings (ARCHS="armv7 armv7s" ONLY_ACTIVE_ARCH=NO) but don't know how to add them in the script. I tried
<env key="ONLY_ACTIVE_ARCH" value="NO"/>
But it didn't work.
I found a solution. I just had to add them as arguments like the other but I had to get rid of the parenthesis which were fine in the command line. I hope it is helpful for other because I spend some time on this:
<?xml version="1.0" encoding="utf-8"?>
<project name="APPNAME" default="debugbuild" basedir=".">
<target name="debugbuild">
<echo message="Building debug build of APPNAME" />
<exec executable="/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild" os="Mac OS X">
<arg value="-workspace"/>
<arg value="APPNAME.xcworkspace"/>
<arg value="-scheme"/>
<arg value="APPNAMETarget"/>
<arg value="build"/>
<arg value="ARCHS=armv7 armv7s"/>
<arg value="ONLY_ACTIVE_ARCH=NO"/>
</exec>
</target>
</project>

ajdt.pdebuild.scripts not set during AJDT headless PDE build

I have an eclipse rcp application being developed in eclipse 3.5. I am able to successfully execute pde headless build in ant (from command shell outside eclipse) via the following target entry:
<target name="compile">
<java classname="org.eclipse.equinox.launcher.Main" fork="true" failonerror="true" dir="some-dir">
<arg value="-application" />
<arg value="org.eclipse.ant.core.antRunner" />
<arg value="-buildfile" />
<arg value="${eclipse.location}/plugins/org.eclipse.pde.build_${some-version}/scripts/productBuild/productBuild.xml" />
<arg value="-Dtimestamp=${timestamp}" />
<arg value="-propertyfile" />
<arg value="${some-dir}/ant.properties" />
<classpath>
<pathelement
location="${eclipse.location}/plugins/org.eclipse.equinox.launcher_${some-version}.jar" />
</classpath>
</java>
</target>
But once AspectJ (AJDT) got involved, I modified the target above like so:
<target name="compile">
<java classname="org.eclipse.equinox.launcher.Main" fork="true" failonerror="true" dir="${some-dir}">
<arg value="-application" />
<arg value="org.eclipse.ant.core.antRunner" />
<arg value="-buildfile" />
**<arg value="${eclipse.location}/plugins/org.eclipse.ajdt.pde.build_2.0.2.e35x-release-20101021-0900/scripts/productBuild/productBuild.xml" />**
<arg value="-Dtimestamp=${timestamp}" />
<arg value="-propertyfile" />
<arg value="${some-dir}/ant.properties" />
**<jvmarg value="-Dajdt.pdebuild.home=${eclipse.location}/plugins/org.eclipse.ajdt.pde.build_2.0.2.e35x-release-20101021-0900" />**
<classpath>
<pathelement
location="${eclipse.location}/plugins/org.eclipse.equinox.launcher_${some-version}.jar" />
</classpath>
</java>
</target>
Unfortunately, I am now getting the following error:
c:\eclipse-3.5\plugins\org.eclipse.ajdt.pde.build_2.0.2.e35x-release-20101021-0900\scripts\productBuild\productBuild.xml:8: Cannot find ${ajdt.pdebuild.scripts}/productBuild/allElements.xml imported from c:\eclipse-3.5\plugins\org.eclipse.ajdt.pde.build_2.0.2.e35x-release-20101021-0900\scripts\productBuild\productBuild.xml
does anyone have any idea on how to set the ajdt.pdebuild.scripts value? thank you!!!
See this blog post:
http://contraptionsforprogramming.blogspot.com/2010/03/ajdt-pde-builds-redux.html
You should not be using AJDT-PDE. That is the old way of doing things and is no longer supported. Instead, you should be making changes to your build.properties file:
# required
compilerAdapter=org.eclipse.ajdt.core.ant.AJDT_AjcCompilerAdapter
sourceFileExtensions=*.java, *.aj
# optional
compilerArg=-aspectpath other.jar
Read the blog post for more details.
there are several steps needed to wrangle ajdt-pde headless build to execute in eclipse 3.5:
1) add ajdt.pdebuild.scripts param with its respective value as a "jvmarg" to the above-shown "java" block.
2) in .../scripts/productBuild/productBuild.xml, change property name="allElementsFile" value="productBuild/allElements.xml" to this property name="allElementsFile" value="${ajdt.pdebuild.scripts}/productBuild/allElements.xml"
3) in .../scripts/productBuild/productBuild.xml, comment out import file="${ajdt.pdebuild.scripts}/productBuild/allElements.xml"
4) in .../scripts/productBuild/productBuild.xml, paste the following import statement: import file="${ajdt.pdebuild.scripts}/build.xml"