# -*- 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

PortSystem 1.0
PortGroup select 1.0
PortGroup java 1.0
PortGroup deprecated 1.0

# Maven 2.x is end-of-life, see https://maven.apache.org/maven-2.x-eol.html
# Last release was in 2009
deprecated.upstream_support no


name            maven2
version         2.2.1
revision        4

categories      java devel
license         Apache-2
maintainers     nomaintainer
platforms       any
supported_archs noarch

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.  Maven 2.0 is a complete rewrite of \
                Maven 1.0 and as such is better organized, faster \
                and easier to use.

homepage        https://maven.apache.org/

master_sites    apache:maven/binaries
distname        apache-maven-${version}-bin
worksrcdir      apache-maven-${version}
use_bzip2       yes
checksums       md5    c581a15cb0001d9b771ad6df7c8156f8 \
                sha1   47ac0417a200cbc6d1b967d6b7c6ae1138e9e3e0 \
                rmd160 25d523d3dc86cf4695b0e343cf0f6e58ea8a54e3

java.version    1.5+
java.fallback   openjdk11

depends_run     port:maven_select

use_configure   no

select.group    maven
select.file     ${filespath}/${name}

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

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}/boot \
        ${worksrcpath}/conf \
        ${worksrcpath}/lib \
        ${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.
    file attributes ${mavendir}/conf -permissions 0755
    file attributes ${mavendir}/conf/settings.xml -permissions 0644
    foreach f [glob -directory ${mavendir}/lib *.jar] {
        file attributes $f -permissions 0644
    }

    # Symlink maven into the bin directory
    ln -s ../share/java/${name}/bin/mvn ${destroot}${prefix}/bin/mvn2
    ln -s ../share/java/${name}/bin/mvnDebug ${destroot}${prefix}/bin/mvnDebug2
}

notes \
"To make maven $version the default, please run
\tsudo port select --set ${select.group} $name"

livecheck.type  none
