1

I'm from javscript side and now learning scala and java ecosystem. At javascript, It was simple as npm install/yarn add, but here in java ecosystem seems a bit complex to me.

I've started scala with apache kafka. and then learned little bit of scala framework such as Play, akka, Sangria(graphql). scala frameworks work fine with sbt. Problem arises as I need to use Java libraries in my sbt scala project. or in general I don't get how java build system works. For example, If I want to add Apache kafka to any system.(maven, gradle, sbt)

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>1.0.0</version>
</dependency>

compile group: 'org.apache.kafka', name: 'kafka-clients', version: '1.0.0'

libraryDependencies += "org.apache.kafka" % "kafka-clients" % "1.0.0"

I tested maven and sbt and It worked. probably gradle will too.

This one doesn't work. https://github.com/apollographql/apollo-android

For maven project(http://mvnrepository.com/artifact/com.apollographql.apollo/apollo-runtime), versions with "Central" repositories work(such as version 0.4.1) However versions with "ApolloGraphQl" repositories doesn't work(such as version 0.4.3)

<dependency>
     <groupId>com.apollographql.apollo</groupId>
     <artifactId>apollo-runtime</artifactId>
     <version>0.4.3</version> -->!!ERROR HERE!! Dependency "com.apollographql.apollo:apollo-runtime:0.4.3" not found
     <type>pom</type>
</dependency>

For gradle project. It works only when I put jcenter() at repositories section

repositories { 
    jcenter()
  }
compile 'com.apollographql.apollo:apollo-runtime:0.4.3'

For Sbt project. It is same as maven. 0.4.1 works(Central repo) and 0.4.3 doens't work(ApolloGraphQl repo)

Another one, https://github.com/sacOO7/socketcluster-client-java This one, gradle works but maven and sbt doesn't work for all versions. I couldn't find this package at maven, but here at https://bintray.com/sacoo7/Maven/socketcluster-client

For me this is kind of big problem... I don't know if there is a one single source and many ways to build it(like npm or yarn?) or... I don't know.. sbt seems like some issues with "unresolved dependency... not found" but aside from sbt. I couldn't use Java libraries freely in Java projects(Maven, gradle or whatever) Probably, I'm the one who doesn't understand Java ecosystem. Can anyone help with this problem. I'm windows 10 64bit, IntelliJ IDEA 2017.2.5. I did scala project with scala 2.12.4, sbt 1.0.3 and maven modelVersion 4.0.0 and gradle sourceCompatibility 1.8

SOLVED ok... I figured it out. at your build.sbt put this one.

resolvers += Resolver.jcenterRepo

I'm not super clear but I think... sbt tries to find libraries in some default repository(I'm not sure which one) If It can't find out that's the not found error. so I have to manually set the repositories. probably each build system has that.

Roniel
  • 13
  • 5
  • Your problem is easy to solve if you understand something about Maven and dependencies. Java build facilities work fine. You need to understand them better. Have your Java project publish a JAR to Maven for your Scala project to pull in. It's simple. – duffymo Jan 05 '18 at 13:44
  • In my case I didn't want that kind of style... as I searched, I could add dependency by github repo link or download it and add dependency by local repo. I feel it's like a hack... I want more general solution that I want to use any java libraries at my sbt. anyway.... problem solved – Roniel Jan 06 '18 at 13:56
  • Not a hack. I’d get over that reluctance. – duffymo Jan 06 '18 at 14:00

0 Answers0