matrei commented on code in PR #15686: URL: https://github.com/apache/grails-core/pull/15686#discussion_r3340139879
########## build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsViolationAggregationPlugin.groovy: ########## @@ -0,0 +1,501 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.grails.buildsrc + +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +import groovy.transform.CompileDynamic +import groovy.transform.CompileStatic + +import org.gradle.api.GradleException +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.file.Directory +import org.gradle.api.file.FileCollection +import org.gradle.api.logging.Logger +import org.gradle.api.logging.Logging +import org.gradle.api.plugins.AppliedPlugin +import org.gradle.api.plugins.quality.Checkstyle +import org.gradle.api.plugins.quality.CodeNarc +import org.gradle.api.plugins.quality.Pmd +import org.gradle.api.provider.Provider +import org.gradle.api.tasks.TaskProvider +import org.gradle.testing.jacoco.tasks.JacocoReport + +import com.github.spotbugs.snom.SpotBugsTask +import groovy.xml.XmlSlurper + +/** + * Root-only convention plugin that aggregates code-style violation XML reports and JaCoCo coverage + * CSV reports into human-readable Markdown files under build/reports/violations/. + * + * Apply this plugin to the root project only. Subprojects should apply + * grails-code-style and grails-jacoco individually. + * + * Tasks registered: + * aggregateStyleViolations — CodeNarc + Checkstyle only + * aggregateAnalysisViolations — PMD + SpotBugs only (requires opt-in properties) + * aggregateViolations — depends on both of the above + * aggregateJacocoCoverage — JaCoCo CSV → Markdown + */ +@CompileStatic +class GrailsViolationAggregationPlugin implements Plugin<Project> { + + private static final Logger LOGGER = Logging.getLogger(GrailsViolationAggregationPlugin) + + /** + * Comma-separated list of fully-qualified class-name prefixes to exclude from the aggregated + * JaCoCo coverage report. Configure via {@code -Pgrails.jacoco.aggregation.excludedClassPrefixes=...} + * or in {@code gradle.properties}. + * + * <p>Defaults to {@link #DEFAULT_JACOCO_EXCLUDED_CLASS_PREFIXES}: the Hibernate 7 support classes + * share fully-qualified names with their Hibernate 5 counterparts, and JaCoCo cannot aggregate + * coverage for two different classes with the same name (it fails with + * "Can't add different class with same name"). Excluding one variant keeps the aggregate valid. + */ + static final String JACOCO_EXCLUDED_CLASS_PREFIXES_PROPERTY = 'grails.jacoco.aggregation.excludedClassPrefixes' + + static final String DEFAULT_JACOCO_EXCLUDED_CLASS_PREFIXES = 'org.grails.orm.hibernate.support.hibernate7.' + + @Override + void apply(Project project) { + if (project != project.rootProject) { + throw new GradleException( + 'GrailsViolationAggregationPlugin must be applied to the root project only. ' + + 'Apply grails-code-style and grails-jacoco to subprojects instead.' + ) + } + + Provider<Directory> violationsDir = project.layout.buildDirectory.dir('reports/violations') Review Comment: There are more explicit types below. Lines 90-91, 104-106, 108, 134-136, 138, 165, 171, 178 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
