score:4
Accepted answer
well, one of these you have to set explicitly, then the other one can be calculated:
librarydependencies += "com.company" % "mylib" % (if (name.value.endswith("1.0")) "1.0" else "2.0")`
then during build you could do something like:
sbt> ;compile;publish // <- e.g. for v 1.0
sbt> set name := "myproject-mylib-2.0"
sbt> ;compile;publish // <- e.g. for v 2.0
if you want it more principled you could define a new key:
val isnew = settingkey[boolean]("are we building a new version of a library")
global / isnew := false
name := if (isnew.value) "myproject-mylib-2.0" else "myproject-mylib-1.0"
librarydependencies += "com.company" % "mylib" % (if (isnew.value) "2.0" else "1.0")`
which you would build like
sbt> ;compile;publish // <- for v 1.0
sbt> set isnew := true
sbt> ;compile;publish // <- for v 2.0
or from command line
sbt compile publish "set isnew := true" compile publish
Source: stackoverflow.com
Related Query
- Cross-building a project dependent on different versions of specific library
- SBT cross building - choosing a different library version for different scala version
- SBT: Cross build project for two Scala versions with different dependencies
- Scala: how to build Scala project with cross build alongside different library dependencies
- How can I cross-compile Scala versions that support different core library APIs?
- Build for different library versions with SBT
- sbt using different Scala versions in a multi project build
- Is it possible to have two different sbt versions for a project simultaneously
- How to chose a specific version of package added by different SBT library dependencies
- How to support multiple Scala versions in a library
- Warnings while building Scala/Spark project with SBT
- Multiple executable jar files with different external dependencies from a single project with sbt-assembly
- Trying to cross compile a project to Scala 2.11 fails with "error while loading Object, Missing dependency 'object scala in compiler mirror'"
- What is the most mature library for building a Data Analytics Pipeline in Java/Scala for Hadoop?
- Unresolved Dependencies when building play 2.0 project
- How do i use play ws library in normal sbt project instead of play?
- Specific syntax to scope library dependencies in SBT?
- Make tests in multi project sbt projects run only if tests pass in dependent projects
- Exclude a specific implicit from a Scala project
- Intellij 12 and internal compilation error when building scala project
- Including Hyperic Sigar library within jar while using sbt assembly for Scala project
- How to use multiple versions of a library in Scala?
- Different ways of building typeclasses in Scala?
- How to install library with SBT libraryDependencies in an Intellij project
- How to toggle between project and library dependencies in SBT?
- Using a Scala 3 Library in a Scala 2.13 Project
- Scalatest building and running in Intellij, but not building the project when run on the command line with maven
- Scala IDE and Apache Spark -- different scala library version found in the build path
- How to create a Play project with a specific version?
- Scala claims I am using different versions of Akka
More Query from same tag
- compiling NW extension in NetLogo
- Read Kafka topic in a Spark batch job
- Scala function not passed by name with curly brackets (braces)
- Why do year and month functions result in long overflow in Spark?
- Scala: Add a sequence number to duplicate elements in a list
- How read table with non utf-8 encoding in aws gllue?
- How to increment for loop variable dynamically in scala?
- Spark SQL - java.lang.UnsupportedOperationException: empty.init when casting column
- ScalaJson: Parsing optional values (with default) without Option
- Not able to replace null values in Spark Dataframe with Integer value
- Can't Run `test` in Scala Test with SBT
- Form mapping that handles optional fields with custom validation
- PlaySlick Database Connection to PostgreSQL
- How to make the code more generic
- how to get the index of the duplicate pair in the a list using scala
- What does it mean to instantiate a trait?
- Incorrect count when counting objects in AWS S3 bucket using sdk
- Scala / sbt java.lang.ClassNotFoundException: com.ullink.slack.simpleslackapi.listeners.SlackMessagePostedListener
- How can I flatten this Future[T] structure?
- Evolution of kafka-streams topology in production
- Comma Separated sequence in a single line using Scala
- Adding dataframes to List in Spark
- How to calculate consecutiveness in Dataset?
- Play 2.0 eclipsify command with sources broken?
- using REST webservices as a datasource for Lift?
- IntelliJ Idea Cannot find sbt-idea-compiler-indices
- Is it possible to override an inline function?
- Find duration between two timestamp in different rows
- How to use reduce or fold to avoid mutable state
- Apache Spark: how to cancel job in code and kill running tasks?