# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 84550 2011-09-27 21:05:11Z snc@macports.org $

PortSystem 1.0

name                maven1
version             1.1

categories          java devel
maintainers         yahoo.com:jendave
platforms           darwin

description         A java-based build and project management environment.
long_description    Maven is a Java project management and project comprehension \
                    tool. Maven is based on the concept of a project object model (POM) \
                    in that all the artifacts produced by Maven are a result of consulting \
                    a well defined model for your project. Builds, documentation, source \
                    metrics, and source  cross-references are all controlled by your POM.

homepage            http://maven.apache.org/

master_sites        apache:maven/binaries
distname            maven-${version}
checksums           md5    ec2b0ad8c78ba52497f63ee7f613b526 \
                    sha1   d9174675f0e846a225278949869fa2d979fa7f3b \
                    rmd160 82ef869218ac42d9132fc74316f0e8a5edcf9431

depends_build       bin:java:kaffe \
                    bin:ant:apache-ant

use_configure       no

# Source builds of maven are not possible. So, the default build is a binary
# install of the jars.
build.cmd           true

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

    # Copy over the needed elements of our directory tree
    file copy \
        ${worksrcpath}/bin \
        ${worksrcpath}/lib \
        ${worksrcpath}/plugins \
        ${worksrcpath}/maven-project-3.xsd \
        ${mavendir}

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

    # Fix permissions on shell scripts
    foreach f { maven install_repo.sh } {
        if [file exists ${mavendir}/bin/$f] {
            file attributes ${mavendir}/bin/$f -permissions +x
        }
    }

    # Reduce the permissions on the distribution files.
    foreach f [glob -directory ${mavendir}/lib *.jar] {
        file attributes $f -permissions 0644
    }

    # Symlink maven executable to mvn in maven1 directory
    system "cd ${mavendir}/bin && ln -s maven mvn"

    # Symlink maven into the bin directory
    system "cd ${destroot}${prefix}/bin && ln -s ../share/java/${name}/bin/mvn mvn1"
}

livecheck.type  regex
livecheck.regex {Get Maven (\d+(?:\.\d+)*)}
