diff --git a/interface/src/main/java/coursierapi/ResolutionParams.java b/interface/src/main/java/coursierapi/ResolutionParams.java index 6774ed1..2f173a8 100644 --- a/interface/src/main/java/coursierapi/ResolutionParams.java +++ b/interface/src/main/java/coursierapi/ResolutionParams.java @@ -16,6 +16,7 @@ public class ResolutionParams implements Serializable { private Boolean keepProvidedDependencies; private Boolean forceDepMgmtVersions; private Boolean enableDependencyOverrides; + private String defaultConfiguration; private ResolutionParams() { maxIterations = null; @@ -29,6 +30,7 @@ private ResolutionParams() { keepProvidedDependencies = null; forceDepMgmtVersions = null; enableDependencyOverrides = null; + defaultConfiguration = null; } @Override @@ -46,7 +48,8 @@ public boolean equals(Object o) { Objects.equals(scalaVersion, that.scalaVersion) && Objects.equals(keepProvidedDependencies, that.keepProvidedDependencies) && Objects.equals(forceDepMgmtVersions, that.forceDepMgmtVersions) && - Objects.equals(enableDependencyOverrides, that.enableDependencyOverrides); + Objects.equals(enableDependencyOverrides, that.enableDependencyOverrides) && + Objects.equals(defaultConfiguration, that.defaultConfiguration); } @Override @@ -62,7 +65,8 @@ public int hashCode() { scalaVersion, keepProvidedDependencies, forceDepMgmtVersions, - enableDependencyOverrides); + enableDependencyOverrides, + defaultConfiguration); } @Override @@ -79,6 +83,7 @@ public String toString() { ", keepProvidedDependencies=" + keepProvidedDependencies + ", forceDepMgmtVersions=" + forceDepMgmtVersions + ", enableDependencyOverrides=" + enableDependencyOverrides + + ", defaultConfiguration=" + defaultConfiguration + '}'; } @@ -98,7 +103,8 @@ public static ResolutionParams of(ResolutionParams params) { .withScalaVersion(params.scalaVersion) .withKeepProvidedDependencies(params.keepProvidedDependencies) .withForceDepMgmtVersions(params.forceDepMgmtVersions) - .withEnableDependencyOverrides(params.enableDependencyOverrides); + .withEnableDependencyOverrides(params.enableDependencyOverrides) + .withDefaultConfiguration(params.defaultConfiguration); } public ResolutionParams withMaxIterations(Integer maxIterations) { @@ -197,6 +203,11 @@ public ResolutionParams withEnableDependencyOverrides(Boolean enableDependencyOv return this; } + public ResolutionParams withDefaultConfiguration(String defaultConfiguration) { + this.defaultConfiguration = defaultConfiguration; + return this; + } + public Integer getMaxIterations() { return maxIterations; } @@ -240,4 +251,8 @@ public Boolean getForceDepMgmtVersions() { public Boolean getEnableDependencyOverrides() { return enableDependencyOverrides; } + + public String getDefaultConfiguration() { + return defaultConfiguration; + } } diff --git a/interface/src/main/scala/coursier/internal/api/ApiHelper.scala b/interface/src/main/scala/coursier/internal/api/ApiHelper.scala index 0272a93..b1608d6 100644 --- a/interface/src/main/scala/coursier/internal/api/ApiHelper.scala +++ b/interface/src/main/scala/coursier/internal/api/ApiHelper.scala @@ -260,6 +260,7 @@ object ApiHelper { .withKeepProvidedDependencies(params.keepProvidedDependencies.map(b => b: JBoolean).orNull) .withForceDepMgmtVersions(params.forceDepMgmtVersions.map(b => b: JBoolean).orNull) .withEnableDependencyOverrides(params.enableDependencyOverrides.map(b => b: JBoolean).orNull) + .withDefaultConfiguration(if (params.defaultConfiguration == ResolutionParams().defaultConfiguration) null else params.defaultConfiguration.value) } def resolutionParams(params: coursierapi.ResolutionParams): ResolutionParams = { @@ -277,6 +278,7 @@ object ApiHelper { .withKeepProvidedDependencies(Option(params.getKeepProvidedDependencies).map(b => b: Boolean)) .withForceDepMgmtVersions(Option(params.getForceDepMgmtVersions).map(b => b: Boolean)) .withEnableDependencyOverrides(Option(params.getEnableDependencyOverrides).map(b => b: Boolean)) + .withDefaultConfiguration(Option(params.getDefaultConfiguration).map(Configuration(_)).getOrElse(params0.defaultConfiguration)) } def cache(cache: coursierapi.Cache): FileCache[Task] = { diff --git a/interface/src/test/scala/coursierapi/ResolutionParamsTests.scala b/interface/src/test/scala/coursierapi/ResolutionParamsTests.scala index eacd1e1..d7072ed 100644 --- a/interface/src/test/scala/coursierapi/ResolutionParamsTests.scala +++ b/interface/src/test/scala/coursierapi/ResolutionParamsTests.scala @@ -30,6 +30,7 @@ object ResolutionParamsTests extends TestSuite { .addExclusion("org.scala-lang.modules", "*") .withUseSystemOsInfo(false) .withUseSystemJdkVersion(false) + .withDefaultConfiguration("foo") val params0 = ApiHelper.resolutionParams(ApiHelper.resolutionParams(params)) assert(params != ResolutionParams.create()) @@ -49,6 +50,7 @@ object ResolutionParamsTests extends TestSuite { .withUseSystemOsInfo(true) .withUseSystemJdkVersion(true) .withScalaVersion("2.14.3") + .withDefaultConfiguration("thing") val params0 = ApiHelper.resolutionParams(ApiHelper.resolutionParams(params)) assert(params != ResolutionParams.create())