PortSystem      1.0
PortGroup	github 1.0

github.setup    google protobuf 3.4.0 v
name            protobuf3-java
revision        1
categories      devel
maintainers     {blair @blair}
license         BSD
description     Encode data in an efficient yet extensible format.
conflicts       protobuf-java

long_description \
                Google Protocol Buffers are a flexible, efficient, \
                automated mechanism for serializing structured data -- \
                think XML, but smaller, faster, and simpler.  You \
                define how you want your data to be structured once, \
                then you can use special generated source code to \
                easily write and read your structured data to and from \
                a variety of data streams and using a variety of \
                languages.  You can even update your data structure \
                without breaking deployed programs that are compiled \
                against the "old" format.  You specify how you want \
                the information you're serializing to be structured by \
                defining protocol buffer message types in .proto \
                files.  Each protocol buffer message is a small \
                logical record of information, containing a series of \
                name-value pairs.

github.tarball_from releases
distname        protobuf-java-${version}
worksrcdir      protobuf-${version}/java

checksums       rmd160  8855fef36d1df4c796e0ea23805664a2eda9b3e8 \
                sha256  7c61081cc2346542070cd35db7d15c7f24aeeefcd3afac08ec88fec03c45d698

platforms       darwin

depends_lib     port:zlib port:protobuf3-cpp
depends_build   port:maven3

patch {
    reinplace "s#\$\{protobuf.source.dir\}/protoc#${prefix}/bin/protoc#g" ${worksrcpath}/pom.xml
}

use_configure   no

build.cmd       mvn3
build.target    install javadoc:javadoc -DskipTests
build.env       MAVEN_OPTS=-Duser.home=${workpath}/.home

destroot {
    set javadir ${destroot}${prefix}/share/java
    set docdir ${destroot}${prefix}/share/doc/${name}

    xinstall -d -m 755 ${javadir}
    xinstall -d -m 755 ${docdir}
    xinstall -d -m 755 ${docdir}/core
    xinstall -d -m 755 ${docdir}/util

    file copy ${worksrcpath}/core/target/protobuf-java-${version}.jar ${javadir}/protobuf.jar
    file copy ${worksrcpath}/util/target/protobuf-java-util-${version}.jar ${javadir}/protobuf-util.jar

    file copy ${worksrcpath}/README.md ${docdir}/README-java.md
    foreach f {CHANGES.txt CONTRIBUTORS.txt LICENSE README.md} {
        file copy ${worksrcpath}/../${f} ${docdir}
    }
    file copy ${worksrcpath}/core/target/site/apidocs ${docdir}/core/api
    file copy ${worksrcpath}/util/target/site/apidocs ${docdir}/util/api
}

test.run    yes
test.cmd    mvn3
test.target test
test.env    ${build.env}