blob: 5b50bcd303d5ec3f2df2a05412966d012eb3e70a [file] [log] [blame]
<!--
******************************************************************************
* Copyright (c) 2016 Oracle
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Konstantin Komissarchik - initial implementation and ongoing maintenance
******************************************************************************
-->
<project name="corundum.macro.install-eclipse">
<macrodef name="install-eclipse">
<attribute name="dest"/>
<attribute name="configuration" default="${configuration.recommended}"/>
<attribute name="extensions" default=""/>
<attribute name="standalone" default="false"/>
<attribute name="os" default="${p2.os}"/>
<attribute name="ws" default="${p2.ws}"/>
<attribute name="arch" default="${p2.arch}"/>
<sequential>
<!-- Delete the destination folder -->
<delete dir="@{dest}" quiet="true"/>
<!-- Remove profiles associated with the destination folder from the profile registry in the shared bundle pool -->
<if>
<isfalse value="@{standalone}"/>
<then>
<normalize-path property=".normalized.dest.path" path="@{dest}"/>
<if>
<available file="${bundle.pool}/p2/org.eclipse.equinox.p2.engine/profileRegistry" type="dir"/>
<then>
<for param="profile.folder">
<path>
<dirset dir="${bundle.pool}/p2/org.eclipse.equinox.p2.engine/profileRegistry" includes="*.profile"/>
</path>
<sequential>
<if>
<available file="@{profile.folder}/.owner"/>
<then>
<loadfile property=".owner" srcFile="@{profile.folder}/.owner"/>
<if>
<equals arg1="${.owner}" arg2="${.normalized.dest.path}"/>
<then>
<delete dir="@{profile.folder}"/>
</then>
</if>
<var name=".owner" unset="true"/>
</then>
</if>
</sequential>
</for>
</then>
</if>
</then>
</if>
<!-- Install eclipse by using p2 director -->
<var name=".extensions" value="org.eclipse.platform,org.eclipse.platform.ide"/>
<append property=".extensions" value="@{extensions}"/>
<with-configuration name="@{configuration}">
<if>
<and>
<equals arg1="@{os}" arg2="macosx"/>
<isfalse value="${.legacy.mac.layout}"/>
</and>
<then>
<var name=".p2.director.dest" value="@{dest}/Eclipse.app/Contents/Eclipse"/>
</then>
<else>
<var name=".p2.director.dest" value="@{dest}"/>
</else>
</if>
<if>
<isset property="build.repositories"/>
<then>
<append property=".repositories" value="${build.repositories}"/>
</then>
</if>
<if>
<istrue value="@{standalone}"/>
<then>
<java classname="org.eclipse.core.launcher.Main" fork="true" failonerror="true">
<classpath>
<fileset dir="${p2}/plugins">
<include name="**/org.eclipse.equinox.launcher_*.jar"/>
</fileset>
</classpath>
<arg line="-application org.eclipse.equinox.p2.director"/>
<arg line="-repository ${.repositories}"/>
<arg line="-destination ${.p2.director.dest}"/>
<arg line="-profile SDKProfile"/>
<arg line="-profileProperties org.eclipse.update.install.features=true"/>
<arg line="-roaming"/>
<arg line="-installIU ${.extensions}"/>
<arg line="-p2.os @{os}"/>
<arg line="-p2.ws @{ws}"/>
<arg line="-p2.arch @{arch}"/>
<jvmarg line="-Xmx512m"/>
</java>
</then>
<else>
<tstamp>
<format property=".profile" pattern="yyyy-MM-dd_HH.mm.ss.SSS"/>
</tstamp>
<java classname="org.eclipse.core.launcher.Main" fork="true" failonerror="true">
<classpath>
<fileset dir="${p2}/plugins">
<include name="**/org.eclipse.equinox.launcher_*.jar"/>
</fileset>
</classpath>
<arg line="-application org.eclipse.equinox.p2.director"/>
<arg line="-repository ${.repositories}"/>
<arg line="-destination ${.p2.director.dest}"/>
<arg line="-bundlepool ${bundle.pool}"/>
<arg line="-shared ${bundle.pool}/p2"/>
<arg line="-profile ${.profile}"/>
<arg line="-profileProperties org.eclipse.update.install.features=true"/>
<arg line="-installIU ${.extensions}"/>
<arg line="-p2.os @{os}"/>
<arg line="-p2.ws @{ws}"/>
<arg line="-p2.arch @{arch}"/>
<jvmarg line="-Xmx512m"/>
</java>
<echo message="${.normalized.dest.path}" file="${bundle.pool}/p2/org.eclipse.equinox.p2.engine/profileRegistry/${.profile}.profile/.owner"/>
<var name=".profile" unset="true"/>
</else>
</if>
</with-configuration>
<var name=".p2.director.dest" unset="true"/>
<var name=".extensions" unset="true"/>
<var name=".normalized.dest.path" unset="true"/>
<!-- Run p2 garbage collector so that unreferenced bundles are removed from the shared bundle pool -->
<if>
<isfalse value="@{standalone}"/>
<then>
<eclipse location="${builder}" application="org.eclipse.equinox.p2.garbagecollector.application"/>
</then>
</if>
<!-- Update eclipse.ini -->
<if>
<available file="@{dest}/eclipse.ini"/>
<then>
<var name=".eclipse.ini" value="@{dest}/eclipse.ini"/>
</then>
<elseif>
<available file="@{dest}/Eclipse.app/Contents/Eclipse/eclipse.ini"/>
<then>
<var name=".eclipse.ini" value="@{dest}/Eclipse.app/Contents/Eclipse/eclipse.ini"/>
</then>
</elseif>
<elseif>
<available file="@{dest}/eclipse.app/Contents/MacOS/eclipse.ini"/>
<then>
<var name=".eclipse.ini" value="@{dest}/eclipse.app/Contents/MacOS/eclipse.ini"/>
</then>
</elseif>
<else>
<fail message="Could not locate eclipse.ini file in @{dest}"/>
</else>
</if>
<if>
<contains string="${p2.arch}" substring="x86_64"/>
<then>
<replaceregexp file="${.eclipse.ini}" match="-Xmx[0-9]*m" replace="-Xmx1024m"/>
</then>
<else>
<replaceregexp file="${.eclipse.ini}" match="-Xmx[0-9]*m" replace="-Xmx512m"/>
</else>
</if>
<var name=".eclipse.ini" unset="true"/>
<!-- Update config.ini to ensure that the splash screen will show -->
<!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=274127 -->
<if>
<isfalse value="@{standalone}"/>
<then>
<if>
<available file="@{dest}/Eclipse.app/Contents/Eclipse/configuration" type="dir"/>
<then>
<var name=".eclipse.configuration" value="@{dest}/Eclipse.app/Contents/Eclipse/configuration"/>
</then>
<else>
<var name=".eclipse.configuration" value="@{dest}/configuration"/>
</else>
</if>
<find-eclipse-bundle property=".platform.bundle" eclipse="@{dest}" bundle="org.eclipse.platform"/>
<makeurl property=".platform.bundle.url" file="${.platform.bundle}"/>
<propertyfile file="${.eclipse.configuration}/config.ini">
<entry key="osgi.splashPath" value="${.platform.bundle.url}"/>
</propertyfile>
<var name=".eclipse.configuration" unset="true"/>
<var name=".platform.bundle" unset="true"/>
<var name=".platform.bundle.url" unset="true"/>
</then>
</if>
</sequential>
</macrodef>
</project>