mirror of https://github.com/sbt/sbt.git
Expose Ivy's circular dependency check via UpdateOptions
This commit is contained in:
parent
a27c636a36
commit
577496b1b6
|
|
@ -0,0 +1,27 @@
|
|||
package sbt
|
||||
|
||||
import org.apache.ivy.plugins.circular.{ CircularDependencyStrategy, WarnCircularDependencyStrategy, IgnoreCircularDependencyStrategy, ErrorCircularDependencyStrategy }
|
||||
|
||||
/**
|
||||
* Wrapper around circular dependency strategy.
|
||||
*/
|
||||
sealed trait CircularDependencyLevel {
|
||||
private[sbt] def ivyStrategy: CircularDependencyStrategy
|
||||
private[sbt] def name: String
|
||||
override def toString: String = name
|
||||
}
|
||||
|
||||
object CircularDependencyLevel {
|
||||
val Warn: CircularDependencyLevel = new CircularDependencyLevel {
|
||||
def ivyStrategy: CircularDependencyStrategy = WarnCircularDependencyStrategy.getInstance
|
||||
def name: String = "warn"
|
||||
}
|
||||
val Ignore: CircularDependencyLevel = new CircularDependencyLevel {
|
||||
def ivyStrategy: CircularDependencyStrategy = IgnoreCircularDependencyStrategy.getInstance
|
||||
def name: String = "ignore"
|
||||
}
|
||||
val Error: CircularDependencyLevel = new CircularDependencyLevel {
|
||||
def ivyStrategy: CircularDependencyStrategy = ErrorCircularDependencyStrategy.getInstance
|
||||
def name: String = "error"
|
||||
}
|
||||
}
|
||||
|
|
@ -69,6 +69,7 @@ final class IvySbt(val configuration: IvyConfiguration) {
|
|||
{
|
||||
val is = new IvySettings
|
||||
is.setBaseDir(baseDirectory)
|
||||
is.setCircularDependencyStrategy(configuration.updateOptions.circularDependencyLevel.ivyStrategy)
|
||||
CustomPomParser.registerDefault
|
||||
configuration match {
|
||||
case e: ExternalIvyConfiguration =>
|
||||
|
|
|
|||
|
|
@ -10,25 +10,33 @@ import java.io.File
|
|||
* See also UpdateConfiguration in IvyActions.scala.
|
||||
*/
|
||||
final class UpdateOptions private[sbt] (
|
||||
/** If set to CircularDependencyLevel.Error, halt the dependency resolution. */
|
||||
val circularDependencyLevel: CircularDependencyLevel,
|
||||
/** If set to true, check all resolvers for snapshots. */
|
||||
val latestSnapshots: Boolean,
|
||||
/** If set to true, use consolidated resolution. */
|
||||
val consolidatedResolution: Boolean) {
|
||||
|
||||
def withCircularDependencyLevel(circularDependencyLevel: CircularDependencyLevel): UpdateOptions =
|
||||
copy(circularDependencyLevel = circularDependencyLevel)
|
||||
def withLatestSnapshots(latestSnapshots: Boolean): UpdateOptions =
|
||||
copy(latestSnapshots = latestSnapshots)
|
||||
def withConsolidatedResolution(consolidatedResolution: Boolean): UpdateOptions =
|
||||
copy(consolidatedResolution = consolidatedResolution)
|
||||
|
||||
private[sbt] def copy(
|
||||
circularDependencyLevel: CircularDependencyLevel = this.circularDependencyLevel,
|
||||
latestSnapshots: Boolean = this.latestSnapshots,
|
||||
consolidatedResolution: Boolean = this.consolidatedResolution): UpdateOptions =
|
||||
new UpdateOptions(latestSnapshots, consolidatedResolution)
|
||||
new UpdateOptions(circularDependencyLevel,
|
||||
latestSnapshots,
|
||||
consolidatedResolution)
|
||||
}
|
||||
|
||||
object UpdateOptions {
|
||||
def apply(): UpdateOptions =
|
||||
new UpdateOptions(
|
||||
circularDependencyLevel = CircularDependencyLevel.Warn,
|
||||
latestSnapshots = true,
|
||||
consolidatedResolution = false)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue