best-quill-79210
03/14/2023, 12:07 PMbetter-magician-65629
03/14/2023, 5:12 PMbuild.gradle
file has the build configuration: https://github.com/growthbook/growthbook-sdk-java/blob/main/lib/build.gradle
You can also see the github actions workflows that build and test: https://github.com/growthbook/growthbook-sdk-java/tree/main/.github/workflows
are you trying to import Gson or OkHttp into your project? they are not exposed and are therefore not available. if you are trying to use Gson and OkHttp directly, you'll need to add them as dependencies to your project.
we have specified them as implementation
dependencies rather than api
dependencies. here's a snippet from the gradle docs:
Dependencies appearing in theconfigurations will be transitively exposed to consumers of the library, and as such will appear on the compile classpath of consumers. Dependencies found in theapi
configuration will, on the other hand, not be exposed to consumers, and therefore not leak into the consumers' compile classpath. This comes with several benefits:implementation
• dependencies do not leak into the compile classpath of consumers anymore, so you will never accidentally depend on a transitive dependency
• faster compilation thanks to reduced classpath size
• less recompilations when implementation dependencies change: consumers would not need to be recompiled
• cleaner publishing: when used in conjunction with the newyou can learn more about that here: https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation this example JVM project implements the growthbook SDK. it does not use OkHttp directly but implements the GBFeatureRepository which does. It does, however, use its own version of Gson: https://github.com/growthbook/examples/tree/main/jvm-spring-web let me know if there's anything else i can answer.plugin, Java libraries produce POM files that distinguish exactly between what is required to compile against the library and what is required to use the library at runtime (in other words, don’t mix what is needed to compile the library itself and what is needed to compile against the library).maven-publish
best-quill-79210
03/14/2023, 8:47 PM<dependency>
<groupId>com.github.growthbook</groupId>
<artifactId>growthbook-sdk-java</artifactId>
<version>main-SNAPSHOT</version>
<scope>system</scope>
<systemPath>/Users/pranay.garg/Documents/growthbook-sdk-java/lib/build/libs/lib-main-SNAPSHOT.jar</systemPath>
</dependency>
and just creating the
Growthbook growthbook = new Growthbook()
on running the project, it throws the following error
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/GsonBuilder
at growthbook.sdk.java.GrowthBookJsonUtils.<init>(GrowthBookJsonUtils.java:28)
at growthbook.sdk.java.GrowthBookJsonUtils.getInstance(GrowthBookJsonUtils.java:56)
at growthbook.sdk.java.GrowthBook.<init>(GrowthBook.java:20)
at com.groww.test.TestApplication.main(TestApplication.java:23)
Caused by: java.lang.ClassNotFoundException: com.google.gson.GsonBuilder
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
better-magician-65629
03/14/2023, 9:00 PMimplementation
to api
in your cloned code to add the dependencies to your class path
i'm not sure you'll be able to access the dependencies this way without adding them to your classpath yourself. this is a related stackoverflow post about this. and according to this one, system scope is deprecated in maven. i haven't used this before but it looks like alternatives are the maven-install-plugin and install:install-file
goal. https://maven.apache.org/plugins/maven-install-plugin/usage.html
This is related to how you're resolving the dependencies locally.best-quill-79210
03/15/2023, 9:42 AMgradle publishToMavenLocal
better-magician-65629
03/21/2023, 7:53 PM