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

name                flyway
version             7.3.1

categories          java devel
license             Apache-2
maintainers         {emcrisostomo @emcrisostomo} openmaintainer
platforms           darwin
supported_archs     noarch

description         Database Migrations Made Easy.
long_description    Flyway is an open-source database migration tool. \
                    It strongly favors simplicity and convention over \
                    configuration.

homepage            https://flywaydb.org/

master_sites        https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/${version}/
distname            ${name}-commandline-${version}
worksrcdir          ${name}-${version}

checksums           rmd160  779592509d181744fd3323a70dcc4a6840919756 \
                    sha256  888fd493fe6d97df5ef91efeb7f670492a52c623851e35b9d9bc5129086d31e3 \
                    size    53866315

java.version        1.8+
java.fallback       openjdk11

use_configure       no

# The default build is a binary install of the jars.
build {}

destroot {
    set flywaydir ${destroot}${prefix}/share/java/${name}

    # Create the target directory if it does not exist
    xinstall -m 755 -d ${flywaydir}

    # Copy over the needed elements of our directory tree
    foreach f [glob -dir ${worksrcpath} *] {
        file copy $f ${flywaydir}
    }

    file attributes ${flywaydir}/flyway -permissions 0755

    # Symlink flyway into the bin directory
    ln -s ../share/java/${name}/flyway ${destroot}${prefix}/bin/flyway
}

livecheck.type      regex
livecheck.url       https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/maven-metadata.xml
livecheck.regex     >(\\d+\\.\\d+(\\.\\d+)*)</
