@@ -35,7 +35,7 @@ abstract class CommonSurfPlugin<E : CommonSurfExtension>(
3535 " com.google.devtools.ksp"
3636 )
3737
38- private val relocations = mutableMapOf< String , String >()
38+ private val relocations = mutableListOf< Relocation >()
3939 private val dependencyDependentRelocations = mutableMapOf<String , MutableMap <String , String >>()
4040
4141 init {
@@ -70,7 +70,15 @@ abstract class CommonSurfPlugin<E : CommonSurfExtension>(
7070 }
7171
7272 protected infix fun String.relocatesTo (to : String ) {
73- relocations[this ] = to
73+ relocations + = Relocation (this , to)
74+ }
75+
76+ protected fun relocatePackage (
77+ from : String ,
78+ to : String ,
79+ excludes : List <String > = emptyList(),
80+ ) {
81+ relocations + = Relocation (from, to, excludes)
7482 }
7583
7684 fun addRelocationsForDependency (
@@ -116,8 +124,13 @@ abstract class CommonSurfPlugin<E : CommonSurfExtension>(
116124
117125 private fun Project.configure () {
118126 tasks.withType<ShadowJar > {
119- relocations.forEach { (from, to) ->
120- relocate(from, " ${Constants .RELOCATION_PREFIX } .$to " )
127+ relocations.forEach { relocation ->
128+ relocate(
129+ relocation.from,
130+ " ${Constants .RELOCATION_PREFIX } .${relocation.to} "
131+ ) {
132+ relocation.excludes.forEach { exclude(it) }
133+ }
121134 }
122135 }
123136
@@ -285,4 +298,10 @@ abstract class CommonSurfPlugin<E : CommonSurfExtension>(
285298
286299 protected open fun Project.afterEvaluated0 (extension : E ) {
287300 }
301+
302+ private data class Relocation (
303+ val from : String ,
304+ val to : String ,
305+ val excludes : List <String > = emptyList(),
306+ )
288307}
0 commit comments