Skip to content

Replace coursier-small with coursier-interface to use the prope…#1030

Merged
olafurpg merged 7 commits intoscalameta:masterfrom
sswistun-vl:coursier-interface
Nov 20, 2019
Merged

Replace coursier-small with coursier-interface to use the prope…#1030
olafurpg merged 7 commits intoscalameta:masterfrom
sswistun-vl:coursier-interface

Conversation

@sswistun-vl
Copy link
Copy Markdown
Contributor

Replaced coursier-small with coursier-interface and added support for supplying custom repositories via environment variable

Copy link
Copy Markdown
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! One small question

@olafurpg
Copy link
Copy Markdown
Member

The test failure looks relevant

X tests.TreeViewLspSuite.libraries 1079ms 
  com.geirsson.coursiersmall.FileException$NotFound: not found: https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava-sources.jar

We should remove all usage of coursier-small, including QuickBuild for the tests

@sswistun-vl sswistun-vl force-pushed the coursier-interface branch 2 times, most recently from 1945b34 to 8f53fe5 Compare October 31, 2019 12:31
@sswistun-vl
Copy link
Copy Markdown
Contributor Author

Ok, I've removed all references to coursier-small, but now there are some seemingly unrelated problems, I'm trying to work them out.

envRepos
.split("""|""")
.map(MavenRepository.of)
.toList: _*
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a Java vararg method. toList:_* is fine, we can deal with 2.13 deprecations another time

@tgodzik tgodzik changed the title coursier-small changed to coursier-interface Replace coursier-small with coursier-interface to use the proper Coursier API Nov 12, 2019
Copy link
Copy Markdown
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just 2 small things to fix, otherwise LGTM

@sswistun-vl
Copy link
Copy Markdown
Contributor Author

Ok, all previous comments should be resolved, sorry for lack of responses.

Copy link
Copy Markdown
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sswistun-vl sswistun-vl force-pushed the coursier-interface branch 3 times, most recently from 2e94185 to 567b7f7 Compare November 14, 2019 14:13
val regex = """([^:]+):([^:]+):([^:]+)""".r

dep match {
case regex(org, name, version) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the regex doesn't match?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a test, so I wouldn't bother validating this. You can optionally log the unexpected case when the regex doesn't match

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this is not a test. Doing regex without the actual need for them is bad. Let's revert.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the dependencies in one like Dependency.of("foo", "bar", "baz") and either keep the regex only in the test scope or drop them altogether

Copy link
Copy Markdown
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to Marek's review just a tiny additional thing.

val regex = """([^:]+):([^:]+):([^:]+)""".r

dep match {
case regex(org, name, version) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a test, so I wouldn't bother validating this. You can optionally log the unexpected case when the regex doesn't match

.dropVendorSuffix(info.getScalaVersion)
val pc = Dependency.of(
s"org.scalameta",
s"mtags_$scala_version",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract to mtagsVersion

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, we don't use it more than once and mtagsVersion would really be less clear here. It's not really mtags version, just mtags + scala version.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to keep this as is. This is BTW the "mtags artifact name", not "mtags version"

s"mtags_${ScalaVersions.dropVendorSuffix(info.getScalaVersion)}",
val scala_version = ScalaVersions
.dropVendorSuffix(info.getScalaVersion)
val pc = Dependency.of(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep the call in one line like Dependency.of(a, b, c) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scalafmt keeps breaking this line.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because it's too long, you would need to extract it to val compilerVersion = mtags.BuildInfo.scalaCompilerVersion. But honestly, I wouldn't bother.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or this is a different line - got a bit confused

Copy link
Copy Markdown
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's fix some of the things @marek1840 suggested, but other than that it should be good to merge.

Copy link
Copy Markdown
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments, otherwise this PR is ready to go!

scalac: ScalacOptionsItem
): URLClassLoader = {
val pc = new Dependency(
val scala_version = ScalaVersions
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: in Scala we use camel case instead of snake case

Suggested change
val scala_version = ScalaVersions
val scalaVersion = ScalaVersions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

.dropVendorSuffix(info.getScalaVersion)
val pc = Dependency.of(
s"org.scalameta",
s"mtags_$scala_version",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to keep this as is. This is BTW the "mtags artifact name", not "mtags version"

Dependency.of("com.lihaoyi", "acyclic_2.12", "0.1.8"),
Dependency.of("com.lihaoyi", "scalaparse_2.12", "2.1.0"),
Dependency
.of("com.typesafe.akka", "akka-cluster_2.12", "2.5.19"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pro tip: if you want to avoid the line break here then you can extract the list into a variable in a higher scope like

val dependencies = List(
  ...
)

Scalafmt will always preserve the line break before dot .of(_) so you need to remove that manually if you want to put it back on a single line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

("com.typesafe.akka", "akka-cluster_2.12", "2.5.19"),
("com.typesafe.akka", "akka-stream_2.12", "2.5.19"),
("com.typesafe.akka", "akka-testkit_2.12", "2.5.19"),
("io.buoyant", s"linkerd-core_2.12", "1.4.3"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
("io.buoyant", s"linkerd-core_2.12", "1.4.3"),
("io.buoyant", "linkerd-core_2.12", "1.4.3"),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thank you @sswistun-vl ! Nice work, I'm glad to finally get rid of coursier-small ^^

@olafurpg olafurpg changed the title Replace coursier-small with coursier-interface to use the proper Coursier API Replace coursier-small with coursier-interface to use the prope… Nov 20, 2019
@olafurpg olafurpg merged commit 971c03c into scalameta:master Nov 20, 2019
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.

4 participants