question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warn about scala binary version suffix on dependencies

See original GitHub issue

The @@dependency directive renders sbt/Maven/Gradle/… snippets to easily copy paste a library dependency on the users build code.

The dependencies usually include a scala.binary.version suffix which can lead users unfamiliar with the scala ecosystem to mixing artifacts such as akka-actor_2.13 and akka-testkit_2.12 which leads to obscure errors (e.g. noclassdeffounderror scala/serializable).

The @@dependency could, instead, not set the scala.binary.version to a given value and use a build-specific placeholder (e.g. Maven property) with a small comment similar to the support to symbol/value in:

@@dependency [Maven,sbt,Gradle] {
  group=com.typesafe.akka
  artifact=akka-stream-kafka-testkit_$scala.binary.version$
  version=$project.version$
  scope=test
  symbol2=AkkaVersion
  value2="$akka.version$"
  group2=com.typesafe.akka
  artifact2=akka-stream-testkit_$scala.binary.version$
  version2=AkkaVersion
  scope2=test
}

rendering as

    <properties>
      <akka.version>2.5.23</akka.version>
    </properties>
    <dependency>
      <groupId>com.typesafe.akka</groupId>
      <artifactId>akka-stream-kafka-testkit_2.12</artifactId>
      <version>2.0.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.typesafe.akka</groupId>
      <artifactId>akka-stream-testkit_2.12</artifactId>
      <version>${akka.version}</version>
      <scope>test</scope>
    </dependency>

But such that any paradox user gets the symbol/value usage out fo the box (instead fo copy/pasting it every single time).

This came up during a gitter discussion.

So, a paradox user simply adding:

@@dependency [Maven,sbt,Gradle] {
  group=com.typesafe.akka
  artifact=akka-stream-kafka-testkit_$scala.binary.version$
  version=$project.version$
  scope=test
}

would get the following maven snippet for free:

    <properties>
      <scala.binary.version>2.5.23</scala.binary.version>
    </properties>
    <dependency>
      <groupId>com.typesafe.akka</groupId>
      <artifactId>akka-stream-kafka-testkit_${scala.binary.version}</artifactId>
      <version>2.0.2</version>
      <scope>test</scope>
    </dependency>

Optionally with a comment:

    <properties>
      <!-- All your artifacts must be compiled to the same scala.binary.version  (TODO: adda  link here to some relevant documentation in scala-lang.org ?)-->
      <scala.binary.version>2.5.23</scala.binary.version>
    </properties>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ennrucommented, Apr 15, 2020

I looked into this. My plan would be to enable this automatically as soon as an artefact name uses $scala.binary.version$.

0reactions
ennrucommented, Apr 16, 2020

Implemented with #429

Read more comments on GitHub >

github_iconTop Results From Across the Web

sbt - How to force Scala to use a different library version?
The way to exclude specific transitive dependency is this: Run sbt evicted to figure out which of the project dependencies is pulling in...
Read more >
Binary versions in the Scala 3.x era #10244 - GitHub
The real question is: given a full version (e.g., 2.13.3 ), what is the binary suffix that I need to use to resolve...
Read more >
Question about Scala 3/2.13 library compat mode and SBT ...
I guess I thought that was the point of the 2.13 v 3.0 binary compatibility…that they would be interchangeable at runtime. Now, obviously...
Read more >
sbt Reference Manual — Cross-building
Different versions of Scala can be binary incompatible, despite maintaining source compatibility. This page describes how to use sbt to build and publish ......
Read more >
Binary version, binary compatibility and cross versioning
Being Scala compiler hacker I mostly understand binary compatibility ... This means that the cross-version suffixes for Scala versions 2.10 and earlier are ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found