template.xml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <project name="build installers" default="build" basedir=".">
  2. <!--<property file="${basedir}/template.properties"/>-->
  3. <target name="build" depends="init,prepare-sources,prepare-zip,-build,post-build,run-build"/>
  4. <target name="-init-props">
  5. <available file="${suite.location}/nbproject/project.properties" property="do.load.ant.props"/>
  6. <available file="${suite.location}/pom.xml" property="do.load.maven.props"/>
  7. </target>
  8. <target name="-init-ant-props" if="do.load.ant.props" depends="-init-props">
  9. <property file="${suite.location}/nbproject/project.properties" prefix="suite.props."/>
  10. </target>
  11. <target name="-init-maven-props" if="do.load.maven.props" depends="-init-props">
  12. <xmlproperty file="${suite.location}/pom.xml" prefix="pom.props"/>
  13. <property name="suite.props.app.name" value="${pom.props.project.properties.brandingToken}"/>
  14. <property name="suite.props.app.title" value="${pom.props.project.artifactId}"/>
  15. </target>
  16. <target name="init" depends="-clean,-init-ant-props,-init-maven-props">
  17. <property name="installer.build.dir" value="${suite.location}/build/installer"/>
  18. <property name="suite.dist.directory" value="${suite.location}/dist"/>
  19. <property name="suite.dist.zip" value="${suite.dist.directory}/${suite.props.app.name}.zip"/>
  20. <property name="installers.file.prefix" value="${suite.props.app.name}"/>
  21. <delete dir="${installer.build.dir}" includeemptydirs="yes" failonerror="false"/>
  22. <mkdir dir="${installer.build.dir}"/>
  23. </target>
  24. <target name="-clean">
  25. </target>
  26. <target name="post-build">
  27. </target>
  28. <target name="-build">
  29. </target>
  30. <target name="run-build">
  31. <ant dir="${installer.build.dir}" inheritAll="false"/>
  32. </target>
  33. <target name="-init-zip">
  34. <condition property="do.build.zip">
  35. <available file="${suite.dist.zip}"/>
  36. </condition>
  37. </target>
  38. <target name="-build-zip" depends="-init-zip" unless="do.build.zip">
  39. <antcall target="-build-zip-ant"/>
  40. <antcall target="-build-zip-maven"/>
  41. </target>
  42. <target name="-build-zip-ant" depends="-init-zip" if="do.load.ant.props">
  43. <subant buildpath="${suite.location}" inheritAll="false" target="build-zip-for-installer"/>
  44. </target>
  45. <target name="-build-zip-maven" depends="-init-zip" if="do.load.maven.props">
  46. <condition property="mvn.executable" value="mvn.bat" else="mvn">
  47. <os family="windows"/>
  48. </condition>
  49. <exec executable="${mvn.executable}" dir="${suite.location}">
  50. <arg value="install"/>
  51. <env key="JAVA_HOME" value="${java.home}"/>
  52. </exec>
  53. </target>
  54. <target name="prepare-zip" depends="-init-zip,-build-zip"/>
  55. <target name="prepare-sources">
  56. <copy todir="${installer.build.dir}">
  57. <fileset dir="${nbi.stub.location}"/>
  58. </copy>
  59. <copy todir="${installer.build.dir}/.common">
  60. <fileset dir="${nbi.stub.common.location}"/>
  61. </copy>
  62. <property name="product.uid" value="${suite.nbi.product.uid}"/>
  63. <!--normen-->
  64. <property name="product.version" value="${suite.nbi.product.version}"/>
  65. <condition property="icon.path" value="${nbi.icon.file}" else="${installer.build.dir}/ext/components/products/helloworld/data/icon48.png">
  66. <and>
  67. <isset property="nbi.icon.file"/>
  68. <available file="${nbi.icon.file}"/>
  69. </and>
  70. </condition>
  71. <basename property="icon.file.name" file="${icon.path}"/>
  72. <condition property="icon.extension" value=".gif">
  73. <or>
  74. <matches string="${icon.file.name}" pattern="^.*\.gif$"/>
  75. <matches string="${icon.file.name}" pattern="^.*\.gif$"/>
  76. </or>
  77. </condition>
  78. <condition property="icon.extension" value=".png">
  79. <or>
  80. <matches string="${icon.file.name}" pattern="^.*\.png$"/>
  81. <matches string="${icon.file.name}" pattern="^.*\.PNG$"/>
  82. </or>
  83. </condition>
  84. <property name="icon.name" value="${suite.props.app.name}${icon.extension}"/>
  85. <copy file="${icon.path}" tofile="${installer.build.dir}/ext/components/products/helloworld/src/org/mycompany/${icon.name}"/>
  86. <replace file="${installer.build.dir}/build.properties" encoding="utf-8">
  87. <replacefilter token="{nbi.ant.tasks.jar}" value="${nbi.ant.tasks.jar}"/>
  88. <replacefilter token="{nbi.registries.management.jar}" value="${nbi.registries.management.jar}"/>
  89. <replacefilter token="{nbi.engine.jar}" value="${nbi.engine.jar}"/>
  90. <replacefilter token="{product-platforms}" value="${generate.installer.for.platforms}"/>
  91. <replacefilter token="{generator-jdk-location-forward-slashes}" value="${generator-jdk-location-forward-slashes}"/>
  92. <replacefilter token="{generated-installers-location-forward-slashes}" value="${suite.dist.directory}"/>
  93. <replacefilter token="{pack200.enabled}" value="${pack200.enabled}"/>
  94. <replacefilter token="{generated-installers-prefix}" value="${installers.file.prefix}"/>
  95. <replacefilter token="{product-uid}" value="${product.uid}"/>
  96. <!--normen-->
  97. <replacefilter token="{product-version}" value="${product.version}"/>
  98. </replace>
  99. <replace dir="${installer.build.dir}/ext" encoding="utf-8">
  100. <replacefilter token="{product-name}" value="${suite.props.app.title}"/>
  101. <replacefilter token="{product-simple-name}" value="${suite.props.app.name}"/>
  102. <replacefilter token="{product-uid}" value="${product.uid}"/>
  103. <replacefilter token="{product-icon-name}" value="${icon.name}"/>
  104. <!--kirill-->
  105. <replacefilter token="{product-description}" value="${product.description}"/>
  106. <replacefilter token="{product-categories}" value="${product.categories}" />
  107. </replace>
  108. <replace dir="${installer.build.dir}/ext/infra/build/products" encoding="utf-8">
  109. <replacefilter token="{product.platforms}" value="${generate.installer.for.platforms}"/>
  110. <replacefilter token="{product-data-path}" value="${suite.dist.zip}"/>
  111. <replacefilter token="{product-data-sub-dir}" value="${suite.props.app.name}"/>
  112. <replacefilter token="{product-uid}" value="${product.uid}"/>
  113. <!--normen-->
  114. <replacefilter token="{product-version}" value="${product.version}"/>
  115. <replacefilter token="{product-install-directory-name}" value="${suite.props.app.name}"/>
  116. <replacefilter token="{product-install-directory-name-windows}" value="${suite.props.app.name}"/>
  117. <replacefilter token="{product-install-directory-name-macosx}" value="${suite.props.app.name}"/>
  118. </replace>
  119. <property name="dir.dir" value="${installer.build.dir}/tmpdirfornac"/>
  120. <mkdir dir="${dir.dir}"/>
  121. <native2ascii encoding="utf-8" src="${installer.build.dir}" dest="${dir.dir}" includes="build.properties ext/**/*.properties"/>
  122. <copy todir="${installer.build.dir}" overwrite="true" includeEmptyDirs="true">
  123. <fileset dir="${dir.dir}"/>
  124. </copy>
  125. <condition property="license.defined">
  126. <and>
  127. <isset property="nbi.license.file"/>
  128. <available file="${nbi.license.file}"/>
  129. </and>
  130. </condition>
  131. <antcall target="-prepare-license"/>
  132. <condition property="icon.defined">
  133. <and>
  134. <isset property="nbi.icon.file"/>
  135. <available file="${nbi.icon.file}"/>
  136. </and>
  137. </condition>
  138. <antcall target="-prepare-icon"/>
  139. <condition property="dock.icon.defined">
  140. <and>
  141. <isset property="nbi.dock.icon.file"/>
  142. <available file="${nbi.dock.icon.file}"/>
  143. </and>
  144. </condition>
  145. <antcall target="-prepare-dock-icon"/>
  146. <delete dir="${dir.dir}" includeEmptyDirs="true"/>
  147. </target>
  148. <target name="-prepare-license" if="license.defined">
  149. <copy file="${nbi.license.file}" tofile="${installer.build.dir}/ext/components/products/helloworld/src/org/mycompany/license.txt" overwrite="true"/>
  150. </target>
  151. <target name="-prepare-icon" if="icon.defined">
  152. <copy file="${nbi.icon.file}" tofile="${installer.build.dir}/ext/engine/src/org/mycompany/installer/wizard/wizard-icon.png" overwrite="true"/>
  153. </target>
  154. <target name="-prepare-dock-icon" if="dock.icon.defined">
  155. <mkdir dir="${installer.build.dir}/ext/engine/src/org/netbeans/installer/utils/system/launchers/impl"/>
  156. <copy file="${nbi.dock.icon.file}" tofile="${installer.build.dir}/ext/engine/src/org/netbeans/installer/utils/system/launchers/impl/dockicon.icns"/>
  157. <copy file="${nbi.dock.icon.file}" tofile="${installer.build.dir}/ext/components/products/helloworld/src/org/mycompany/${suite.props.app.name}.icns"/>
  158. </target>
  159. <target name="replace">
  160. <property file="${token.file}"/>
  161. <replaceregexp file="${file.to.replace}" flags="mg">
  162. <regexp pattern="${regexp.token}"/>
  163. <substitution expression="${regexp.replacement}"/>
  164. </replaceregexp>
  165. </target>
  166. </project>