# $Id: Portfile 107438 2013-06-29 10:26:11Z breskeby@macports.org $

PortSystem 1.0

name            groovy
version         2.1.5
revision        0
categories      java lang
maintainers     breskeby
platforms       darwin
description     Groovy -- a Java-based scripting language
long_description Groovy is a new agile dynamic language for the JVM combining \
                lots of great features from languages like Python, Ruby and \
                Smalltalk and making them available to Java developers \
                using a Java-like syntax. \
                \
                Groovy is designed to help you get things done on the Java \
                platform in a quicker, more concise and fun way - bringing \
                the power of Python and Ruby inside the Java platform. \
                \
                Groovy can be used as an alternative compiler to javac to \
                generate standard Java bytecode to be used by any Java project \
                or it can be used dynamically as an alternative language such \
                as for scripting Java objects, templating or writing unit test cases.
homepage        http://groovy.codehaus.org/
distname        groovy-src-${version}
master_sites    http://dist.codehaus.org/groovy/distributions/
license	        ASL-2
conflicts		groovy-devel
extract.suffix     .zip
extract.cmd        unzip
extract.pre_args   "-o -q"
extract.post_args  "-d ${workpath}"

checksums		md5     5ac0a2fd30449812163706f7732ef831 \
                sha1    48e21b53225ccae757492a384f7c947526b6e07e \
                rmd160  358fa71de7d67475d9ccb4dedd701d2f1f22e809
use_configure   no
worksrcdir      groovy-${version}
build.cmd		GRADLE_USER_HOME=${workpath} ./gradlew
build.args      -g ${workpath}
build.target	installGroovy
supported_archs noarch
destroot {
    set target ${destroot}${prefix}/share/java/groovy

    # Create the target java directory
    xinstall -m 755 -d ${destroot}${prefix}/share/java
	
    # Copy in our directory tree
    file copy ${worksrcpath}/target/install ${target}
		
    # Remove .bat files
    foreach f [glob -directory ${target}/bin *.bat] { file delete $f }
    # Fix permissions on the scripts,
    # and at the same time add symlinks to them
    foreach f { grape groovy groovyc groovyConsole groovysh java2groovy startGroovy } {
        file attributes ${target}/bin/${f} -permissions +x
        system "cd ${destroot}${prefix}/bin && ln -s ../share/java/groovy/bin/${f}"
    }
}
