# Maintainer: Shanto <[email protected]>
# Contributor: Shanto <[email protected]>

pkgname=eclipse-aptana
pkgver=3.1.3
_pkgdate=201205292222
_pkgtag=7E7E787ICGPCYKWML6RQRHBZmz0R
pkgrel=1
pkgdesc="Aptana Studio plugin for Eclipse (HTML5/CSS3/JavaScript/Ruby/Rails/PHP/Pydev/Django)"
url="http://www.aptana.com/products/studio3"
arch=('any')
license=('EPL')
depends=('eclipse' 'libjpeg6-turbo' 'libpng12')
makedepends=('unzip')
conflicts=('eclipse-pydev')
provides=('eclipse-pydev')
# find current download link at:
# http://download.aptana.com/studio3/plugin/update/index.html
source=(http://d1iwq2e2xrohf.cloudfront.net/tools/studio/plugin/update/studio3/${pkgver}.${_pkgdate}/com.aptana.feature.studio-${pkgver}.${_pkgdate}-${_pkgtag}.zip)
md5sums=('a4eff3a9fbad185cf8c8eb85ba47725e')
options=('!strip')

build() {
_dest=${pkgdir}/usr/share/eclipse/dropins/${pkgname/eclipse-}/eclipse

cd ${srcdir}

# Cleanup
find plugins/*.{win32,macosx}.* -delete

# Features
find features -type f | while read _feature ; do
if [[ ${_feature} =~ (.*\.jar$) ]] ; then
install -dm755 ${_dest}/${_feature%*.jar}
cd ${_dest}/${_feature/.jar}
jar xf ${srcdir}/${_feature}
else
install -Dm644 ${srcdir}/${_feature} ${_dest}/${_feature}
fi
done

# Plugins
#_extract_jar={com.aptana.{git,*libraries,parsing,terminal,swt.webkit}*,{com,org}.python.pydev*}
_keep_as_jar="(.+/com\.aptana\.scripting_.+)"
find plugins -type f | while read _plugin ; do
if [[ ${_plugin} =~ (.*\.jar$) && ! ${_plugin} =~ $_keep_as_jar ]] ; then
install -dm755 ${_dest}/${_plugin%*.jar}
cd ${_dest}/${_plugin/.jar}
jar xf ${srcdir}/${_plugin}
else
install -Dm644 ${srcdir}/${_plugin} ${_dest}/${_plugin}
fi
done

find $_dest/plugins -name 'redtty' -exec chmod 0755 {} \;
}