# $Id$

PortSystem      1.0
PortGroup	github 1.0

github.setup    google protobuf 3.0.0 v
name            protobuf3-java
categories      devel
maintainers     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       sha1   bbb5bbed9e0fde6dc72a0d55e359ad81030420a8 \
                sha256 411eb52ee294386cf04e0fcc5a68a93280c90d90908915f0ce2a28a695d42702

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}