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

name.remal.gradle_plugins.toolkit.build_logic.checkstyle.gradle Maven / Gradle / Ivy

There is a newer version: 0.64.11
Show newest version
import static org.gradle.api.artifacts.ArtifactRepositoryContainer.MAVEN_CENTRAL_URL
import static org.gradle.language.base.plugins.LifecycleBasePlugin.VERIFICATION_GROUP

allprojects {
    apply plugin: 'checkstyle'

    dependencies {
        constraints {
            checkstyle 'com.puppycrawl.tools:checkstyle:10.18.1'
        }
    }

    configurations.checkstyle.with { Configuration conf ->
        conf.extendsFrom = conf.extendsFrom.findAll { it.name != 'projectDependencyConstraints' }
    }

    configurations.checkstyle {
        resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
            select("com.google.guava:guava:0")
        }
    }
    
    checkstyle {
        ignoreFailures = false
        configFile = project.file("${project.rootProjectDir}/checkstyle.xml")

        toolVersion = project.configurations.checkstyle
            .allDependencyConstraints
            .matching { it.group == 'com.puppycrawl.tools' && it.name == 'checkstyle' }
            .matching { it.version != null && !it.version.isEmpty() }
            .first()
            .version
    }

    tasks.register('allCheckstyle') {
        group = VERIFICATION_GROUP
        dependsOn(project.provider { project.sourceSets.collect { SourceSet sourceSet -> sourceSet.getTaskName('checkstyle', null) } })
    }

    pluginManager.withPlugin('java') {
        URI mavenCentralUri = project.uri(MAVEN_CENTRAL_URL)
        repositories.withType(MavenArtifactRepository)
            .matching { MavenArtifactRepository repo -> repo.url.scheme != 'file' && repo.url != mavenCentralUri }
            .configureEach { MavenArtifactRepository repo ->
                repo.content { RepositoryContentDescriptor content ->
                    configurations.configureEach { Configuration conf ->
                        if (startWithWord(conf.name, 'checkstyle')) {
                            content.notForConfigurations(conf.name)
                        }
                    }
                }
            }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy