# $Id: Portfile 78186 2011-04-27 18:41:12Z breskeby@macports.org $

PortSystem 1.0

name				gradle-devel
version				1.0-milestone-3
categories			devel java groovy
maintainers			breskeby
description			An open-source build system that is based on the Groovy language
long_description	Gradle is a build system which offers you ease, power and freedom. \
					You can choose the balance for yourself. It has powerful multi-project build \
					support. It has a layer on top of Ivy that provides a build-by-convention \
					integration for Ivy. It gives you always the choice between the flexibility \
					of Ant and the convenience of a build-by-convention behavior.
					
homepage			http://www.gradle.org/
platforms			darwin
distname			gradle-${version}-bin
conflicts			gradle
master_sites		http://gradle.artifactoryonline.com/gradle/distributions/
checksums 			md5	1ee94c89a4f6d03c36c662d9991d8c1b \
					sha1 9ca9036e8e6346090b9bac6bd133662841e42869 \
					rmd160 ff774fa4ed2dcff2f8e9600428942c4e5b57dbbe
						
worksrcdir			gradle-${version}
set workTarget		""

use_zip				yes
use_configure 		no

build.cmd			true

platform darwin {
    extract.post_args	| gnutar -x
    build.env		JAVA_HOME=/Library/Java/Home
}

pre-destroot {
	# Remove extraneous bat files
	foreach f [glob -directory ${worksrcpath}${workTarget}/bin *.bat] {
		file delete $f
	}
}

destroot	{
	# Create the target java directory
	xinstall -m 755 -d ${destroot}${prefix}/share/java/gradle

	# Copy over the needed elements of our directory tree
	file copy ${worksrcpath}/bin					\
			  ${worksrcpath}/lib 					\
			  ${worksrcpath}/LICENSE		 		\
			  ${worksrcpath}/NOTICE		 		\
			  ${destroot}${prefix}/share/java/gradle

	# Symlink gradle into the bin directory
	system "cd ${destroot}${prefix}/bin && ln -s ${prefix}/share/java/gradle/bin/gradle"
}

post-activate {
 	        ui_msg "****************************************************************************"
 	        ui_msg "* Remember to set the environment variable GRADLE_HOME to the path to"
 	        ui_msg "* the gradle distribution: ${prefix}/share/java/gradle"
 	        ui_msg "****************************************************************************"
 }
