In eclipse there is a plugin for vaadin.
When mark *.widgetset file in your project and click on on Compile vaading widgetset it compiles widgetset under WebContent\VAADIN\widgetsets. So my question is how to do it from command line without eclipse?
Note that: I've searched, but there are example of maven. This is old project and there is not maven configuration in it
You did not say which Vaadin version you are using but compiler class at least in Vaadin7 seems to be this:
https://vaadin.com/api/framework/7.6.8/com/vaadin/tools/WidgetsetCompiler.html
Not sure of commandline but I have this kind of ANT script for Vaadin7, maybe it will help a bit:
<target name="compile-widgetset" depends="init,resolve">
<delete includeEmptyDirs="true">
<fileset dir="${basedir}/WebContent/VAADIN/gwt-unitCache/" includes="**/*" defaultexcludes="no"/>
</delete>
<java classname="com.vaadin.tools.WidgetsetCompiler" failonerror="yes" fork="yes" maxmemory="600m">
<jvmarg value="-Xms512M"/>
<jvmarg value="-Xmx1024M"/>
<jvmarg value="-Xss8M"/>
<jvmarg value="-Djava.awt.headless=true" />
<arg value="-war"/>
<arg value="WebContent/VAADIN/widgetsets"/>
<arg value="${widgetset}"/>
<arg value="-logLevel"/>
<arg value="DEBUG"/>
<arg value="-style"/>
<arg value="OBF"/>
<classpath>
<pathelement path="${module.src.dir}"/>
<pathelement path="${module.build.dir}/WebContent/WEB-INF/classes" />
<pathelement path="${module.build.dir}/WebContent/WEB-INF/lib" />
<path refid="widgetset.path"/>
</classpath>
</java>
</target>
Compile instructions: https://vaadin.com/docs/v7/framework/clientside/clientside-compiling.html
I figured out using this url
https://github.com/canthony/simple-vaadin-7-compile-widgetset-ivy
I only added manifest tag to include dependecies in the META-INF/MANIFEST.MF file
<war destfile="${artifacts}/${warfilename}"
basedir="${workdir}"
webxml="${webroot}/WEB-INF/web.xml"
>
<manifest>
<attribute name="Dependencies" value="org.jboss.xnio, org.hibernate"/>
</manifest>
<lib dir="${webroot}/WEB-INF/lib" erroronmissingdir="no">
<include name="*.jar"/>
</lib>
<lib dir="${libraries}" erroronmissingdir="no">
<include name="*.jar"/>
</lib>
</war>
Related
I am a beginner in Ant and GWT and I was creating a new Ant project in GWT by following the steps mentioned on this GWT page: webAppCreator under the Creating an Ant project section. I was able to create this project successfully but I got the error build.xml does not exist! in the Command Prompt log. I am unable to fix this problem even after following all the steps mentioned here : ant build.xml file doesn't exist.
Here is my Command Prompt log:
C:\Users\TEST>webAppCreator -junit D:\SELENIUM\junit-4.10.jar -out foo com.example.foo.Foo
Generating from templates: [sample, eclipse, readme, _eclipse-test, _sample-test, ant]
Created directory foo
Created directory foo\src
Created directory foo\src\com\example\foo
Created directory foo\src\com\example\foo\client
Created directory foo\src\com\example\foo\server
Created directory foo\src\com\example\foo\shared
Created directory foo\test
Created directory foo\test\com\example\foo
Created directory foo\war
Created directory foo\war\WEB-INF
Created directory foo\test\com\example\foo\client
Created file foo\src\com\example\foo\Foo.gwt.xml
Created file foo\src\com\example\foo\client\GreetingService.java
Created file foo\src\com\example\foo\client\GreetingServiceAsync.java
Created file foo\src\com\example\foo\client\Foo.java
Created file foo\src\com\example\foo\server\GreetingServiceImpl.java
Created file foo\src\com\example\foo\shared\FieldVerifier.java
Created file foo\war\WEB-INF\web.xml
Created file foo\war\Foo.css
Created file foo\war\Foo.html
Created file foo\war\favicon.ico
Created file foo\.classpath
Created file foo\.project
Created file foo\Foo.launch
Created file foo\README.txt
Created file foo\FooSuite-dev.launch
Created file foo\FooSuite-prod.launch
Created file foo\test\com\example\foo\FooJUnit.gwt.xml
Created file foo\test\com\example\foo\FooSuite.java
Created file foo\test\com\example\foo\client\FooTest.java
Created file foo\build.xml
C:\Users\TEST>ant build
Buildfile: build.xml does not exist!
Build failed
C:\Users\TEST>ant devmode
Buildfile: build.xml does not exist!
Build failed
Here is my build.xml file:
<?xml version="1.0" encoding="utf-8" ?>
<project name="Foo" default="build" basedir=".">
<!-- Arguments to gwtc and devmode targets -->
<property name="gwt.args" value="" />
<!-- Configure path to GWT SDK -->
<property name="gwt.sdk" location="D:/GWT/gwt-2.8.1/gwt-2.8.1" />
<path id="project.class.path">
<pathelement location="war/WEB-INF/classes"/>
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
<pathelement location="${gwt.sdk}/gwt-dev.jar"/>
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar"/>
<pathelement location="${gwt.sdk}/validation-api-1.0.0.GA-sources.jar"/>
<fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
<!-- Add any additional non-server libs (such as JUnit) here -->
</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.sdk}/gwt-servlet.jar" />
<copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" />
<!-- Add any additional server libs that need to be copied -->
</target>
<target name="javac" depends="libs" description="Compile java source to bytecode">
<mkdir dir="war/WEB-INF/classes"/>
<javac srcdir="src" includes="**" encoding="utf-8"
destdir="war/WEB-INF/classes"
source="1.7" target="1.7" nowarn="true"
debug="true" debuglevel="lines,vars,source">
<classpath refid="project.class.path"/>
</javac>
<copy todir="war/WEB-INF/classes">
<fileset dir="src" excludes="**/*.java"/>
</copy>
</target>
<target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" maxmemory="512m">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
</classpath>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
<arg line="${gwt.args}"/>
<arg value="com.example.foo.Foo"/>
</java>
</target>
<target name="devmode" depends="javac" description="Run development mode (pass -Dgwt.args=-nosuperDevMode to fallback to classic DevMode)">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode" maxmemory="1g">
<classpath>
<pathelement location="src"/>
<path refid="project.class.path"/>
<pathelement location="${gwt.sdk}/gwt-codeserver.jar"/>
</classpath>
<arg value="-startupUrl"/>
<arg value="Foo.html"/>
<arg line="-war"/>
<arg value="war"/>
<!-- Additional arguments like -style PRETTY, -logLevel DEBUG or -nosuperDevMode -->
<arg line="${gwt.args}"/>
<arg value="com.example.foo.Foo"/>
<arg value="com.example.foo.Foo"/>
</java>
</target>
<target name="javac.tests" depends="javac" description="Compiles test code">
<javac srcdir="test" includes="**" encoding="utf-8"
source="1.7" target="1.7" nowarn="true"
destdir="war/WEB-INF/classes"
debug="true" debuglevel="lines,vars,source">
<classpath location="D:\SELENIUM\junit-4.10.jar"/>
<classpath refid="project.class.path"/>
</javac>
</target>
<target name="test.dev" depends="javac.tests" description="Run development mode tests">
<mkdir dir="reports/htmlunit.dev" />
<junit fork="yes" printsummary="yes" haltonfailure="yes" maxmemory="256m">
<sysproperty key="gwt.args" value="-devMode -logLevel WARN -war www-test" />
<sysproperty key="java.awt.headless" value="true" />
<classpath>
<pathelement location="src" />
<pathelement location="test" />
<path refid="project.class.path" />
<pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA.jar" />
<pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA-sources.jar" />
<pathelement location="D:\SELENIUM\junit-4.10.jar" />
</classpath>
<batchtest todir="reports/htmlunit.dev" >
<fileset dir="test" >
<include name="**/*Suite.java" />
</fileset>
</batchtest>
<formatter type="plain" />
<formatter type="xml" />
</junit>
</target>
<target name="test.prod" depends="javac.tests" description="Run production mode tests">
<mkdir dir="reports/htmlunit.prod" />
<junit fork="yes" printsummary="yes" haltonfailure="yes" maxmemory="256m">
<sysproperty key="gwt.args" value="-logLevel WARN -war www-test" />
<sysproperty key="java.awt.headless" value="true" />
<classpath>
<pathelement location="src" />
<pathelement location="test" />
<path refid="project.class.path" />
<pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA.jar" />
<pathelement location="D:/GWT/gwt-2.8.1/gwt-2.8.1/validation-api-1.0.0.GA-sources.jar" />
<pathelement location="D:\SELENIUM\junit-4.10.jar" />
</classpath>
<batchtest todir="reports/htmlunit.prod" >
<fileset dir="test" >
<include name="**/*Suite.java" />
</fileset>
</batchtest>
<formatter type="plain" />
<formatter type="xml" />
</junit>
</target>
<target name="test" description="Run development and production mode tests">
<antcall target="test.dev" />
<antcall target="test.prod" />
</target>
<target name="build" depends="gwtc" description="Build this project" />
<target name="war" depends="build" description="Create a war file">
<zip destfile="Foo.war" basedir="war"/>
</target>
<target name="clean" description="Cleans this project">
<delete dir="war/WEB-INF/classes" failonerror="false" />
<delete dir="war/foo" failonerror="false" />
</target>
</project>
Can someone please help me to fix this issue?
It seems your build.xml is created in a foo folder.
See this output:
Created file foo\build.xml
Go to the foo directory and then run ant.
C:\Users\TEST>ant build
Buildfile: build.xml does not exist!
Build failed
It means build file is absent in TEST directory. Checking your logs you have one in the :\Users\TEST\foo. So you should navigate into foo than try command via terminal one more time.
if you are on Mac :
brew install ant;
brew install ivy;
ant ivy-bootstrap ;
then go to top of ant project;
run ant
This is not truly a YUI-related question.
I am trying to use YUI Compressor(in fact a .jar application) for multiple JS files. I would like to get those files automatically(as opposed to specifying every file's name in build.xml).
Here is my build.xml file:
<?xml version="1.0" encoding="utf-8"?>
<project name="CUIProject" default="prod">
<target name="-load.properties">
<loadproperties>
<file file="minify.properties"/>
</loadproperties>
</target>
<!--Minify JS files-->
<target name="-js.minify">
<apply executable="java" parallel="false" dest="${build.dir}">
<fileset dir="${src.dir}"/>
<mapper>
<globmapper from="*.js" to="*-min.js" handledirsep="yes"/>
</mapper>
<arg value="-jar"/>
<arg path="${minifier.dir}"/>
<srcfile/>
<arg value="-o"/>
<targetfile/>
</apply>
</target>
<!--Build-->
<target name="prod"
depends="
-load.properties,
-js.minify
">
</target>
</project>
The problem is that I get a FileNotFound exception because for some reason the <targetdir/> is somehow escaped: the \ separator from Windows is used as an escaping character, so my path because just one very large word.
How can I avoid such a behavior?
I had the same issue with YUI. The easiest way I found is to use the Ant-Contrib <for> task.
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<fileset dir="${antlib.dir}/antcontrib">
<include name="*.jar"/>
</fileset>
</classpath>
</taskdef>
<!-- Minimize Concatinated JavaScript Files -->
<for param="concat.dir">
<dirset dir="${work.js.dir}">
<include name="*"/>
</dirset>
<sequential>
<echo message="[java] Minimized #{concat.dir}/concat-${build.id}-min.js>"/>
<java jar="${yui.compressor.jar}"
failonerror="true"
fork="true">
<arg value="-o"/>
<arg value="#{concat.dir}/concat-${build.id}-min.js"/>
<arg value="#{concat.dir}/concat-${build.id}.js"/>
</java>
</sequential>
</for>
Also take a look at the <pathconvert> task. This will convert the path separator from one OS to another. This may fix your issue. The File Mapper page in Ant's manual contains some examples using <pathconvert>.
I have a web project that deploys war files, and right now I can deploy to Glassfish in Windows. Here is my build.xml's necessary part.
<target
name="deploywar"
description="Varolan WAR dosyasını yayınlar." >
<echo level="info" >
Proje sunucuda yayinlaniyor...
</echo>
<exec
executable="cmd"
failonerror="true"
output="${out.txt}" >
<arg value="/c" />
<arg value="${glassfish.path}/glassfish/bin/asadmin --passwordfile ${password.file} deploy --contextroot /GlassfishDeployment ${deployyolu}/${war.filename}" />
</exec>
</target>
BUT I want to re-write my code to work on all platforms. I did some searchs about it which ends up with this helpful page. I wanted to try this method. I added necessary Jar file in to my project. Then I did these task definitions ;
<fileset dir="WebContent/WEB-INF/lib">
<include name="sun-appserv-ant.jar"/>
</fileset>
<target name="as-ant-init">
<taskdef name="sun-appserv-deploy"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask" />
<taskdef name="sun-appserv-undeploy"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.UndeployTask" />
<taskdef name="sun-appserv-component"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.ComponentTask" />
<taskdef name="sun-appserv-admin"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.AdminTask" />
<taskdef name="sun-appserv-jspc"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.SunJspc" />
<taskdef name="sun-appserv-update"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.UpdateTask" />
<taskdef name="sun-appserv-instance"
classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.InstanceTask" />
<taskdef name="wsgen" classname="com.sun.tools.ws.ant.WsGen" />
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport" />
<classpath path="${glassfish.path}/lib/sun-appserv-ant.jar" />
</target>
I ended up with this error;
taskdef class org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask cannot be found
Could anyone help me about solving this error or another way to deploy w/o platform?
Thanks.
I used this code fragment from this reply ;
<presetdef name="asadmin">
<java jar="${glassfish.home}/modules/admin-cli.jar" fork="true" jvm="${java.home}/bin/java" >
<arg line="--port ${glassfish.admin.port}" />
</java>
</presetdef>
<target name="deploy">
<asadmin failonerror="true">
<arg value="deploy" />
<arg value="--force=true" />
<arg value="${ear.file}" />
</asadmin>
</target>
It solved my problem.
Thanks to;
https://stackoverflow.com/a/7299637/1400515
We have a large project that is created using Vaadin 6.8
We recently decided to upgrade to version 7.
Refactor the code that caused it in line with changes in the framework.
There was a problem: we can not compile widgetset ...
The project was created in Netbeans IDE, a compilation produced with Ant script.
Here's a error:
Here's Ant script:
<import file="nbproject/build-impl.xml"/>
<target name="widgetset-init">
<property name="widgetset" value="user_interface.ApplicationWidgetSet"/>
<property name="widgetset-path" value="user_interface"/>
<property name="client-side-destination" value="web/VAADIN/widgetsets" />
<property name="generate.widgetset" value="1"/>
</target>
<target name="generate-widgetset" depends="widgetset-init, compile" if="generate.widgetset">
<echo>Updating ${widgetset}...</echo>
<mkdir dir="${src.dir}/${widgetset-path}"/>
<java classname="com.vaadin.server.widgetsetutils.WidgetSetBuilder" failonerror="yes" fork="yes" maxmemory="512m">
<arg value="${widgetset}"/>
<jvmarg value="-Xss1024k"/>
<jvmarg value="-Djava.awt.headless=true"/>
<classpath>
<pathelement path="${src.dir}" />
<pathelement path="${javac.classpath}" />
<pathelement path="${build.web.dir}/WEB-INF/classes" />
</classpath>
</java>
</target>
<target name="compile-widgetset" depends="init, widgetset-init, generate-widgetset">
<echo>Compiling ${widgetset} into ${client-side-destination} directory...</echo>
<java classname="com.google.gwt.dev.Compiler" failonerror="yes" fork="yes" maxmemory="512m">
<arg value="-war" />
<arg value="${client-side-destination}" />
<arg value="${widgetset}" />
<jvmarg value="-Xss1024k"/>
<jvmarg value="-Djava.awt.headless=true"/>
<classpath>
<pathelement path="${src.dir}" />
<pathelement path="${javac.classpath}" />
<pathelement path="${build.web.dir}/WEB-INF/classes" />
</classpath>
</java>
</target>
i got a problem by executing groovy from an ant file.
In Eclipse with a launcher, everything works fine but wehn i run the ant file i got the following output:
Main.groovy: 71: unable to resolve class InitializeDatabase
[groovyc] # line 71, column 40. [groovyc] java.lang.Object
javaClassInstance = new InitializeDatabase()
[groovyc]
[groovyc] 1 error
InitializeDatabase is a java class in the same package..
public class InitializeDatabase {
public void test() {
System.out.println("Hello Groovy");
}
}
I guess the problem is located at the ant file:
<project name="tp" basedir="." default="dbsetup">
<target name="dbsetup">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
<classpath>
<fileset dir="../files/lib/default" includes="*.jar" />
</classpath>
</taskdef>
<delete dir="bin" />
<mkdir dir="bin" />
<groovyc srcdir="src" destdir="bin" />
<java classname="groovy.ui.GroovyMain" dir="../.." fork="true" failonerror="true">
<classpath>
<fileset dir="../files/lib/default" includes="*.jar"/>
<pathelement location="bin"/>
</classpath>
<arg line="build/scripts/src/build/Main.groovy" />
</java>
</target>
</project>
Can someone help me please?
You need to include the javac task inside your groovyc one. Change:
<groovyc srcdir="src" destdir="bin" />
to
<groovyc srcdir="src" destdir="build">
<javac/>
</groovyc>
And it should work fine. As it says here:
Joint compilation means that the Groovy compilation will parse the
Groovy source files, create stubs for all of them, invoke the Java
compiler to compile the stubs along with Java sources, and then
continue compilation in the normal Groovy compiler way. This allows
mixing of Java and Groovy files without constraint.
...
The right way of working is, of course, to use a nested tag and all
the attributes and further nested tags as required.
Here is the final file which works great.
Thanks to tim_yates!
<target name="dbsetup">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc">
<classpath>
<fileset dir="../files/lib/default" includes="*.jar" />
</classpath>
</taskdef>
<delete dir="bin" />
<mkdir dir="bin" />
<groovyc srcdir="src" destdir="bin">
<javac source="1.6" target="1.6" debug="on" />
</groovyc>
<java classname="groovy.ui.GroovyMain" dir="../.." fork="true" failonerror="true">
<classpath>
<fileset dir="../files/lib/default" includes="*.jar"/>
<pathelement location="bin"/>
</classpath>
<arg line="build/scripts/src/build/access/AccessDbSetup.groovy" />
</java>
</target>