Created
November 12, 2015 11:53
-
-
Save pomadchin/85d38921fc7bd863d67f to your computer and use it in GitHub Desktop.
Build util
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://scastie.org/13093 | |
/*** | |
sbtPlugin := true | |
*/ | |
import sbt._ | |
import Keys._ | |
object BuildUtil { | |
private val localLibs = scala.util.Try(IO.read(file("local-libs.txt"))).map(_.split('\n').map(_.trim).toSet).getOrElse(Set()) | |
implicit class ProjectExt(p: Project) { | |
/** | |
* if artifactId is in local-libs.txt then add project at a sibling directory with that name as a dependency, otherwise add that artifact as a regular dependency | |
*/ | |
def addLib(artifactId: String, version: String) = { | |
val org = "com.com" | |
if (localLibs(artifactId)) { | |
val ref = ProjectRef(file("..") / artifactId, artifactId) | |
val exclude = allDependencies ~= (_.map(_.exclude(org, artifactId)).filterNot(m => m.organization == org && m.name == artifactId)) | |
p.dependsOn(ref).aggregate(ref).settings(exclude) | |
} | |
else { | |
p.settings(libraryDependencies += org %% artifactId % version) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment