Can't call public method of non-public class: public (Google gcloud library)

前端 未结 4 936
没有蜡笔的小新
没有蜡笔的小新 2021-01-06 13:46

I am attempting to use the gcloud library.

(ns firengine.state
  (:import
   [com.google.cloud AuthCredentials]
   [com.google.cloud.datastore DatastoreOpti         


        
4条回答
  •  甜味超标
    2021-01-06 14:34

    As Shlomi said, that's a long running bug. Following the advice of Noam Ben Ari on the clj-jira, I've managed the circumvent the issue by writing a small java class that wraps the client creation. I can then use that directly from my clj code.

    package pubsub_echo.pubsub;
    
    import com.google.cloud.AuthCredentials;
    import com.google.cloud.pubsub.PubSub;
    
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    
    public class GCloudPubSub {
    
        public PubSub getClient() throws FileNotFoundException, IOException {
            PubSubOptions.Builder optionsBuilder = PubSubOptions.builder();
            ClassLoader classLoader = getClass().getClassLoader();
            FileInputStream authStream = new FileInputStream(classLoader.getResource("SERVICE_ACCOUNT.json").getPath());
            AuthCredentials creds = AuthCredentials.createForJson(authStream);
    
            return optionsBuilder
                .authCredentials(creds)
                .projectId("PROJECT_ID")
                .build()
                .service();
        }
    
    }
    

    For guidance on adding Java compilation to your project:

    https://github.com/technomancy/leiningen/blob/master/doc/MIXED_PROJECTS.md

提交回复
热议问题