# $Id: Portfile 54084 2009-07-20 17:28:02Z breskeby@macports.org $

PortSystem 1.0

name				gradle
version				0.7
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			${name}-${version}-src
master_sites		http://dist.codehaus.org/gradle
checksums 			md5	a62518443bfc11ebea85b750e883cef8 \
					sha1 938bc77db8c1167c44925ec3a914b9657bc05296 \
					rmd160 602d1b0611a6e8871af727cff040371eff28916a
						
worksrcdir			${name}-${version}
set workTarget		""

use_zip				yes
use_configure 		no

build.cmd			./gradlew
build.target		clean explodedDistBase -Dskip.test

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}/build/distributions/exploded/bin *.bat] {
		file delete $f
	}
}

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

	# Copy over the needed elements of our directory tree
	file copy ${worksrcpath}/build/distributions/exploded/bin					\
			  ${worksrcpath}/build/distributions/exploded/lib 					\
			  ${worksrcpath}/build/distributions/exploded/gradle-imports 		\
			  ${worksrcpath}/build/distributions/exploded/LICENSE		 		\
			  ${worksrcpath}/build/distributions/exploded/NOTICE		 		\
			  ${worksrcpath}/build/distributions/exploded/plugin.properties 	\
			  ${destroot}${prefix}/share/java/${name}

	# Symlink gradle into the bin directory
	system "cd ${destroot}${prefix}/bin && ln -s ${prefix}/share/java/${name}/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/${name}"
 	        ui_msg "****************************************************************************"
 }
