blob: 30e3ab60be3f8341e279cf7cdee5b235a8d6996a [file] [log] [blame]
<project name="WebIDE customTargets overrides" >
<property name="super" value="Build specific targets and properties" />
<property name="minifyDirectory" value="${buildDirectory}/built-js" />
<target name="download3rdPartyLibs">
<mkdir dir="${requirejsHome}" />
<get src="http://requirejs.org/docs/release/2.1.6/r.js"
dest="${requirejsHome}/r.js"
usetimestamp="true"
maxtime="30" />
</target>
<target name="updateBuildLabel" if="buildLabel">
<echo message="Updating build label..."/>
<replace dir="${buildDirectory}" includes="pluginVersions.properties,featureVersions.properties" >
<replacefilter token="HEAD" value="${buildLabel}" />
<replacefilter token="origin/mls -alaster" value="${buildLabel}" />
</replace>
<!-- Build Id in Orion page footer -->
<replace dir="${buildDirectory}" includes="**/web/orion/nls/root/messages.js" >
<replacefilter token="@buildLabel@" value="${buildLabel}" />
</replace>
</target>
<macrodef name="optimize" >
<attribute name="name" />
<attribute name="pageDir" default = "." />
<attribute name="bundle" />
<sequential>
<java classname="org.mozilla.javascript.tools.shell.Main" fork="true"
dir="${buildDirectory}/optimization">
<classpath>
<fileset dir="${requirejsHome}/lib/">
<include name="**/*.jar"/>
</fileset>
</classpath>
<jvmarg value="-Xss1024k" />
<!-- JavaScript language version -->
<arg value="-version" />
<arg value="180" />
<arg value="${requirejsHome}/r.js"/>
<arg value="-o" />
<arg value="./orion.build.js"/>
<arg value="optimize=closure" />
<arg value="name=@{pageDir}/@{name}" />
<arg value="out=@{pageDir}/built-@{name}.js"/>
<arg value="dir=" />
</java>
<!-- optimize the page css -->
<java classname="org.mozilla.javascript.tools.shell.Main" fork="true" dir="${buildDirectory}/optimization">
<classpath>
<fileset dir="${requirejsHome}/lib/">
<include name="**/*.jar"/>
</fileset>
</classpath>
<arg value="${requirejsHome}/r.js"/>
<arg value="-o" />
<arg value="./orion.build.js"/>
<arg value="cssIn=@{pageDir}/@{name}.css" />
<arg value="out=@{pageDir}/@{name}.css" />
</java>
<antcall target="updateHTML">
<param name="minifiedScript" value="${buildDirectory}/optimization/@{pageDir}/built-@{name}.js" />
<param name="pageDir" value="@{pageDir}" />
<param name="name" value="@{name}" />
</antcall>
<antcall target="updateJS">
<param name="minifiedScript" value="${buildDirectory}/optimization/@{pageDir}/built-@{name}.js" />
<param name="pageDir" value="@{pageDir}" />
<param name="name" value="@{name}" />
</antcall>
<copy todir="${buildDirectory}/bundles/@{bundle}/web/@{pageDir}" >
<fileset dir="${buildDirectory}/optimization/@{pageDir}" includes="built-@{name}.js, @{name}.html" >
<size when="more" value="0" />
</fileset>
</copy>
</sequential>
</macrodef>
<macrodef name="editorOptimize" >
<attribute name="scriptName" />
<attribute name="fileName" />
<attribute name="optimize" />
<sequential>
<java classname="org.mozilla.javascript.tools.shell.Main" fork="true"
dir="${buildDirectory}/optimization">
<classpath>
<fileset dir="${requirejsHome}/lib/">
<include name="**/*.jar"/>
</fileset>
</classpath>
<!-- JavaScript language version -->
<arg value="-version" />
<arg value="180" />
<arg value="${requirejsHome}/r.js"/>
<arg value="-o" />
<arg value="@{scriptName}"/>
<arg value="optimize=@{optimize}" />
<arg value="out=${minifyDirectory}/@{fileName}"/>
<arg value="dir=" />
</java>
</sequential>
</macrodef>
<target name="updateHTML" >
<condition property="builtResult" value="require([&quot;built-${name}.js&quot;]);" else="require([&quot;${name}.js&quot;]);" >
<length file="${minifiedScript}" when="greater" length="0" />
</condition>
<replace file="${buildDirectory}/optimization/${pageDir}/${name}.html" token="require([&quot;${name}.js&quot;]);" value="${builtResult}" />
<replace file="${buildDirectory}/optimization/${pageDir}/${name}.html" token="require([&apos;${name}.js&apos;]);" value="${builtResult}" />
<replace file="${buildDirectory}/optimization/${pageDir}/${name}.html" token="requirejs/require.js" value="requirejs/require.min.js" />
</target>
<target name="checkBuiltResult">
<condition property="builtResultExists" value="1" >
<length file="${minifiedScript}" when="greater" length="0" />
</condition>
</target>
<!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=404957 -->
<target name="updateJS" depends="checkBuiltResult" if="builtResultExists">
<!-- Omit superfluous prefix "./" if we're dealing with module in the cwd -->
<condition property="moduleName" value="${name}" else="${pageDir}/${name}">
<equals arg1="${pageDir}" arg2="." />
</condition>
<property name="builtModuleName" value="built-${name}.js" />
<replace file="${minifiedScript}" value="define(&apos;${builtModuleName}&apos;">
<replacefilter token="define(&quot;${moduleName}&quot;" />
<replacefilter token="define(&apos;${moduleName}&apos;" />
</replace>
</target>
<target name="requirejs" if="minify">
<echo message="Minification started..."/>
<delete dir="${buildDirectory}/optimization" />
<delete dir="${minifyDirectory}" />
<mkdir dir="${minifyDirectory}" />
<copy file="${builder}/scripts/orion.build.js" tofile="${buildDirectory}/optimization/orion.build.js" overwrite="true"/>
<copy file="${builder}/scripts/editor.build-js.js" tofile="${buildDirectory}/optimization/editor.build-js.js" overwrite="true"/>
<copy file="${builder}/scripts/editor.build.almond-js.js" tofile="${buildDirectory}/optimization/editor.build.almond-js.js" overwrite="true"/>
<copy file="${builder}/scripts/editor.build-css.js" tofile="${buildDirectory}/optimization/editor.build-css.js" overwrite="true"/>
<!-- Stage files for optimization -->
<copy todir="${buildDirectory}/optimization" >
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.core/web" includes="**"/>
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.ui/web" includes="**"/>
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.editor/web" includes="**"/>
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.git/web" includes="**"/>
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.users/web" includes="**"/>
</copy>
<!-- build standalone editor -->
<editorOptimize filename="built-editor.css" scriptname="editor.build-css.js" optimize="closure"/>
<editorOptimize filename="built-editor-amd.min.js" scriptname="editor.build-js.js" optimize="closure"/>
<editorOptimize filename="built-editor-amd.js" scriptname="editor.build-js.js" optimize="none"/>
<editorOptimize filename="built-editor.min.js" scriptname="editor.build.almond-js.js" optimize="closure"/>
<editorOptimize filename="built-editor.js" scriptname="editor.build.almond-js.js" optimize="none"/>
<!-- build orion pages and plugins -->
<optimize pageDir="." name="index" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="navigate" name="table" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="edit" name="edit" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="compare" name="compare" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="operations" name="list" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="search" name="search" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="settings" name="settings" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="shell" name="shellPage" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="plugins/site" name="sitePlugin" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="plugins" name="authenticationPlugin" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="plugins" name="fileClientPlugin" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="plugins" name="jslintPlugin" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="plugins" name="preferencesPlugin" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="plugins" name="taskPlugin" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="sites" name="site" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="sites" name="sites" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="sites" name="view" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="mixloginstatic" name="LoginWindow" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="mixloginstatic" name="manageOpenids" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="git/plugins" name="gitPlugin" bundle="org.eclipse.orion.client.git" />
<optimize pageDir="git" name="git-log" bundle="org.eclipse.orion.client.git" />
<optimize pageDir="git" name="git-status2" bundle="org.eclipse.orion.client.git" />
<optimize pageDir="git" name="git-repository" bundle="org.eclipse.orion.client.git" />
<optimize pageDir="git" name="git-commit" bundle="org.eclipse.orion.client.git" />
<optimize pageDir="profile" name="user-list" bundle="org.eclipse.orion.client.users" />
<optimize pageDir="profile" name="userservicePlugin" bundle="org.eclipse.orion.client.users" />
<!-- copy css back -->
<copy todir="${buildDirectory}/bundles/org.eclipse.orion.client.ui/web" >
<fileset dir="${buildDirectory}/optimization" includes="**/*.css" excludes="git/,profile/"/>
</copy>
<copy todir="${buildDirectory}/bundles/org.eclipse.orion.client.git/web" >
<fileset dir="${buildDirectory}/optimization" includes="git/**/*.css" />
</copy>
<copy todir="${buildDirectory}/bundles/org.eclipse.orion.client.users/web" >
<fileset dir="${buildDirectory}/optimization" includes="profile/**/*.css" />
</copy>
</target>
</project>