lurodrigo / firestore-clj

An unofficial Firestore API for Clojure. Provides tools for doing single pulls and writes, streaming real-time data, batched writes and transactions.
MIT License
42 stars 8 forks source link

Review google compile dependency #6

Open codestiff opened 4 years ago

codestiff commented 4 years ago

It looks like one of the "necessary" (for some circumstances) steps before using firestore-clj is to set managed-dependencies. I'm not familiar with what is happening here but suffice it to say, I've been needing to do things like: https://github.com/codestiff/connective/blob/0.1.7/modules/connective-firestore/project.clj#L8

In order to work w/ firestore-clj. I think a more complete picture of what is causing compilation issues when not using managed-dependencies is worthwhile.

For example,

Caused by: java.lang.NoClassDefFoundError: io/grpc/ManagedChannel
        at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3119)
        at java.base/java.lang.Class.privateGetPublicMethods(Class.java:3144)
        at java.base/java.lang.Class.getMethods(Class.java:1863)
        at clojure.lang.Reflector.getMethods(Reflector.java:498)
        at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:994)
        at clojure.lang.Compiler.analyzeSeq(Compiler.java:7107)
        ... 196 more
Caused by: java.lang.ClassNotFoundException: io.grpc.ManagedChannel
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
        ... 203 more
Subprocess failed
REPL server launch timed out.
codestiff commented 4 years ago

Proposal 1

Perhaps, gen-class isn't necessary. Remove the gen-class and allow it to be dynamic (vs compiled into the the jar as a .class).

https://github.com/polvotech/firestore-clj/blob/edb0f8d871138fcbe3ef19cdf8c393fae46b70e4/project.clj#L12

Use reify perhaps. Or if there a way to gen-class at runtime (reify is probably the better option). It's also possible removing the aot compilation will work as well.

codestiff commented 4 years ago

Related: https://github.com/polvotech/firestore-clj/issues/1#issuecomment-630508083

lurodrigo commented 4 years ago

Sorry for the delay! I've been really busy in the past few weeks. Gonna take a deeper look soon