You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-widgetset.xml 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?xml version="1.0"?>
  2. <!--
  3. Client-side code is compiled by using GWTCompiler which compiles client-side Java code into
  4. JavaScript. Generated files are located under WebContent/VAADIN/widgetsets/*.
  5. Client-side compilation is required if you create new or modify existing widgets.
  6. You may use either this script or Vaadin Hosted Mode Browser.launch (in Eclipse)
  7. to compile your client-side java code.
  8. By default Vaadin first tries to serve widgetset resources from the file system, if that
  9. fails then files are streamed from vaadin-@version@.jar.
  10. See configure target to adjust this buildfile.
  11. -->
  12. <project name="Widgetset compile example" basedir="." default="compile-widgetset">
  13. <!--
  14. Update based on your project structure, by default this buildfile assumes that you
  15. 1. use WebContent under your project's root directory
  16. 2. WebContent/WEB-INF/lib/vaadin-@version@.jar exists
  17. 3. WebContent/WEB-INF/src contains your project source files
  18. 4. gwt directory contains extracted GWT distribution
  19. -->
  20. <target name="configure">
  21. <!-- Path from this file to the project root -->
  22. <property name="base"
  23. value="../../../" />
  24. <!-- Location of GWT distribution -->
  25. <property name="gwt-location"
  26. value="${base}gwt" />
  27. <!-- Location of Vaadin JAR -->
  28. <property name="vaadin-jar-location"
  29. value="${base}WebContent/WEB-INF/lib/vaadin-@version@.jar" />
  30. <!-- Location of project source code -->
  31. <property name="src-location"
  32. value="${base}WebContent/WEB-INF/src" />
  33. <!-- Target where to compile server-side classes -->
  34. <property name="server-side-destination"
  35. value="${base}WebContent/WEB-INF/classes"/>
  36. <!-- Target where to compile the widget set -->
  37. <property name="client-side-destination"
  38. value="${base}WebContent/VAADIN/widgetsets" />
  39. </target>
  40. <!-- Modify this configuration to compile your own widgetset -->
  41. <target name="configure-widgetset">
  42. <echo>Modify this example Ant script to compile your own widget sets.</echo>
  43. <!-- Name of the widget set -->
  44. <property name="widgetset" value="com.vaadin.demo.colorpicker.gwt.ColorPickerWidgetSet"/>
  45. <!-- If generated automatically as a combining widget set -->
  46. <!-- from all the widget sets included in the class path. -->
  47. <!-- <property name="widgetset" value="com.vaadin.demo.widgetset.CombiningWidgetSet"/> -->
  48. <!-- <property name="generate.widgetset" value="1"/> -->
  49. <!-- Path to the generated widget set directory. Must be -->
  50. <!-- relative to $src-location, which must be the first -->
  51. <!-- entry in the class path. -->
  52. <property name="widgetset-path" value="com/vaadin/demo/widgetset"/>
  53. </target>
  54. <!-- Modify this configuration to package your own widgetset Jar. -->
  55. <target name="configure-jar">
  56. <!-- The compiled JAR name -->
  57. <property name="jar-destination" value="${base}colorpicker.jar"/>
  58. <!-- Title of the widget set (for JAR) -->
  59. <property name="widgetset-title" value="ColorPicker"/>
  60. <!-- Version of the widget set (for JAR) -->
  61. <property name="widgetset-version" value="1.0"/>
  62. <!-- Vendor of the widget set (for JAR) -->
  63. <property name="widgetset-vendor" value="Vaadin Ltd"/>
  64. </target>
  65. <!-- ================================================== -->
  66. <!-- Build Targets -->
  67. <!-- ================================================== -->
  68. <target name="init" depends="configure">
  69. <echo>Requirements for classpath:</echo>
  70. <echo> ${gwt-location}/gwt-dev.jar</echo>
  71. <echo> ${gwt-location}/gwt-user.jar</echo>
  72. <echo> ${gwt-location}/validation-api-1.0.0.GA.jar</echo>
  73. <echo> ${gwt-location}/validation-api-1.0.0.GA-sources.jar</echo>
  74. <echo> ${vaadin-jar-location}</echo>
  75. <echo> ${src-location}</echo>
  76. <echo>Output will be written into ${client-side-destination}</echo>
  77. <!-- Check that files exist -->
  78. <fail message="Some of the required files (listed above) are missing.">
  79. <condition><not><resourcecount count="5">
  80. <filelist files="${gwt-location}/gwt-dev.jar,${gwt-location}/gwt-user.jar,${gwt-location}/validation-api-1.0.0.GA.jar,${gwt-location}/validation-api-1.0.0.GA-sources.jar,${vaadin-jar-location}"/>
  81. </resourcecount></not></condition>
  82. </fail>
  83. <!-- Construct and check classpath -->
  84. <!-- Includes paths required for both server and client-side compilation -->
  85. <path id="compile.classpath">
  86. <!-- The source location must be first, as required by generate-widgetset. -->
  87. <pathelement path="${src-location}" />
  88. <pathelement path="${server-side-destination}" />
  89. <pathelement path="${vaadin-jar-location}" />
  90. <pathelement path="${gwt-location}/gwt-user.jar" />
  91. <pathelement path="${gwt-location}/gwt-dev.jar" />
  92. <pathelement path="${gwt-location}/validation-api-1.0.0.GA.jar" />
  93. <pathelement path="${gwt-location}/validation-api-1.0.0.GA-sources.jar" />
  94. <fileset dir="${base}WebContent/WEB-INF/lib/">
  95. <include name="*.jar"/>
  96. </fileset>
  97. </path>
  98. </target>
  99. <!-- Compiled server-side components are needed for building the client-side -->
  100. <target name="compile-server-side" depends="init">
  101. <javac srcdir="${src-location}" destdir="${server-side-destination}">
  102. <classpath>
  103. <path refid="compile.classpath"/>
  104. </classpath>
  105. </javac>
  106. </target>
  107. <!-- Generates a combined widget set from all widget -->
  108. <!-- sets in the class path, including project sources. -->
  109. <!-- Updates the configuration if it already exists. -->
  110. <target name="generate-widgetset"
  111. depends="compile-server-side, configure-widgetset"
  112. if="generate.widgetset">
  113. <!-- Create the directory if it does not already exist. -->
  114. <mkdir dir="${src-location}/${widgetset-path}"/>
  115. <java classname="com.vaadin.terminal.gwt.widgetsetutils.WidgetSetBuilder"
  116. failonerror="yes" fork="yes" maxmemory="256m">
  117. <arg value="${widgetset}"/>
  118. <jvmarg value="-Xss1024k"/>
  119. <jvmarg value="-Djava.awt.headless=true"/>
  120. <classpath>
  121. <path refid="compile.classpath"/>
  122. </classpath>
  123. </java>
  124. </target>
  125. <!-- Build the widget set. -->
  126. <target name="compile-widgetset"
  127. depends="compile-server-side, generate-widgetset">
  128. <echo>Compiling ${widgetset}...</echo>
  129. <java classname="com.google.gwt.dev.Compiler"
  130. failonerror="yes" fork="yes" maxmemory="256m">
  131. <arg value="-war" />
  132. <arg value="${client-side-destination}" />
  133. <arg value="${widgetset}" />
  134. <jvmarg value="-Xss1024k"/>
  135. <jvmarg value="-Djava.awt.headless=true"/>
  136. <classpath>
  137. <path refid="compile.classpath"/>
  138. </classpath>
  139. </java>
  140. </target>
  141. <!-- Build JAR -->
  142. <target name="package-jar"
  143. depends="init, configure-widgetset, configure-jar">
  144. <jar jarfile="${jar-destination}" compress="true">
  145. <manifest>
  146. <attribute name="Vaadin-Package-Version" value="1" />
  147. <attribute name="Vaadin-Widgetsets" value="${widgetset}" />
  148. <attribute name="Implementation-Title" value="${widgetset-title}" />
  149. <attribute name="Implementation-Version" value="${widgetset-version}" />
  150. <attribute name="Implementation-Vendor" value="${widgetset-vendor}" />
  151. <!-- The following are Vaadin-specific. -->
  152. <attribute name="Vaadin-License-Title" value="Apache2" />
  153. <attribute name="Vaadin-License-File" value="http://www.apache.org/licenses/LICENSE-2.0" />
  154. </manifest>
  155. <!-- The built server-side classes are here. -->
  156. <fileset dir="${server-side-destination}">
  157. <patternset>
  158. <include name="**/*" />
  159. </patternset>
  160. </fileset>
  161. <!-- Especially all the widget set source files are required. -->
  162. <fileset dir="${src-location}">
  163. <patternset>
  164. <include name="**/*" />
  165. </patternset>
  166. </fileset>
  167. </jar>
  168. </target>
  169. </project>