Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sbt 1.4.0 when COURSIER_CACHE is overridden #75

Merged
merged 3 commits into from
Oct 20, 2020

Conversation

anilkumarmyla
Copy link
Contributor

Fixes #74

When COURSIER_CACHE is overriden (say to .cache/coursier/v1), in sbt-1.4.0 we would get file path as ${BASE}/.cache/coursier/v1/https/repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar in which case we need to interpolate ${BASE} as well. This PR attempts to do so

@anilkumarmyla anilkumarmyla marked this pull request as ready for review October 19, 2020 00:51
@cb372
Copy link
Owner

cb372 commented Oct 19, 2020

Do you want to try adding a scripted test for this? I think adding the following line to build.sbt in the test project should reproduce the issue:

ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-cache"

When I upgraded the example project to sbt 1.4.0 and added that line I got debug output like this:

[debug] Source to library relations:
[debug]   ${BASE}/src/main/scala/foo/MyCaseClass.scala -> ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.11/scala-library-2.12.11.jar
[debug]   ${BASE}/src/main/scala/foo/MyCaseClass.scala -> ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/typelevel/cats-effect_2.12/0.10.1/cats-effect_2.12-0.10.1.jar
[debug]   ${BASE}/src/main/scala/foo/Example.scala -> ${BASE}/coursier-cache/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.12/2.3.3/shapeless_2.12-2.3.3.jar
[debug]   ${BASE}/src/main/scala/foo/Example.scala -> ${BASE}/coursier-cache/https/repo1.maven.org/maven2/com/google/guava/guava/26.0-jre/guava-26.0-jre.jar
[debug]   ${BASE}/src/main/scala/foo/Example.scala -> ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/typelevel/cats-effect_2.12/0.10.1/cats-effect_2.12-0.10.1.jar
[debug]   ${BASE}/src/main/scala/foo/Example.scala -> ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.11/scala-library-2.12.11.jar
[debug]   ${BASE}/src/main/scala/foo/Example.scala -> ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/typelevel/cats-core_2.12/1.2.0/cats-core_2.12-1.2.0.jar
[debug]   ${BASE}/src/main/scala/foo/Example.scala -> ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/http4s/http4s-blaze-server_2.12/0.18.16/http4s-blaze-server_2.12-0.18.16.jar
[debug] Library dependencies:
[debug]   ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/typelevel/cats-effect_2.12/0.10.1/cats-effect_2.12-0.10.1.jar
[debug]   ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/http4s/http4s-blaze-server_2.12/0.18.16/http4s-blaze-server_2.12-0.18.16.jar
[debug]   ${BASE}/coursier-cache/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.12/2.3.3/shapeless_2.12-2.3.3.jar
[debug]   ${BASE}/coursier-cache/https/repo1.maven.org/maven2/com/google/guava/guava/26.0-jre/guava-26.0-jre.jar
[debug]   ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/typelevel/cats-core_2.12/1.2.0/cats-core_2.12-1.2.0.jar
[debug]   ${BASE}/coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.12.11/scala-library-2.12.11.jar

@anilkumarmyla
Copy link
Contributor Author

Added the scripted test. I was wondering how I could add an env variable while doing scripted test and completely forgot I could override it in build.sbt. Thanks for the suggestion, added the test and verified it fails without this change and passes with the change

@anilkumarmyla
Copy link
Contributor Author

Hmm, I realized this key doesn't exist in sbt 1.2.x or lower and fails the test for those builds 😬 Any suggestions on how I could resolve? Should I pin the scripted test to sbt 1.4.0?

@cb372
Copy link
Owner

cb372 commented Oct 20, 2020

I can't think of a good way to make just this test run only on certain versions of sbt 1.x.

If you want to give up on writing a test for this, I'm fine with that. You've already tested it manually and I've reviewed the code, so I'm satisfied that it works. In an ideal world we'd have an automated test, but I don't think it's worth spending too much effort on.

@anilkumarmyla
Copy link
Contributor Author

Yeah we can add a test when we stop supporting sbt 1.2.x or lower, for now i've reverted the test commit

@cb372 cb372 merged commit 38752aa into cb372:master Oct 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[sbt 1.4.0] Plugin doesn't work when COURSIER_CACHE is overridden
2 participants