Ports@

I have taken a stab at a diff that will allow us to integrate Maven
based ports into the build process.  As you may know, Maven downloads
dependencies at build time which the good security in our build
process does not allow, as network access is only on when we are
downloading the source.

This patch to /usr/ports/devel/jdk/java.port.mk follows in the same
model as the apache-ant build support that previously existed.  I have
included a tarball of my snakeyaml proposed port to demonstrate how
the patch works.

I would appreciate your feedback on this as it is the first time I
have offered a patch to the ports infrastructure.

Patch follows:

Index: java.port.mk
===================================================================
RCS file: /home/cvs/ports/devel/jdk/java.port.mk,v
retrieving revision 1.34
diff -u -p -r1.34 java.port.mk
--- java.port.mk        17 Jun 2015 17:16:04 -0000      1.34
+++ java.port.mk        5 Apr 2016 00:50:17 -0000
@@ -110,6 +110,42 @@ do-build:
 .   endif
 .endif

+# Allow ports that use devel/maven to set MODJAVA_BUILD=maven
+# Since maven downloads dependencies at build-time (which is not allowed
+# in our production builds because we turn on networking support only
+# for the fetch phase of the  build), maven's offline repository support
+# is used and the port maintainer is expected to supply an archive that
+# holds the complete set of dependencies needed to build the port.
+.if defined(MODJAVA_BUILD) && ${MODJAVA_BUILD:L} == "maven"
+BUILD_DEPENDS += devel/maven
+    MODJAVA_BUILD_DEP_SITE ?=
+    MODJAVA_BUILD_TARGET_NAME ?= package
+    MODJAVA_BUILD_FILE ?= pom.xml
+    MODJAVA_BUILD_DIR ?= ${WRKSRC}
+    MODJAVA_BUILD_ARGS ?=
+    MODJAVA_BUILD_DEP_DIR ?= ${WRKDIR}
+    MODJAVA_BUILD_DEP_SUB ?= local-repo
+    MODJAVA_BUILD_DEP_PKG ?= maven-dependencies.tgz
+    MODJAVA_BUILD_DEP_UNPACK ?= tar
+    MODJAVA_BUILD_DEP_UNPACK_ARGS ?= xzf
+
+MODJAVA_BUILD_UNPACK_DEPS = \
+       cd ${MODJAVA_BUILD_DEP_DIR} && \
+           ${SETENV} ${MODJAVA_BUILD_DEP_UNPACK}
${MODJAVA_BUILD_DEP_UNPACK_ARGS} ${MODJAVA_BUILD_DEP_PKG}
+
+MODJAVA_BUILD_TARGET = \
+       cd ${MODJAVA_BUILD_DIR} && \
+           ${SETENV} ${MAKE_ENV} ${LOCALBASE}/bin/mvn \
+           -f ${MODJAVA_BUILD_FILE} \
+           
-Dmaven.repo.local="${MODJAVA_BUILD_DEP_DIR}/${MODJAVA_BUILD_DEP_SUB}"
\
+           -o ${MODJAVA_BUILD_ARGS} ${MODJAVA_BUILD_TARGET_NAME}
+.      if !target(do-build)
+do-build:
+       ${MODJAVA_BUILD_UNPACK_DEPS}
+       ${MODJAVA_BUILD_TARGET}
+.      endif
+.endif
+
 # Convenience variables.
 # Ports that install .jar files for public use (ie, in ${MODJAVA_JAR_DIR})
 # please install unversioned .jar files. If a port installs

Thanks,
Bryan

Attachment: snakeyaml.tgz
Description: GNU Zip compressed data

Reply via email to