dweiss commented on a change in pull request #1267: LUCENE-9201: Add missing javadocs check task URL: https://github.com/apache/lucene-solr/pull/1267#discussion_r382988638
########## File path: gradle/validation/missing-docs-check.gradle ########## @@ -0,0 +1,118 @@ +/* + * 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 + * + * http://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. + */ + +configure(rootProject) { + ext { + // too many classes to fix overall to just enable the above to be level="method" right now, + // but we can prevent the modules that don't have problems from getting any worse + methodLevels = [ + ':lucene:analysis:icu', + ':lucene:analysis:morfologik', + ':lucene:analysis:phonetic', + ':lucene:analysis:stempel', + ':lucene:classification', + ':lucene:demo', + ':lucene:expressions', + ':lucene:facet', + ':lucene:join', + ':lucene:memory', + ':lucene:suggest', + ':lucene:spatial3d', + ] + } +} + +allprojects { + plugins.withType(JavaPlugin) { + + // set the default check level for each project + def lv = { + if (project.path.startsWith(':solr')) 'package' // todo: add missing docs for all classes and bump this to level=class + else if (project.path in rootProject.methodLevels ) 'method' + else 'class' + } + + task checkMissingDocsDefault(type: CheckMissingDocsTask, dependsOn: 'javadoc') { + enabled = project.javadoc.destinationDir.exists() + dirs += [ project.javadoc.destinationDir.absolutePath ] + level = lv.call() + } + + task checkMissingDocs() { + group 'Verification' + description 'Check missing Javadocs' + + dependsOn checkMissingDocsDefault + } + + } +} + +configure(project(':lucene:core')) { + plugins.withType(JavaPlugin) { + + // too much to fix core/ for now, but enforce full javadocs for key packages + def checkedDirs = [ + "/org/apache/lucene/util/automaton", + "/org/apache/lucene/analysis", + "/org/apache/lucene/document", + "/org/apache/lucene/search/similarities", + "/org/apache/lucene/index", + "/org/apache/lucene/codecs" + ].collect { path -> "${project.javadoc.destinationDir.absolutePath}${path}" } + + task checkMissingDocsMethod(type: CheckMissingDocsTask, dependsOn: 'javadoc') { + dirs = checkedDirs + level = 'method' + } + + checkMissingDocs { + dependsOn checkMissingDocsDefault + dependsOn checkMissingDocsMethod + } + + } +} + +class CheckMissingDocsTask extends DefaultTask { + + @Input + List<String> dirs = [] + + @Input + String level = "none" + + def checkMissingJavadocs(String dir, String level) { + project.exec { Review comment: I buffered the output of python execution and rethrow it as a gradle exception. this way the output is displayed at the end of execution in a summary (instead of when it was executed during concurrent build). ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
