Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In SBT, can one automatically name-mangle privately used packages?

Consider the common case of using a specific versioned jar to implement a method, but not exposing any types from that jar in the public or protected API (only in method signatures of private methods).

Now what I want is an automatic compile-time linking of this code by name-mangling the original package name and replacing it in the generated code within SBT (again: I want to add a plugin to SBT or a setting in the build.sbt that does this on every sbt compile).

The goal of this is to avoid classpath errors with multiple possibly incompatible versions of a classes with the same package/class name. Note: in the situation I describe above, inlining or this name-mangling should always work and allow one to side-step version-hell (at the cost of larger jars).

like image 903
Oscar Boykin Avatar asked Dec 31 '12 18:12

Oscar Boykin


1 Answers

This sounds like the sort of thing that ProGuard would be able to do. There is an SBT ProGuard plugin but it doesn't appear to be actively maintained.

If I were tackling this problem, personally speaking I would look to a custom classloader for a solution rather than name mangling.

like image 85
Paul Butcher Avatar answered Oct 26 '22 17:10

Paul Butcher