• Stars
    star
    443
  • Rank 94,627 (Top 2 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created almost 12 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tool for catching binary incompatibility in Scala

MiMa

MiMa (for "Migration Manager") is a tool for identifying binary incompatibilities in Scala libraries.

It's pronounced MEE-ma.

What it is?

MiMa can report binary modifications that may cause the JVM to throw a java.lang.LinkageError (or one of its subtypes, like AbstractMethodError) at runtime. Linkage errors are usually the consequence of modifications in classes/members signature.

MiMa compares all classfiles of two released libraries and reports all source of incompatibilities that may lead to a linkage error. MiMa provides you, the library maintainer, with a tool that can greatly automate and simplify the process of ensuring the release-to-release binary compatibility of your libraries.

A key aspect of MiMa to be aware of is that it only looks for syntactic binary incompatibilities. The semantic binary incompatibilities (such as adding or removing a method invocation) are not considered. This is a pragmatic approach as it is up to you, the library maintainer, to make sure that no semantic changes have occurred between two binary compatible releases. If a semantic change occurred, then you should make sure to provide this information as part of the new release's change list.

In addition, it is worth mentioning that binary compatibility does not imply source compatibility, i.e., some of the changes that are considered compatible at the bytecode level may still break a codebase that depends on it. Interestingly, this is not an issue intrinsic to the Scala language. In the Java language binary compatibility does not imply source compatibility as well. MiMa focuses on binary compatibility and currently provides no insight into source compatibility.

See also: TASTy-MiMa

For Scala 3, in addition to binary compatible, TASTy compatibility becomes increasingly important. Another tool, TASTy-MiMa, is designed to automatically check TASTy compatibility in much the same way that MiMa checks binary compatibility.

Keep in mind that TASTy-MiMa is still young, as of early 2023. It is likely to contain bugs.

Usage

SBT

MiMa's sbt plugin supports sbt 1.x only. (Use v0.3.0 for sbt 0.13.x.)

To use it add the following to your project/plugins.sbt file:

addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "<version>")

Add the following to your build.sbt file:

mimaPreviousArtifacts := Set("com.example" %% "my-library" % "<version>")

and run mimaReportBinaryIssues to see something like the following:

[info] Found 4 potential binary incompatibilities
[error]  * method rollbackTransactionResource()resource.Resource in object resource.Resource does not have a   correspondent in new version
[error]  * method now()scala.util.continuations.ControlContext in trait resource.ManagedResourceOperations does not    have a correspondent in old version
[error]  * abstract method now()scala.util.continuations.ControlContext in interface resource.ManagedResource does not have a correspondent in old version
[error]  * method rollbackTransactionResource()resource.Resource in trait resource.MediumPriorityResourceImplicits does not have a correspondent in new version
[error] {file:/home/jsuereth/project/personal/scala-arm/}scala-arm/*:mima-report-binary-issues: Binary compatibility check failed!
[error] Total time: 15 s, completed May 18, 2012 11:32:29 AM

Mill

A MiMa plugin for Mill is maintained at lolgab/mill-mima.

To use it add the following to your build.sc:

import $ivy.`com.github.lolgab::mill-mima::x.y.z`
import com.github.lolgab.mill.mima._

Please check this page for further information.

Filtering binary incompatibilities

When MiMa reports a binary incompatibility that you consider acceptable, such as a change in an internal package, you need to use the mimaBinaryIssueFilters setting to filter it out and get mimaReportBinaryIssues to pass, like so:

import com.typesafe.tools.mima.core._

mimaBinaryIssueFilters ++= Seq(
  ProblemFilters.exclude[MissingClassProblem]("com.example.mylibrary.internal.Foo"),
)

You may also use wildcards in the package and/or the top Problem parent type for such situations:

mimaBinaryIssueFilters ++= Seq(
  ProblemFilters.exclude[Problem]("com.example.mylibrary.internal.*"),
)

IncompatibleSignatureProblem

Most MiMa checks (DirectMissingMethod, IncompatibleResultType, IncompatibleMethType, etc) are against the "method descriptor", which is the "raw" type signature, without any information about generic parameters.

The IncompatibleSignature check compares the Signature, which includes the full signature including generic parameters. This can catch real incompatibilities, but also sometimes triggers for a change in generics that would not in fact cause problems at run time. Notably, it will warn when updating your project to scala 2.12.9+ or 2.13.1+, see this issue for details.

You can opt-in to this check by setting:

import com.typesafe.tools.mima.plugin.MimaKeys._

ThisBuild / mimaReportSignatureProblems := true

Annotation-based exclusions

The mimaExcludeAnnotations setting can be used to tell MiMa to ignore classes, objects, and methods that have a particular annotation. Such an annotation might typically have "experimental" or "internal" in the name.

The setting is a Seq[String] containing fully qualified annotation names.

Example:

mimaExcludeAnnotations += "scala.annotation.experimental"

Caveat: mimaExcludeAnnotations is only implemented on Scala 3.

Setting different mimaPreviousArtifacts

From time to time you may need to set mimaPreviousArtifacts according to some conditions. For instance, if you have already ported your project to Scala 2.13 and set it up for cross-building to Scala 2.13, but still haven't cut a release, you may want to define mimaPreviousArtifacts according to the Scala version, with something like:

mimaPreviousArtifacts := {
  if (CrossVersion.partialVersion(scalaVersion.value) == Some((2, 13)))
    Set.empty
  else
    Set("com.example" %% "my-library" % "1.2.3")
}

or perhaps using some of sbt 1.2's new API:

import sbt.librarymanagement.{ SemanticSelector, VersionNumber }

mimaPreviousArtifacts := {
  if (VersionNumber(scalaVersion.value).matchesSemVer(SemanticSelector(">=2.13")))
    Set.empty
  else
    Set("com.example" %% "my-library" % "1.2.3")
}

Make mimaReportBinaryIssues not fail

The setting mimaFailOnNoPrevious defaults to true and will make mimaReportBinaryIssues fail if mimaPreviousArtifacts hasn't been set.

To make mimaReportBinaryIssues not fail you may want to do one of the following:

  • set mimaPreviousArtifacts on all the projects that should be checking their binary compatibility
  • avoid calling mimaPreviousArtifacts when binary compatibility checking isn't needed
  • set mimaFailOnNoPrevious := false on specific projects that want to opt-out (alternatively disablePlugins(MimaPlugin))
  • set ThisBuild / mimaFailOnNoPrevious := false, which disables it build-wide, effectively reverting back to the previous behaviour

Setting mimaPreviousArtifacts when name contains a "."

To refer to the project name in mimaPreviousArtifacts, use moduleName rather than name, like

mimaPreviousArtifacts := Set(organization.value %% moduleName.value % "0.1.0")

Unlike name, moduleName escapes characters like ., and is the name actually used by publish and publishLocal to publish your project. It's also the value your users should use when adding your project to their dependencies.

More Repositories

1

config

configuration library for JVM languages using HOCON files
Java
6,068
star
2

cloudflow

Cloudflow enables users to quickly develop, orchestrate, and operate distributed streaming applications on Kubernetes.
Scala
325
star
3

paradox

Markdown documentation
Scala
242
star
4

kafka-with-akka-streams-kafka-streams-tutorial

Code samples for the Lightbend tutorial on writing microservices with Akka Streams, Kafka Streams, and Kafka
Scala
211
star
5

kafka-streams-scala

Thin Scala wrapper around Kafka Streams Java API
Scala
191
star
6

model-serving-tutorial

Code and presentation for Strata Model Serving tutorial
Scala
70
star
7

kafka-streams-query

Library offering http based query on top of Kafka Streams Interactive Queries
Scala
69
star
8

akka-cluster-operator

Run Akka Cluster applications in Kubernetes.
Go
69
star
9

ssl-config

SSL configuration logic, extracted from Play's WS (for use in Akka et al).
Scala
66
star
10

reactive-streams-utils

Java
62
star
11

service-locator-dns

This project is deprecated
Scala
61
star
12

benchdb

A database and query tool for JMH benchmark results
Scala
59
star
13

genjavadoc

A compiler plugin for generating docโ€™able Java source from Scala source
Scala
55
star
14

kalix-jvm-sdk

Java and Scala SDKs for Kalix
Scala
55
star
15

kubeflow-recommender

Kubeflow example of machine learning/model serving
Jupyter Notebook
34
star
16

reactive-integration-examples

Examples for demonstrating the concept of Reactive Integration
Java
31
star
17

flink-k8s-operator

An example of building kubernetes operator (Flink) using Abstract operator's framework
Scala
26
star
18

reactive-cli

Scala
23
star
19

sbt-google-cloud-storage

A SBT resolver and publisher for Google Cloud Storage
Scala
22
star
20

kalix-javascript-sdk

JavaScript and TypeScript SDKs for Kalix
TypeScript
22
star
21

reactive-lib

Scala
18
star
22

sbt-reactive-app

Scala
18
star
23

mesos-spark-integration-tests

Mesos Integration Tests on Docker/Ec2
Shell
16
star
24

fdp-sample-applications

All sample applications for Fast Data Platform
Scala
15
star
25

pipelines-examples

Pipelines Example Applications
Scala
15
star
26

cinnamon-ui

Lightbend Cinnamon UI
15
star
27

spark-history-server-docker

Docker image for Spark history server on Kubernetes
Shell
14
star
28

microprofile-reactive-streams

Java
13
star
29

microprofile-reactive-messaging

Lightbend's implementation of the MicroProfile Reactive Messaging spec
Java
13
star
30

console-charts

Lightbend Console Helm Charts
Go
11
star
31

flink-operator

Helm Chart for lyft/flinkk8soperator
Smarty
11
star
32

sbt-whitesource

An sbt plugin to keep your WhiteSource project up to date
Scala
10
star
33

akka-grpc-ddata-shopping-cart

Scala
10
star
34

pipelines-model-serving

Implementation of Model serving in pipelines
Scala
8
star
35

akka-grpc-hands-on

Akka gRPC Hands-On
Scala
7
star
36

lb-demos

Demo applications showcasing the Lightbend Platform
Java
7
star
37

fdp-speculative-model-serving

Experimental implementation of speculative model serving
Scala
6
star
38

lightbend-markdown

Support for writing Lagom documentation in Markdown
Scala
5
star
39

vscode-kalix-tools

A VS Code extension for developers building stateful serverless applications on Kalix
TypeScript
5
star
40

sbt-bill-of-materials

Create 'Bill of Materials' (BOM) POM files from sbt for consumption in Maven and Gradle.
Scala
5
star
41

RSocketCloudflow

RSocket Ingress for cloudflow
Scala
5
star
42

sbt-paradox-project-info

A Paradox directive to include standardised project information into the generated documentation
Scala
5
star
43

sbt-paradox-apidoc

Apidoc (javadoc and scaladoc) support for the project documentation tool paradox
Scala
4
star
44

KnativeSamples

Collection of Knative examples using Scala
Scala
4
star
45

telemetry-samples

Lightbend Telemetry Samples
Java
4
star
46

spark-streaming-testbed

Set of applications to test the performances of Spark Streaming
Scala
4
star
47

fdp-dynamically-controlled-streams

Implementation of dynamically controlled streams patterns
Scala
4
star
48

cloudflow-contrib

Community Supported Cloudflow integrations
Scala
3
star
49

seldoncloudflow

Seldon Cloudflow Integration
Jupyter Notebook
3
star
50

cloudflow-docs

This repository hosts the cloudflow.io website as well as the Cloudflow documentation.
Shell
3
star
51

akka-operator-helm

Helm charts for Akka platform operator
Smarty
3
star
52

lightbend-orchestration-docs

Documentation for Lightbend Orchestration
Scala
3
star
53

sbt-paradox-dependencies

A Paradox directive to show module's transitive dependencies in the Paradox generated documentation
Scala
3
star
54

ML-metadata-tutorial

Presentation and exercise code for ML metadata tutorial
Scala
3
star
55

antora-ui-lightbend-cloud-theme

CSS
2
star
56

akka-projection-grpc-benchmark

2
star
57

deckhand

sbt companion for Kubernetes and OpenShift
Scala
2
star
58

kalix-value-entity.g8

This is an sbt template for setting up a Scala Kalix project with a Value Entity.
Scala
2
star
59

console-akka-cluster-example

Example for setting up an Akka Cluster app to run in Kubernetes with Lightbend Console monitoring
Scala
2
star
60

cloudflow-installer

Installation Scripts for Cloudflow
Shell
2
star
61

kalix-trial-scala-shoppingcart

Scala
2
star
62

kalix-action

Run Kalix CLI commands in GitHub workflows
Dockerfile
2
star
63

akka-cluster-orchestration-example

Scala
2
star
64

reactive-app-maven-plugin

Java
2
star
65

akka-cloud-platform-deploy

Provisioning solution for Akka Cloud Platform to supported cloud providers
TypeScript
2
star
66

homebrew-brew

Homebrew is a package manager for macOS which provides easy installation and update management of additional software. This Tap (repository) contains the Formulae for tools that Lightbend offers.
Ruby
2
star
67

play-openshift-example

Scala
1
star
68

reactive-sandbox

Shell
1
star
69

reactive-cli-build

Shell
1
star
70

sbt-paradox-lightbend-project-info

A flavour of sbt-paradox-project-info for Lightbend's use.
Scala
1
star
71

kalix-trial-java-shoppingcart

An e-commerce example for Kalix
Java
1
star
72

telemetry

Lightbend Telemetry - public
Scala
1
star
73

nfs

NFS server and PVC
Smarty
1
star
74

cloudflow-helm-charts

Cloudflow Helm repository
1
star
75

IBMIntegrationGluster

Gluster support for IBM integration
Shell
1
star
76

kalix-cicd-github-actions

Sample JS project using Github Actions CI/CD support for Kalix
JavaScript
1
star
77

monitoringsamples

Sample applications that can be used to test monitoring tools (Insight team)
Scala
1
star
78

flink-k8s-build

This is a simple project to build Flink image with Prometheus jar out of the "standard" Flink images
Shell
1
star
79

sbt-publish-rsync

An sbt plugin that adds rsync capabilities to your project
Scala
1
star
80

akkaserverless-cicd-github-actions

JavaScript
1
star
81

kalix-ws-loan-application-scala

Scala
1
star
82

akkaserverless-value-entity.g8

Template for an Akkaserverless project with a service backed by a value entity
Scala
1
star
83

homebrew-cloudstate

Homebrew tap for csctl - The Lightbend Cloudstate CLI
Ruby
1
star