From c983405b9f18cce28d6301124a5426e53adc63b2 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Wed, 10 Feb 2010 14:37:36 +0100 Subject: [PATCH] Build system: Put Java class files into a .jar file. Hi, I was wondering why the java plugin api class files are published under share/collectd/java. Ideally, a java-plugin.jar file containing all the class files should get published rather than the individual class files. Additionally, the jar files IMO should get published to the lib directory where the so files are sitting rather than the share directory. Same holds true for jmx class files as well (probably jmx.jar?). I could work on this if everyone is okay with it. Regards Amit --- bindings/java/Makefile.am | 15 +++++++++------ configure.in | 31 +++++++++++++++++++++++++++++++ src/collectd.conf.in | 2 +- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am index d3315acc..fa253f65 100644 --- a/bindings/java/Makefile.am +++ b/bindings/java/Makefile.am @@ -27,19 +27,22 @@ EXTRA_DIST = org/collectd/api/CollectdConfigInterface.java \ java-build-stamp: org/collectd/api/*.java $(JAVAC) -d "." "$(srcdir)/org/collectd/api"/*.java $(JAVAC) -d "." "$(srcdir)/org/collectd/java"/*.java + mkdir -p .libs + $(JAR) cf .libs/collectd-api.jar "org/collectd/api"/*.class + $(JAR) cf .libs/generic-jmx.jar "org/collectd/java"/*.class touch "$@" all-local: java-build-stamp install-exec-local: java-build-stamp - mkdir -p "$(DESTDIR)$(pkgdatadir)/java/org/collectd/api" - $(INSTALL) -m 644 "org/collectd/api"/*.class \ - "$(DESTDIR)$(pkgdatadir)/java/org/collectd/api/" - mkdir -p "$(DESTDIR)$(pkgdatadir)/java/org/collectd/java" - $(INSTALL) -m 644 "org/collectd/java"/*.class \ - "$(DESTDIR)$(pkgdatadir)/java/org/collectd/java/" + mkdir -p "$(DESTDIR)$(pkgdatadir)/java" + $(INSTALL) -m 644 .libs/collectd-api.jar \ + "$(DESTDIR)$(pkgdatadir)/java" + $(INSTALL) -m 644 .libs/generic-jmx.jar \ + "$(DESTDIR)$(pkgdatadir)/java" clean-local: rm -f "org/collectd/api"/*.class rm -f "org/collectd/java"/*.class + rm -f .libs rm -f "java-build-stamp" diff --git a/configure.in b/configure.in index 89bdeaa2..107dbe39 100644 --- a/configure.in +++ b/configure.in @@ -1554,6 +1554,7 @@ with_java_vmtype="client" with_java_cflags="" with_java_libs="" JAVAC="$JAVAC" +JAR="$JAR" AC_ARG_WITH(java, [AS_HELP_STRING([--with-java@<:@=PREFIX@:>@], [Path to Java home.])], [ if test "x$withval" = "xno" @@ -1614,6 +1615,18 @@ then AC_MSG_RESULT([not found]) fi fi + if test "x$JAR" = "x" + then + AC_MSG_CHECKING([for jar]) + TMPDIR=`find "$with_java_home" -name jar -type f | head -n 1` + if test "x$TMPDIR" != "x" + then + JAR="$TMPDIR" + AC_MSG_RESULT([$JAR]) + else + AC_MSG_RESULT([not found]) + fi + fi else if test "x$with_java_home" != "x" then AC_MSG_WARN([JAVA_HOME: No such directory: $with_java_home]) @@ -1650,6 +1663,24 @@ if test "x$JAVAC" = "x" then with_java="no (javac not found)" fi +if test "x$JAR" = "x" +then + with_jar_path="$PATH" + if test "x$with_java_home" != "x" + then + with_jar_path="$with_java_home:with_jar_path" + if test -d "$with_java_home/bin" + then + with_jar_path="$with_jar_home/bin:with_jar_path" + fi + fi + + AC_PATH_PROG(JAR, jar, [], "$with_jar_path") +fi +if test "x$JAR" = "x" +then + with_java="no (jar not found)" +fi SAVE_CPPFLAGS="$CPPFLAGS" SAVE_CFLAGS="$CFLAGS" diff --git a/src/collectd.conf.in b/src/collectd.conf.in index f76d9d63..de52fbee 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -342,7 +342,7 @@ FQDNLookup true # # JVMArg "-verbose:jni" -# JVMArg "-Djava.class.path=@prefix@/share/collectd/java" +# JVMArg "-Djava.class.path=@prefix@/share/collectd/java/collectd-api.jar" # # LoadPlugin "org.collectd.java.Foobar" # -- 2.11.0