# Maintainer: not me :)
# Contributor: Lukas Jirkovsky <l.jirkovsky@gmail.com>


pkgname=intellij-idea-community-edition
pkgver=2018.1.4
_pkgver=181.5087.20
pkgrel=1.parabola1
epoch=2
pkgdesc="IDE for Java, Groovy and other programming languages with advanced refactoring features"
arch=('any')
url="https://www.jetbrains.com/idea/"
license=('Apache')
backup=('usr/share/intellijidea-ce/bin/idea.vmoptions'
        'usr/share/intellijidea-ce/bin/idea64.vmoptions')
depends=('java-environment=8' 'giflib' 'libxtst' 'libxft' 'ttf-font'
         'coreutils' 'grep' 'which')
conflicts=('intellij-idea-libs')
replaces=('intellij-idea-libs')
install=idea.install
source=(https://github.com/JetBrains/intellij-community/archive/idea/${_pkgver%.*}.tar.gz
        idea.desktop
        idea.sh)
sha256sums=('fa31113e3676e8d036e35e287f9c55f3b1c50413898a8e61f84e605c3808e5cc'
            'bd37ad47c926941108f624cbe5adbd7fe91d198b15aca63d8a0c0da14c7a76a6'
            '0e5d6a47b5ae464e9f562110ccc798f55055943e425e0621c0275f72615fdb1d')


build()
{
  cd "intellij-community-idea-${_pkgver%.*}"

  ant
}


package()
{
# TODO:
# as is, this fails to build so this function has not been reached yet
# so this function may need some tweaking
# it is from the arch package that did not have a build() function
# but merely packaged downloaded binaries

  install -d -m755 "$pkgdir/"usr/share
  cp -a "idea-IC-$_pkgver" "$pkgdir"/usr/share/intellijidea-ce

  # make sure that all files are owned by root
  chown -R root:root "$pkgdir/usr/share"

  install -d -m755 "$pkgdir"/usr/bin
  install -D -m755 "$srcdir"/idea.sh "$pkgdir"/usr/bin/idea.sh
  install -D -m644 "$srcdir"/idea.desktop "$pkgdir"/usr/share/applications/idea.desktop
  install -D -m644 "$pkgdir"/usr/share/intellijidea-ce/bin/idea.png \
                   "$pkgdir"/usr/share/pixmaps/idea.png

  # workaround FS#40934
  sed -i 's|lcd|on|'  "$pkgdir"/usr/share/intellijidea-ce/bin/*.vmoptions
}
