All Downloads are FREE. Search and download functionalities are using the official Maven repository.

name.remal.gradle_plugins.toolkit.build_logic.base-package.gradle Maven / Gradle / Ivy

There is a newer version: 0.68.0
Show newest version
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}"
                    )
                }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy