name.remal.gradle_plugins.toolkit.build_logic.base-package.gradle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of build-logic Show documentation
Show all versions of build-logic Show documentation
Remal Gradle plugins: toolkit: build-logic
if (project.isBuildSrcProject) return
allprojects {
tasks.withType(AbstractCompile).configureEach {
doLast {
String baseJavaPackage = project.calculateBaseJavaPackage()
String classFilePrefix = baseJavaPackage.replace('.', '/')
project.files(it.destinationDirectory).asFileTree
.matching { include('**/*.class') }
.matching { exclude("${classFilePrefix}/**/*.class") }
.visit { FileVisitDetails details ->
if (details.directory) return
String relativePath = details.relativePath.toString()
String className = relativePath.replaceFirst(/\.class$/, '').replace('/', '.')
throw new GradleException(
"Class name doesn't start with base Java package '${baseJavaPackage}': ${className}"
)
}
}
}
}