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.

common.xml 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="common" basedir="." default="" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">
  3. <tstamp>
  4. <format property="build.date" pattern="yyyy-MM-dd" />
  5. </tstamp>
  6. <dirname property="vaadin.basedir" file="${ant.file.common}" />
  7. <property name="gwt.basedir" location="${vaadin.basedir}/../gwt" />
  8. <property file="${vaadin.basedir}/build.properties" />
  9. <property name="modules.to.publish.to.maven" value="shared,server,client,client-compiler,client-compiled,theme-compiler,themes" />
  10. <property name="modules.to.publish.to.download" value="${modules.to.publish.to.maven},all" />
  11. <ivy:settings file="${vaadin.basedir}/ivysettings.xml" />
  12. <ivy:settings file="${vaadin.basedir}/ivysettings.xml" id="ivysettings" />
  13. <ivy:resolve file="${vaadin.basedir}/ivy-taskdefs.xml" conf="taskdefs" log="quiet" />
  14. <ivy:cachepath pathid="taskdefs.classpath" conf="taskdefs" />
  15. <taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml" classpathref="taskdefs.classpath" />
  16. <!-- ant contrib for Maven integration -->
  17. <taskdef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="taskdefs.classpath" />
  18. <!-- FIXME These are not available in other files -->
  19. <antcontrib:propertyregex property="vaadin.version.major" input="${vaadin.version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\1" />
  20. <antcontrib:propertyregex property="vaadin.version.minor" input="${vaadin.version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\2" />
  21. <antcontrib:propertyregex property="vaadin.version.revision" input="${vaadin.version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\3" />
  22. <union id="empty.reference" />
  23. <property name="filtered.webcontent.dir" location="${vaadin.basedir}/result/filteredWebContent" />
  24. <property name="release-notes-tickets-file" location="${vaadin.basedir}/result/release-notes-tickets.html" />
  25. <target name="filter.webcontent" unless="webcontent.filtered" depends="fetch-release-notes-tickets">
  26. <property name="webcontent.filtered" value="true" />
  27. <!-- Running without build.release-notes will cause an error, which is ignored -->
  28. <loadfile property="release-notes-tickets" srcFile="${release-notes-tickets-file}" failonerror="false" />
  29. <delete dir="${filtered.webcontent.dir}" />
  30. <copy todir="${filtered.webcontent.dir}">
  31. <fileset dir="${vaadin.basedir}/WebContent">
  32. <include name="img/**" />
  33. </fileset>
  34. </copy>
  35. <copy todir="${filtered.webcontent.dir}">
  36. <fileset dir="${vaadin.basedir}/WebContent">
  37. <patternset>
  38. <include name="release-notes.html" />
  39. <include name="license.html" />
  40. <include name="licenses/**" />
  41. <include name="css/**" />
  42. </patternset>
  43. </fileset>
  44. <filterchain>
  45. <expandproperties />
  46. <replacetokens begintoken="@" endtoken="@">
  47. <token key="version" value="${vaadin.version}" />
  48. </replacetokens>
  49. <replacetokens begintoken="@" endtoken="@">
  50. <token key="version-minor" value="${vaadin.version.major}.${vaadin.version.minor}" />
  51. </replacetokens>
  52. <replacetokens begintoken="@" endtoken="@">
  53. <token key="builddate" value="${build.date}" />
  54. </replacetokens>
  55. <replacetokens begintoken="@" endtoken="@">
  56. <token key="release-notes-tickets" value="${release-notes-tickets}" />
  57. </replacetokens>
  58. </filterchain>
  59. </copy>
  60. </target>
  61. <target name="fetch-release-notes-tickets" unless="built.release-notes" if="build.release-notes">
  62. <mkdir dir="${vaadin.basedir}/result"/>
  63. <subant buildpath="${vaadin.basedir}/buildhelpers" target="fetch-release-notes-tickets" antfile="build.xml" inheritall="true">
  64. <property name="output" location="${release-notes-tickets-file}" />
  65. </subant>
  66. <property name="built.release-notes" value="1" />
  67. </target>
  68. <fileset dir="${filtered.webcontent.dir}" id="common.files.for.all.jars">
  69. <patternset>
  70. <include name="release-notes.html" />
  71. <include name="license.html" />
  72. <include name="licenses/**" />
  73. <include name="css/**" />
  74. <include name="img/**" />
  75. </patternset>
  76. </fileset>
  77. <target name="pom.xml" description="Generates a pom.xml based on the Ivy configuration. Either for a snapshot or a release version" depends="pom.xml.release,pom.xml.snapshot">
  78. </target>
  79. <target name="pom.xml.release" if="build.release">
  80. <fail unless="result.dir" message="No result.dir parameter given" />
  81. <property name="ivy.xml" location="${result.dir}/../ivy.xml" />
  82. <property name="pom.xml" location="${result.dir}/lib/${module.name}-${vaadin.version}.pom" />
  83. <property name="conf" value="build, build-provided" />
  84. <property name="vaadin.maven.version" value="${vaadin.version}" />
  85. <ivy:makepom templatefile="${vaadin.basedir}/pom-template.xml" ivyfile="${ivy.xml}" pomfile="${pom.xml}" conf="${conf}">
  86. <mapping conf="build" scope="compile" />
  87. <mapping conf="build-provided" scope="provided" />
  88. </ivy:makepom>
  89. </target>
  90. <target name="pom.xml.snapshot" unless="build.release">
  91. <fail unless="result.dir" message="No result.dir parameter given" />
  92. <property name="ivy.xml" location="${result.dir}/../ivy.xml" />
  93. <property name="pom.xml" location="${result.dir}/lib/${module.name}-${vaadin.version}.pom" />
  94. <property name="temp.pom.xml" location="${pom.xml}.temp" />
  95. <property name="conf" value="build, build-provided" />
  96. <property name="vaadin.maven.version" value="${vaadin.version.major}.${vaadin.version.minor}-SNAPSHOT" />
  97. <ivy:makepom templatefile="${vaadin.basedir}/pom-template.xml" ivyfile="${ivy.xml}" pomfile="${temp.pom.xml}" conf="${conf}">
  98. <mapping conf="build" scope="compile" />
  99. <mapping conf="build-provided" scope="provided" />
  100. </ivy:makepom>
  101. <copy file="${temp.pom.xml}" tofile="${pom.xml}">
  102. <filterchain>
  103. <replacestring from="${vaadin.version}" to="${vaadin.maven.version}" />
  104. </filterchain>
  105. </copy>
  106. <delete file="${temp.pom.xml}" />
  107. </target>
  108. <target name="sources.jar" depends="compile, filter.webcontent">
  109. <fail unless="result.dir" message="No result.dir parameter given" />
  110. <fail unless="module.name" message="No module.name parameter given" />
  111. <fail unless="src" message="No src directory parameter given" />
  112. <property name="sources.jar" location="${result.dir}/lib/${module.name}-${vaadin.version}-sources.jar" />
  113. <jar file="${sources.jar}" compress="true">
  114. <fileset dir="${src}">
  115. <patternset>
  116. <include name="**/*.java" />
  117. </patternset>
  118. </fileset>
  119. <fileset refid="common.files.for.all.jars" />
  120. <restrict>
  121. <union refid="extra.jar.includes" />
  122. <name name="*.java" />
  123. </restrict>
  124. </jar>
  125. </target>
  126. <target name="javadoc.jar" depends="dependencies, filter.webcontent">
  127. <fail unless="result.dir" message="No result.dir parameter given" />
  128. <fail unless="module.name" message="No module.name parameter given" />
  129. <property name="src" location="{$result.dir}/../src" />
  130. <property name="javadoc.dir" value="${result.dir}/javadoc" />
  131. <property name="javadoc.jar" location="${result.dir}/lib/${module.name}-${vaadin.version}-javadoc.jar" />
  132. <javadoc destdir="${javadoc.dir}" author="true" version="true" use="true" windowtitle="${module.name}">
  133. <packageset dir="${src}" excludes="${classes.exclude}" />
  134. <doctitle>&lt;h1>${module.name}&lt;/h1></doctitle>
  135. <!-- <header><![CDATA[<script type="text/javascript" src=".html-style/style.js"></script>]]></header> -->
  136. <bottom>${javadoc.bottom}</bottom>
  137. <link offline="true" href="http://docs.oracle.com/javase/6/docs/api/" packagelistLoc="build/javadoc/j2se-1.6.0" />
  138. <link offline="true" href="http://java.sun.com/j2ee/1.4/docs/api/" packagelistLoc="build/javadoc/j2ee-1.4" />
  139. <classpath refid="classpath.compile.dependencies" />
  140. </javadoc>
  141. <!-- Create a javadoc jar -->
  142. <jar file="${javadoc.jar}" compress="true">
  143. <fileset dir="${javadoc.dir}" />
  144. <fileset refid="common.files.for.all.jars" />
  145. </jar>
  146. </target>
  147. <target name="jar" depends="compile, pom.xml, filter.webcontent">
  148. <fail unless="result.dir" message="No result.dir parameter given" />
  149. <fail unless="module.name" message="No module.name parameter given" />
  150. <property name="result.jar" location="${result.dir}/lib/${module.name}-${vaadin.version}.jar" />
  151. <property name="classes" location="{$result.dir}/classes" />
  152. <property name="src" location="{$result.dir}/../src" />
  153. <union id="jar.files">
  154. <fileset dir="${classes}" excludes="${classes.exclude}" erroronmissingdir="false" />
  155. <fileset dir="${src}" excludes="${jar.exclude}" erroronmissingdir="false" />
  156. <fileset refid="common.files.for.all.jars" />
  157. <union refid="extra.jar.includes" />
  158. </union>
  159. <jar destfile="${result.jar}" duplicate="fail" index="true">
  160. <manifest>
  161. <attribute name="Implementation-Vendor" value="${vaadin.vendor}" />
  162. <attribute name="Implementation-URL" value="${vaadin.url}" />
  163. <attribute name="Implementation-Version" value="${vaadin.version}" />
  164. </manifest>
  165. <union refid="jar.files" />
  166. </jar>
  167. <antcall target="common.make-osgi-bundle">
  168. <param name="jar" value="${result.jar}" />
  169. <param name="bundle-version" value="${vaadin.version}" />
  170. <param name="bundle-name" value="${module.name}" />
  171. <param name="bundle-symbolic" value="${module.symbolic}" />
  172. <param name="bundle-vendor" value="${vaadin.vendor}" />
  173. </antcall>
  174. </target>
  175. <!-- Add OSGi attributes to the manifest of the given jar -->
  176. <target name="make-osgi-bundle">
  177. <fail unless="jar" message="No jar parameter given" />
  178. <fail unless="bundle-name" message="No bundle-name parameter given" />
  179. <fail unless="bundle-symbolic" message="No bundle-symbolic parameter given" />
  180. <fail unless="bundle-version" message="No bundle-version parameter given" />
  181. <fail unless="bundle-vendor" message="No bundle-vendor parameter given" />
  182. <property name="bundle-manifestversion" value="2" />
  183. <jar file="${jar}" update="true">
  184. <manifest>
  185. <attribute name="Bundle-Version" value="${bundle-version}" />
  186. <attribute name="Bundle-ManifestVersion" value="${bundle-manifestversion}" />
  187. <attribute name="Bundle-Name" value="${bundle-name}" />
  188. <attribute name="Bundle-SymbolicName" value="${bundle-symbolic}" />
  189. <attribute name="Bundle-Vendor" value="${bundle-vendor}" />
  190. <attribute name="Bundle-RequiredExecutionEnvironment" value="JavaSE-${vaadin.java.version}" />
  191. </manifest>
  192. </jar>
  193. <antcontrib:if>
  194. <isset property="import-package" />
  195. <then>
  196. <jar file="${result.jar}" update="true">
  197. <manifest>
  198. <attribute name="Import-Package" value="${import-package}" />
  199. </manifest>
  200. </jar>
  201. </then>
  202. </antcontrib:if>
  203. <antcontrib:if>
  204. <isset property="require-bundle" />
  205. <then>
  206. <jar file="${result.jar}" update="true">
  207. <manifest>
  208. <attribute name="Require-Bundle" value="${require-bundle}" />
  209. </manifest>
  210. </jar>
  211. </then>
  212. </antcontrib:if>
  213. <antcontrib:if>
  214. <isset property="export-package" />
  215. <then>
  216. <jar file="${result.jar}" update="true">
  217. <manifest>
  218. <attribute name="Export-Package" value="${export-package}" />
  219. </manifest>
  220. </jar>
  221. </then>
  222. </antcontrib:if>
  223. <!-- Generate the Export-Package attribute in the manifest -->
  224. <java classname="com.vaadin.buildhelpers.GeneratePackageExports" failonerror="true" fork="yes">
  225. <arg value="${jar}" />
  226. <arg line="com/vaadin com/google ${osgi.extra.package.prefixes}" />
  227. <classpath refid="vaadin.buildhelpers.classpath" />
  228. <jvmarg value="-Dvaadin.version=${vaadin.version}" />
  229. </java>
  230. </target>
  231. <target name="compile" description="Compiles the module" depends="dependencies, directories" if="src-exists">
  232. <fail unless="module.name" message="No module name given" />
  233. <javac srcdir="${src}" destdir="${classes}" source="${vaadin.java.version}" target="${vaadin.java.version}" debug="true" encoding="UTF-8" includeantruntime="false">
  234. <classpath refid="classpath.compile.dependencies" />
  235. <classpath refid="classpath.compile.custom" />
  236. </javac>
  237. </target>
  238. <target name="exec-buildhelper" depends="compile">
  239. <fail unless="main.class" message="No main class given in 'main.class'" />
  240. <fail unless="output" message="No output file given in 'output'" />
  241. <java classname="${main.class}" output="${output}" failonerror="true" fork="yes">
  242. <classpath refid="vaadin.buildhelpers.classpath" />
  243. <classpath refid="classpath.compile.dependencies" />
  244. <jvmarg value="-Dvaadin.version=${vaadin.version}" />
  245. </java>
  246. </target>
  247. <target name="directories">
  248. <property name="result.dir" location="result" />
  249. <property name="src" location="${result.dir}/../src" />
  250. <property name="classes" location="${result.dir}/classes" />
  251. <available file="${src}" type="dir" property="src-exists" />
  252. <mkdir dir="${classes}" />
  253. </target>
  254. <target name="test.run" depends="test.compile">
  255. <fail unless="module.name" message="No module name given" />
  256. <property name="result.dir" location="result" />
  257. <property name="classes" location="${result.dir}/classes" />
  258. <property name="test.src" location="${result.dir}/../tests/src" />
  259. <property name="test.classes" location="${result.dir}/tests/classes" />
  260. <junit printsummary="withOutAndErr" fork="yes">
  261. <formatter usefile="false" type="plain" />
  262. <jvmarg value="-ea" />
  263. <classpath location="${test.classes}" />
  264. <classpath location="${classes}" />
  265. <classpath refid="classpath.compile.custom" />
  266. <classpath refid="classpath.test.dependencies" />
  267. <batchtest fork="yes">
  268. <fileset dir="${test.src}">
  269. <exclude name="**/Abstract*" />
  270. <exclude name="com/vaadin/tests/data/bean/*" />
  271. <exclude name="com/vaadin/tests/util/*" />
  272. <exclude name="**/VaadinClasses.java" />
  273. <exclude name="**TestRunner.java" />
  274. <exclude name="**/SQLTestsConstants.java" />
  275. </fileset>
  276. </batchtest>
  277. </junit>
  278. </target>
  279. <target name="test.compile" description="Compiles tests" depends="compile, dependencies.test">
  280. <fail unless="module.name" message="No module name given" />
  281. <property name="result.dir" location="result" />
  282. <property name="base.dir" location="${result.dir}/.." />
  283. <property name="test.src" location="${base.dir}/tests/src" />
  284. <property name="test.resources" location="${base.dir}/tests/resources" />
  285. <property name="test.classes" location="${result.dir}/tests/classes" />
  286. <property name="classes" location="${result.dir}/classes" />
  287. <mkdir dir="${test.classes}" />
  288. <javac srcdir="${test.src}" destdir="${test.classes}" source="${vaadin.java.version}" target="${vaadin.java.version}" debug="true" encoding="UTF-8" includeantruntime="false">
  289. <classpath refid="classpath.test.dependencies" />
  290. <classpath location="${classes}" />
  291. <classpath refid="classpath.test.custom" />
  292. </javac>
  293. <!-- Copy resources -->
  294. <copy todir="${test.classes}" failonerror="false">
  295. <fileset dir="${test.resources}" />
  296. </copy>
  297. </target>
  298. <target name="dependencies" description="Resolves dependencies needed by this module">
  299. <property name='conf' value="build, build-provided" />
  300. <ivy:resolve resolveid="common" conf="${conf}" />
  301. <ivy:cachepath pathid="classpath.compile.dependencies" conf="${conf}" />
  302. </target>
  303. <target name="dependencies.test" description="Resolves dependencies needed by test">
  304. <ivy:resolve resolveid="common" conf="test" />
  305. <ivy:cachepath pathid="classpath.test.dependencies" conf="test" />
  306. </target>
  307. <target name="clean">
  308. <fail unless="result.dir" message="No result.dir parameter given" />
  309. <delete dir="${result.dir}" />
  310. </target>
  311. <target name="publish-local" description="Publishes the given module to the local repository">
  312. <fail unless="result.dir" message="No result.dir parameter given" />
  313. <property name="conf" value="*(public)" />
  314. <ivy:resolve conf="${conf}" />
  315. <ivy:publish settingsref="ivysettings" conf="${conf}" resolver="build-temp" overwrite="true" forcedeliver="true">
  316. <!-- <artifacts pattern="${result.dir}/[artifact]-[revision].[ext]" />-->
  317. <artifacts pattern="${result.dir}/lib/[artifact]-[revision](-[classifier]).[ext]" />
  318. </ivy:publish>
  319. </target>
  320. <target name="publish.to.local.maven">
  321. <property name="conf" value="*(public)" />
  322. <ivy:resolve conf="${conf}" />
  323. <ivy:publish conf="${conf}" resolver="local-maven" overwrite="true">
  324. </ivy:publish>
  325. </target>
  326. <!-- Checkstyle conf -->
  327. <property name="cs.dir" location="${vaadin.basedir}/checkstyle" />
  328. <property name="cs.xml" location="${cs.dir}/vaadin-checkstyle.xml" />
  329. <property name="cs.header-file" location="${cs.dir}/header" />
  330. <taskdef resource="checkstyletask.properties" uri="antlib:com.puppycrawl.tools.checkstyle" classpathref="taskdefs.classpath" />
  331. <target name="checkstyle">
  332. <fail unless="result.dir" message="No result.dir parameter given" />
  333. <fail unless="cs.src" message="No cs.src parameter given" />
  334. <property name="result.dir.full" location="${result.dir}"/>
  335. <mkdir dir="${result.dir}" />
  336. <echo>##teamcity[importData type='checkstyle' path='${result.dir.full}/checkstyle-errors.xml']</echo>
  337. <cs:checkstyle config="${cs.xml}" failOnViolation="false">
  338. <fileset dir="${cs.src}" includes="**/*.java" />
  339. <formatter type="xml" toFile="${result.dir}/checkstyle-errors.xml"/>
  340. <property key="checkstyle.header.file" file="${cs.header-file}" />
  341. </cs:checkstyle>
  342. </target>
  343. </project>