I am considering building a small tool for running different releases of the same project.
So far, i can import the project, and can even import both versions without compilation failures.
name := "diffing-tool"
val sparkVersion = "3.1.2"
resolvers += Resolver.publishMavenLocal
resolvers += Resolver.defaultLocal
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % sparkVersion,
"org.apache.spark" %% "spark-sql" % sparkVersion,
"com.foo" %% "bar" % "1.0",
"com.foo" %% "bar" % "1.1"
)
My code can compile and run the following code
object Hello extends App {
println("Hello world")
val fromJar1 = com.foo.bar.Run.main()
val fromJar2 = com.foo.bar.Run.main()
def diff(fromJar1: Any, fromJar2: Any) = {
println("Hello world")
}
diff(fromJar1, fromJar2)
}
However, I do not know a good way to rename the packages/artifacts such that the code can refer to each version of the code separately.
Ideas of what this would look like include
- the use of shading in the
build.sbt
file (which is usually used for dependencies of dependencies, and I have not yet figured out what to do in my current use case -- also, i would like to avoidsbt assembly
if possible which is coupled with shading if i am not mistaken). ill need detailed instructions on how to set this up. - Another approach is, at runtime, to use
reflection
, theClassLoader
, or perhaps something from thesbt.librarymanagement
package, to get a separate reference to each artifact. Will need detailed instructions on how to set this up. - Other ideas are very welcome.
Aucun commentaire:
Enregistrer un commentaire