RMongo
RMongo copied to clipboard
Fix Java jar path to comply with CRAN publishing rules
After submitting to CRAN, got this reply:
This is not the way to submit to CRAN: see the CRAN policies.
You did not check as per the policies, and missed
Package has FOSS license, installs .class/.jar but has no 'java' directory.
" Source packages under an Open Source license must provide source or something which can easily be converted back to source (e.g., .rda files) for all components of the package (including for example PDF documentation, configure files produced by autoconf). For Java .class and .jar files, the sources should be in a top-level java directory in the source package (or that directory should explain how they can be obtained). "
Code doesn't compile:
> mongo <- mongoDbConnect("test")
Error in .jnew("rmongo/RMongo", dbName, host, as.integer(port)) :
java.lang.ClassNotFoundException
Calls: mongoDbConnect ... new -> initialize -> initialize -> .jnew ->
.External
…
I'm new to R so sorry if i'm wrong.
The exception is thrown because the r-mongo-scala-1.0-SNAPSHOT.jar is not in the classpath.
You can see the classpath used at runtime with print(.jclassPath())
I fix this issue by moving the java directory into the old inst directory, as before your last commit. Otherwise, the java directory with the jar is not copied in the package installation (you can see this directory location with print(system.file(package = "RMongo"))
).
Maybe there is an other way to fix this without the inst directory. If you want, i can add a PR.
Thanks @oziade we can move it back, but CRAN won't let me publish unless the java jar file is in source package. I would like to get this updated package updated in CRAN.
As i understand the error message in your first comment, i think CRAN just need the source for building jar in the java top level directory, not the jar itself, which could be kept in the inst directory. If you look in this R package, the java directory contains the java source file. I don't know if the scala file is enough in this case.
But i'm not very familiar with CRAN policy !
Thanks, i'll try that and re-submit.
@tc have you tried to re-submit RMongo to CRAN? If still the same reason for rejecting are valid, the following could solve the isue, accoridng CRAN policy: "For Java .class and .jar files, the sources should be in a top-level java directory in the source package (or that directory should explain how they can be obtained)."
So, all you need to do is add a "java" folder which is not empty. If the folder is empty it is removed during building. Just add a README file in there, with a link to the java driver source of MongoDB driver; the releases are on Github, see here: https://github.com/mongodb/mongo-java-driver/releases
That should fix at least the mentioned "note" from CRAN. You can check for CRAN compliance by running R CMD check --as-cran -> should result in no errors, no warnings and no notes (except a note for who is maintainer).