pgspider / jdbc_fdw

JDBC Foreign Data Wrapper for PostgreSQL
Other
64 stars 21 forks source link

JFLAGS is set to a system directory for build #38

Open mbanck-ntap opened 4 months ago

mbanck-ntap commented 4 months ago

The JAVAFILES target builds a class file out of the java sources. However, it runs javac $(JFLAGS) ... , where JFLAGS is defined further up in the Makefile as -d $(pkglibdir). $(pkglibdir) is usually under /usr so not writable for a non-root user.

I think what is needed here is building the class file into a temporary build directory under the current (source) directory and then installing the class file into $pglibdir during make install.

Currently, the build fails with a cryptic error while writing JDBCUtils error that is not obviously due to permission problems:

javac -d /usr/lib/postgresql/16/lib /<<PKGBUILDDIR>>/JDBCUtils.java /<<PKGBUILDDIR>>/JDBCDriverLoader.java /<<PKGBUILDDIR>>/JDBCConnection.java /<<PKGBUILDDIR>>/resultSetInfo.java
/<<PKGBUILDDIR>>/JDBCUtils.java:29: error: error while writing JDBCUtils: /usr/lib/postgresql/16/lib/JDBCUtils.class
public class JDBCUtils {
       ^
Note: /<<PKGBUILDDIR>>/JDBCConnection.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
make[1]: *** [/<<PKGBUILDDIR>>/Makefile:37: JAVAFILES] Error 1
mbanck-ntap commented 4 months ago

Actually, on further reflection, I don't think $pkglibdir is the right directory anyway. The PL/Java project installs its .jar into the $sharedir/extension directory, as jars (and Java classes) are platform-independent.

This way, one could also leave the installation to PGXS, i.e. build the .class files in the local directory and add them to DATA_built in the Makefile while also switching pkglibdir in PG_CPPFLAGS.