Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read application.conf from build.sbt

Tags:

scala

sbt

I found a lot of similar questions, but some of them are unanswered and others don't work for me.
My task is to read application.conf from build.sbt, to keep all configuration in a single place. But my build.sbt with code

import com.typesafe.config._

val conf = com.typesafe.config.ConfigFactory.parseFile(new File("conf/application.conf")).resolve()

version := conf.getString("app.version")

don't compile with error

error: object typesafe is not a member of package com

How to fix this problem?

like image 263
Dmitry Meshkov Avatar asked Aug 05 '15 08:08

Dmitry Meshkov


1 Answers

To make this work it is important to know that sbt projects have a recursive structure, so when you run sbt you actually start a project that has as root folder the project folder within your root project.

Given that, to fix your problem you need to add typesafe-config as a library dependency also for you sbt project; in order to do that add a build.sbt in the project folder of your root project and specify the dependency in there as you would normally do (i.e. libraryDependencies += ...).

like image 154
Aldo Stracquadanio Avatar answered Oct 17 '22 23:10

Aldo Stracquadanio