name.remal.gradle_plugins.toolkit.build_logic.classes-relocation.gradle Maven / Gradle / Ivy
if (project.isBuildSrcProject) return
allprojects {
pluginManager.withPlugin('name.remal.classes-relocation') {
dependencies {
excludeFromForcedClassesRelocation 'com.google.code.findbugs:jsr305'
excludeFromForcedClassesRelocation 'org.jetbrains:annotations'
}
classesRelocation {
relocatedClassesPackageName = "${project.calculateBaseJavaPackage()}.internal._relocated"
}
List relocationConfNames = [
'relocateClasses',
'excludeFromClassesRelocation',
'excludeFromForcedClassesRelocation',
]
tasks.withType(AbstractCompile).configureEach { AbstractCompile task ->
task.inputs.property('relocatedClassesPackageName', classesRelocation.relocatedClassesPackageName)
relocationConfNames.forEach { relocationConfName ->
task.dependsOn(configurations.named(relocationConfName))
task.inputs.files(configurations.named(relocationConfName))
.optional()
.withPropertyName("configuration-$relocationConfName")
}
}
configurations.matching { relocationConfNames.contains(it.name) }.configureEach { Configuration conf ->
conf.canBeConsumed = false
conf.attributes {
attribute(
Usage.USAGE_ATTRIBUTE,
objects.named(Usage.class, Usage.JAVA_RUNTIME)
)
attribute(
Category.CATEGORY_ATTRIBUTE,
objects.named(Category.class, Category.LIBRARY)
)
}
}
}
}