Skip to content

Commit

Permalink
Fix link
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Nov 14, 2022
1 parent 17df88d commit 32dc3a0
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions buildSrc/src/main/kotlin/Relocation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ExternalModuleDependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.extra
import org.gradle.kotlin.dsl.invoke
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import java.io.File

Expand Down Expand Up @@ -161,17 +161,25 @@ fun KotlinDependencyHandler.relocateImplementation(
action: ExternalModuleDependency.() -> Unit = {}
): ExternalModuleDependency {
val dependency = implementation(relocatedDependency.notation) {
relocatedDependency.exclusionAction(this)
exclude(ExcludeProperties.`everything from kotlin`)
exclude(ExcludeProperties.`everything from kotlinx`)
action()

}
project.relocationFilters.add(
RelocationFilter(
dependency.group!!, dependency.name, relocatedDependency.packages.toList(), includeInRuntime = true,
)
)
project.addRelocationRuntime(dependency)
project.configurations.maybeCreate(SHADOW_RELOCATION_CONFIGURATION_NAME)
addDependencyTo(
project.dependencies,
SHADOW_RELOCATION_CONFIGURATION_NAME,
relocatedDependency.notation,
Action<ExternalModuleDependency> {
relocatedDependency.exclusionAction(this)
exclude(ExcludeProperties.`everything from kotlin`)
exclude(ExcludeProperties.`everything from kotlinx`)
action()
}
)
return dependency
}

Expand All @@ -192,22 +200,24 @@ fun DependencyHandler.relocateImplementation(
dependency.group!!, dependency.name, relocatedDependency.packages.toList(), includeInRuntime = true,
)
)
project.addRelocationRuntime(dependency)
project.configurations.maybeCreate(SHADOW_RELOCATION_CONFIGURATION_NAME)
addDependencyTo(
project.dependencies,
SHADOW_RELOCATION_CONFIGURATION_NAME,
relocatedDependency.notation,
Action<ExternalModuleDependency> {
relocatedDependency.exclusionAction(this)
exclude(ExcludeProperties.`everything from kotlin`)
exclude(ExcludeProperties.`everything from kotlinx`)
action(this)
}
)
return dependency
}


const val SHADOW_RELOCATION_CONFIGURATION_NAME = "shadowRelocation"

private fun Project.addRelocationRuntime(
dependency: Dependency,
) {
val relocate = configurations.maybeCreate(SHADOW_RELOCATION_CONFIGURATION_NAME)
dependencies {
relocate(dependency)
}
}


data class RelocationFilter(
val groupId: String,
Expand Down

0 comments on commit 32dc3a0

Please sign in to comment.