tkawachi / sbt-lock

Gemfile.lock for sbt
75 stars 12 forks source link

properly handle test dependencies #40

Open jtjeferreira opened 3 years ago

jtjeferreira commented 3 years ago

Uses dependencyOverrides instead of Compile / dependencyOverrides because otherwise it is unused. However to also fix the use case presented in https://github.com/tkawachi/sbt-lock/pull/30, this PR also looks into Test classpath and adds these modules to the dependencyOverrides with the test configuration...

I tested this in my work project and the changes were minimal

@@ -1,8 +1,8 @@
 // DON'T EDIT THIS FILE.
-// This file is auto generated by sbt-lock 0.6.1.
+// This file is auto generated by sbt-lock 0.8.1-SNAPSHOT.
 // https://github.com/tkawachi/sbt-lock/
 dependencyOverrides ++= {
-  if (!(sbtLockHashIsUpToDate in ThisBuild).value && sbtLockIgnoreOverridesOnStaleHash.value) {
+  if (!(ThisBuild / sbtLockHashIsUpToDate).value && sbtLockIgnoreOverridesOnStaleHash.value) {
     Seq.empty
   } else {
     Seq(
@@ -12,6 +12,7 @@ dependencyOverrides ++= {
       "com.beachape" % "enumeratum-macros_2.13" % "1.5.10",
       "com.beachape" % "enumeratum_2.13" % "1.5.14",
       "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.0",
+      "com.fasterxml.jackson.core" % "jackson-annotations" % "2.9.8" % "test",
       "com.fasterxml.jackson.core" % "jackson-core" % "2.9.9",
       "com.fasterxml.jackson.core" % "jackson-databind" % "2.9.9",
       "com.github.ben-manes.caffeine" % "caffeine" % "2.8.0",
@@ -62,6 +63,7 @@ dependencyOverrides ++= {
       "io.perfmark" % "perfmark-api" % "0.19.0",
       "javax.activation" % "activation" % "1.1",
       "javax.xml.bind" % "jaxb-api" % "2.1",
+      "javax.xml.bind" % "jaxb-api" % "2.3.0" % "test",
       "javax.xml.stream" % "stax-api" % "1.0-2",
       "org.checkerframework" % "checker-qual" % "2.10.0",
       "org.codehaus.mojo" % "animal-sniffer-annotations" % "1.18",

fixes #34

An improvement to this could be adding a new setting to control, how test dependencies should be added:

  1. add all test dependencies (which would handle #28) - not implemented
  2. add only test dependencies where the version is different than compile dependencies - implemented in this PR
  3. do not add test dependencies at all
jtjeferreira commented 3 years ago

hi @tkawachi

could you have a look at the PR? do you think I need to improve anything?

jtjeferreira commented 2 years ago

hi @tkawachi

any chance to have a look at this?

nrdxp commented 2 years ago

Can we merge this? The plugin is basically completely broken without it