I have a Scala project that is dependent on a Java project(child project). My project structure is :
I am using GitLab to download some depedency jars for my project and I am using GitlabPlugin.
My build.sbt:
lazy val root = Project("root-proj", file(".")).dependsOn(childProj)
lazy val childProj = Project("child", file("child")).settings(
libraryDependencies ++= Seq(
"org.jdom" % "jdom" % "1.1.3",
"commons-lang" % "commons-lang" % "2.6",
"junit" % "junit" % "4.12" % Test,
"com.novocode" % "junit-interface" % "0.11" % Test
),
Compile / compile / javacOptions += "-g",
Compile / packageDoc / mappings := Seq()
)
ThisBuild / useCoursier := false
enablePlugins(GitlabPlugin)
import com.gilcloud.sbt.gitlab.{GitlabCredentials, GitlabPlugin}
GitlabPlugin.autoImport.gitlabDomain := "gitlab.com"
GitlabPlugin.autoImport.gitlabCredentials := {
sys.env.get("CI_JOB_TOKEN") match {
// Gitlab CI pipeline
case Some(t) =>
Some(GitlabCredentials("Job-Token", t))
// local machine
case None =>
val c = Credentials
.loadCredentials(Path.userHome / ".sbt" / ".credentials.gitlab")
.left
.map(s => new IllegalArgumentException(s))
.toTry
.get
Some(GitlabCredentials(c))
}
}
My plugins.sbt has this line: addSbtPlugin("com.gilcloud" % "sbt-gitlab" % "0.1.2")
I am able to build the root project successfully if it is not dependent on Child project by commenting .dependsOn(childProj)
and childProj
variable.
But if use the Child project to build, I get the following errors:
[error] stack trace is suppressed; run 'last child / headerAuthHandler' for the full output
[error] stack trace is suppressed; run 'last ssExtractDependencies' for the full output
[error] stack trace is suppressed; run 'last child / ssExtractDependencies' for the full output
[error] (child / headerAuthHandler) java.util.NoSuchElementException: None.get
[error] (ssExtractDependencies) java.util.NoSuchElementException: None.get
[error] (child / ssExtractDependencies) java.util.NoSuchElementException: None.get
This works fine If I run using GitLab pipeline, the issue is while trying to build locally using IntelliJ.
How do I tell my child project to use GitlabPlugin and use all GitlabPlugin statements?
I tried using Project("child", file("child")).enablePlugins(GitlabPlugin).settings(...
but still the same issue.
I added the line
credentials += Credentials(Path.userHome / ".sbt" / ".credentials.gitlab")
to my child project settings and it started working. This may be specific to sbt-gitlab
plugin.