如何使Scala 2.12.11代码在Scala 2.13.2中运行?

Currently in my BuildSettings.scala file I am using crossScalaVersion := Seq("2.12.11", "2.13.2"), and my scalaVersion := "2.13.2", Now when I do sbt compile, it compiles with 2.13.2 correctly without any issue. Now when I do + compile, first it compiles with 2.12.11, then with 2.13.2 and fails here. Now the reason why its failing with 2.13.2 on + compile is because I have some collection libraries and some other libraries which are supported in only 2.12.11 and not in 2.13.2, e.g if we look at this piece of code:

package com.abc.models.common.implicits
import scala.collection.TraversableLike
trait TraversableExtension {
  implicit class traversableExtension[A, B](iterable: TraversableLike[A, B]) {
    def headOrError(message: String): A = {
      iterable.headOption.getOrElse(throw new Exception(message))
    }
  }
}

TraversableLike doesn't exist anymore in 2.13.2, also in some other files I face other issues for which classes are not supported in 2.13.2 anymore. I can update the code according to 2.13.2 standards and support libraries, whatever is alternative to above collection etc. But then + compile fails, i.e compilation with 2.12.11 fails, as those libraries won't exist in 2.12.11.

如何使它们同时适用于两个版本?