Code

Build system: Put Java class files into a .jar file.
authorAmit Gupta <amit.gupta221@gmail.com>
Wed, 10 Feb 2010 13:37:36 +0000 (14:37 +0100)
committerFlorian Forster <octo@huhu.verplant.org>
Wed, 10 Feb 2010 13:48:33 +0000 (14:48 +0100)
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
configure.in
src/collectd.conf.in

index d3315accc5b896a0d4b019a6813cfb681ba954cb..fa253f65d0ed21e9d2df07707a533cac4621c947 100644 (file)
@@ -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"
index 89bdeaa2d8397a4045dce8ce528769b78a81630c..107dbe39e872434de81ade84b481531cfece1de9 100644 (file)
@@ -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"
index f76d9d63f49fdf7145cdb830a0848bc29bacd8a7..de52fbee57d32463ed571aff0443ac3d00600f02 100644 (file)
@@ -342,7 +342,7 @@ FQDNLookup   true
 
 #<Plugin "java">
 #      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"
 #      <Plugin "org.collectd.java.Foobar">