How do I import class abc
from project main
to be used by another class in project web
in a multi-project sbt
configuration?
Upon sbt compile
I get:object abc is not a member of package com
not found: type abc
While compilation from within IntelliJ is successful.
build.sbt
lazy val main = project.in(file("main"))
.settings(commonSettings: _*)
lazy val web = project.in(file("web"))
.settings(commonSettings: _*)
.enablePlugins(PlayScala)
.dependsOn(main)
lazy val root = (project in file("."))
.dependsOn(web, main)
.aggregate(web, main)
.settings(commonSettings: _*)
mainClass in root in Compile := (mainClass in web in Compile).value
fullClasspath in web in Runtime ++= (fullClasspath in main in Runtime).value
fullClasspath in root in Runtime ++= (fullClasspath in web in Runtime).value
Inside web project:
package com.company.web.controllers
import _root_.com.company.main.abc // also tried without root.
// Intellij recognizes the import successuflly
class Posts @Inject() (repo : abc) extends Controller { ..
Inside main project:
package com.company.main
class abc @Inject() (){
What could be wrong? Thanks.
Turned out the directory structure of project main
wasn't according to maven
directory structure, as described here
src/
main/
scala/
com/bla/bla
test/
scala/
<test Scala sources
Intellij was successfully compiling the project because whatever old directory structure was in place, it was marked as source directory
under File -> project structure -> modules -> sources
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With