# $Id: Portfile,v 1.5 2005/10/26 18:18:21 jberry Exp $

PortSystem 1.0

name           		struts
version         	1.2.7

categories      	java
maintainers     	jberry@opendarwin.org
platforms       	darwin

description     	Apache Struts Framework.
long_description	Struts is a framework for writing Java web applications, \
					based on the model-view-controller paradigm.
homepage			http://struts.apache.org/

distname			${name}-${version}-src
master_sites    	apache:struts/source/
checksums       	md5 c6665758e2a3345d307a9b975b030543

depends_build		bin:ant:apache-ant
depends_lib			bin:java:kaffe \
					port:commons-beanutils \
					port:commons-collections \
					port:commons-digester \
					port:commons-fileupload \
					port:commons-lang \
					port:commons-logging \
					port:commons-validator \
					port:jakarta-oro \
					port:servlet23-api \
					port:antlr \
					port:jakarta-taglibs-standard-11

use_configure		no

set javaLibs		${prefix}/share/java

post-extract {
	file mkdir \
		${worksrcpath}/contrib \
		${worksrcpath}/lib
}

build {
	# Build Struts
	system "cd ${worksrcpath} && \
		CLASSPATH=${javaLibs}/commons-digester-rss.jar \
		ant dist \
			-Dcommons-beanutils.jar=${javaLibs}/commons-beanutils.jar \
			-Dcommons-collections.jar=${javaLibs}/commons-collections.jar \
			-Dcommons-digester.jar=${javaLibs}/commons-digester.jar \
			-Dcommons-fileupload.jar=${javaLibs}/commons-fileupload.jar \
			-Dcommons-lang.jar=${javaLibs}/commons-lang.jar \
			-Dcommons-logging.jar=${javaLibs}/commons-logging.jar \
			-Dcommons-validator.jar=${javaLibs}/commons-validator.jar \
			-Djakarta-oro.jar=${javaLibs}/jakarta-oro.jar \
			-Dservlet.jar=${javaLibs}/servlet23-api.jar \
			-Dantlr.jar=${javaLibs}/antlr.jar \
			"

	# Extract tld files from standard.jar, needed by struts-el
	set tld_dir ${workpath}/tld
	file mkdir ${tld_dir}
	system "cd ${tld_dir} && jar xf ${javaLibs}/standard.jar META-INF"
	
	# Build Struts-EL
	system "cd ${worksrcpath}/contrib/struts-el && \
		ant dist \
			-Dservlet.jar=${javaLibs}/servlet23-api.jar \
			-Djstl.tld.dir=${tld_dir}/META-INF \
			-Djstl.jar=${javaLibs}/jstl.jar \
			-Djstl-standard.jar=${javaLibs}/standard.jar \
			-Dcommons-beanutils.jar=${javaLibs}/commons-beanutils.jar \
			"
}

destroot {
	xinstall -m 755 -d ${destroot}${prefix}/share/java
	file copy ${worksrcpath}/dist \
		${destroot}${prefix}/share/java/${name}
	xinstall -m 755 -d ${destroot}${prefix}/share/java/${name}/contrib
	file copy ${worksrcpath}/contrib/struts-el/dist \
		${destroot}${prefix}/share/java/${name}/contrib/struts-el
}
