# $Id: Portfile 68278 2010-05-30 22:35:04Z ryandesign@macports.org $

PortSystem 1.0

name				grails
version				1.3.1
revision			1
categories			devel java
maintainers			breskeby
description			An open-source web application framework that leverages the Groovy language
long_description	Grails aims to bring the "coding by convention" paradigm to Groovy. \
					It's an open-source web application framework that leverages the Groovy \
					language and complements Java Web development. \
					You can use Grails as a standalone development environment that hides all \
					configuration details or integrate your Java business logic. \
					Grails aims to make development as simple as possible and hence \
					should appeal to a wide range of developers not just those from the Java community.
homepage			http://www.grails.org/
platforms			darwin
conflicts			grails-devel
distname			${name}-${version}
master_sites		http://dist.codehaus.org/grails
checksums 			md5 eae157394eeaa704015756a7613eae50 \
					sha1 3dbfc9d38314c6120a953f474b15f9de9702748f \
					rmd160 14fc1b01a26ff4866cb1117b171f62ccb3609057

worksrcdir			${name}-${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/${name}

	# Copy over the needed elements of our directory tree
	file copy ${worksrcpath}/bin     						\
			  ${worksrcpath}/dist 							\
			  ${worksrcpath}/conf 							\
			  ${worksrcpath}/lib 							\
			  ${worksrcpath}/media 							\
			  ${worksrcpath}/plugins						\
			  ${worksrcpath}/scripts						\
			  ${worksrcpath}/src						    \
			  ${worksrcpath}/build.properties 				\
			  ${destroot}${prefix}/share/java/${name}

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

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