Skip to content

Commit

Permalink
Use tasks.register instead of task
Browse files Browse the repository at this point in the history
  • Loading branch information
malliaridis committed Feb 16, 2025
1 parent aae5452 commit 52b5ee4
Show file tree
Hide file tree
Showing 43 changed files with 154 additions and 143 deletions.
2 changes: 1 addition & 1 deletion gradle/documentation/changes-to-html.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def resources = scriptResources(buildscript)

configure(project(':solr:documentation')) {
task changesToHtml(type: ChangesToHtmlTask) {
tasks.register("changesToHtml", ChangesToHtmlTask) {
siteDir = resources
script = file("${resources}/changes2html.pl")
}
Expand Down
16 changes: 8 additions & 8 deletions gradle/documentation/documentation.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ configure(rootProject) {
solrRefguideUrl = project.propertyOrDefault('solr.refguide.url', "https://solr.apache.org/guide/solr/${refguideUrlVersion}")
}

task documentation() {
tasks.register("documentation") {
group = 'documentation'
description = 'Generate all documentation'

Expand All @@ -61,18 +61,18 @@ configure(project(':solr:documentation')) {
assets = file("src/assets")
}

task documentation() {
tasks.register("documentation") {
group = 'documentation'
description = "Generate ${project.name.capitalize()} documentation"

dependsOn project.parent.subprojects.collect { prj ->
prj.tasks.matching { it.name == 'renderSiteJavadoc' }
}
dependsOn 'changesToHtml','copyDocumentationAssets',
'markdownToHtml','createDocumentationIndex'
dependsOn 'changesToHtml', 'copyDocumentationAssets',
'markdownToHtml', 'createDocumentationIndex'
}

task copyDocumentationAssets(type: Copy) {
tasks.register("copyDocumentationAssets", Copy) {
includeEmptyDirs = false
from(project.assets)
into project.docroot
Expand All @@ -92,13 +92,13 @@ configure(project(':solr:documentation')) {
}
}

task documentationMinimal() {
tasks.register("documentationMinimal") {
group = 'documentation'
description = "Generate stub Solr documentation pointing to web page (that's part of Solr TGZ)"
dependsOn 'copyMiniDocumentationAssets', 'createMiniDocumentationIndex', 'copyChangesToHtmlForMiniSite'
}

task copyChangesToHtmlForMiniSite(type: Copy) {
tasks.register("copyChangesToHtmlForMiniSite", Copy) {
dependsOn 'copyDocumentationAssets'
dependsOn 'markdownToHtml'

Expand All @@ -108,7 +108,7 @@ configure(project(':solr:documentation')) {
dependsOn 'changesToHtml'
}

task copyMiniDocumentationAssets(type: Copy) {
tasks.register("copyMiniDocumentationAssets", Copy) {
includeEmptyDirs = false
from('src/assets')
into project.docrootMinimal
Expand Down
6 changes: 3 additions & 3 deletions gradle/documentation/markdown.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ buildscript {
}

configure(project(':solr:documentation')) {
task markdownToHtml(type: Copy) {
tasks.register("markdownToHtml", Copy) {
dependsOn copyDocumentationAssets

filteringCharset = 'UTF-8'
Expand All @@ -60,7 +60,7 @@ configure(project(':solr:documentation')) {
}
}

task createDocumentationIndex(type: MarkdownTemplateTask) {
tasks.register("createDocumentationIndex", MarkdownTemplateTask) {
dependsOn markdownToHtml

outputFile = file("${project.docroot}/index.html")
Expand All @@ -74,7 +74,7 @@ configure(project(':solr:documentation')) {
withProjectList()
}

task createMiniDocumentationIndex(type: MarkdownTemplateTask) {
tasks.register("createMiniDocumentationIndex", MarkdownTemplateTask) {
outputFile = file("${project.docrootMinimal}/index.html")
templateFile = file("${project.markdownSrc}/online-link.template.md")

Expand Down
2 changes: 1 addition & 1 deletion gradle/documentation/pull-lucene-javadocs.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ configure(project(":solr:documentation")) {
}


task collectLuceneJavadocs() {
tasks.register("collectLuceneJavadocs") {
description "Collect and unpack javadoc artifacts from 'javadocs' configuration"

dependsOn configurations.javadocs
Expand Down
4 changes: 2 additions & 2 deletions gradle/documentation/render-javadoc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ allprojects {
dependsOn "renderJavadoc"
}

task renderJavadoc(type: RenderJavadocTask) {
tasks.register("renderJavadoc", RenderJavadocTask) {
description "Generates Javadoc API documentation for each module. This directly invokes javadoc tool."
group "documentation"

Expand All @@ -58,7 +58,7 @@ allprojects {
outputDir = project.javadoc.destinationDir
}

task renderSiteJavadoc(type: RenderJavadocTask) {
tasks.register("renderSiteJavadoc", RenderJavadocTask) {
description "Generates Javadoc API documentation for the site (relative links)."
group "documentation"

Expand Down
4 changes: 2 additions & 2 deletions gradle/generation/javacc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ configure(rootProject) {
javacc libs.javacc.javacc
}

task javacc() {
tasks.register("javacc") {
description "Regenerate sources for corresponding javacc grammar files."
group "generation"

Expand Down Expand Up @@ -91,7 +91,7 @@ import org.apache.lucene.queryparser.charstream.CharStream;'''.trim())
}

configure(project(":solr:core")) {
task javacc(type: JavaCCTask) {
tasks.register("javacc", JavaCCTask) {
description "Regenerate Solr query parser"
group "generation"

Expand Down
4 changes: 2 additions & 2 deletions gradle/generation/local-settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def hasDefaults = rootProject.file("gradle.properties").exists()
configure(rootProject) {
// Add a task verifying that gradle process has access to JVM internals.
// this is occasionally needed for certain tasks.
task checkJdkInternalsExportedToGradle() {
tasks.register("checkJdkInternalsExportedToGradle") {
doFirst {
def jdkCompilerModule = ModuleLayer.boot().findModule("jdk.compiler").orElseThrow()
def gradleModule = getClass().module
Expand All @@ -47,6 +47,6 @@ configure(rootProject) {
}
}

task localSettings() {
tasks.register("localSettings") {
// This is just a placeholder until all references to the localSettings task are removed #SOLR-16641
}
2 changes: 1 addition & 1 deletion gradle/hacks/wipe-temp.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {
plugins.withType(JavaPlugin).configureEach {
def temps = []

task wipeTaskTemp() {
tasks.register("wipeTaskTemp") {
doLast {
temps.each { temp ->
project.delete fileTree(temp).matching {
Expand Down
4 changes: 2 additions & 2 deletions gradle/help.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ configure(rootProject) {
]

helpFiles.each { section, path, sectionInfo ->
task "help${section}" {
tasks.register("help${section}") {
group = 'Help (developer guides and hints)'
description = sectionInfo
doFirst {
Expand All @@ -57,7 +57,7 @@ configure(rootProject) {
}
}

task allHelpFilesExit() {
tasks.register("allHelpFilesExit") {
doFirst {
helpFiles.each { section, path, sectionInfo ->
if (!rootProject.file(path).exists()) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/lucene-dev/lucene-dev-repo-composite.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if (luceneDevRepo != null) {
// important to have the names match.
name = 'lucene-root'
dependencySubstitution {
all { DependencySubstitution dependency ->
configureEach { DependencySubstitution dependency ->
if (dependency.requested instanceof ModuleComponentSelector) {
def moduleSelector = (ModuleComponentSelector) dependency.requested
if (moduleSelector.group == "org.apache.lucene" && moduleSelector.version == luceneVersion) {
Expand Down
8 changes: 5 additions & 3 deletions gradle/maven/defaults-maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ configure(subprojects.findAll { it.path in rootProject.published }) { prj ->
}

plugins.withType(JavaPlugin).configureEach {
task sourcesJar(type: Jar, dependsOn: classes) {
tasks.register("sourcesJar", Jar) {
dependsOn classes
archiveClassifier = 'sources'
from sourceSets.main.allJava
}

task javadocJar(type: Jar, dependsOn: javadoc) {
tasks.register("javadocJar", Jar) {
dependsOn javadoc
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

// Add aliases of convention tasks with shorter names.
task mavenToApacheSnapshots() {
tasks.register("mavenToApacheSnapshots") {
group "Publishing"
description "Publish Maven JARs and POMs to Apache Snapshots repository: ${apacheNexusSnapshots}"

Expand Down
6 changes: 3 additions & 3 deletions gradle/maven/maven-local.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ configure(rootProject) {
mavenLocalDir = file("${buildDir}/maven-local")
}

task mavenToLocalFolder() {
tasks.register("mavenToLocalFolder") {
group "Publishing"
description "Publish Maven JARs and POMs locally to " + mavenLocalDir

Expand All @@ -33,12 +33,12 @@ configure(rootProject) {
}
}

task mavenToLocalRepo() {
tasks.register("mavenToLocalRepo") {
group "Publishing"
description "Publish Maven JARs and POMs to current user's local maven repository."
}

task mavenLocalClean(type: Delete) {
tasks.register("mavenLocalClean", Delete) {
delete mavenLocalDir
}

Expand Down
6 changes: 3 additions & 3 deletions gradle/solr/packaging.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ configure(allprojects.findAll {project -> project.path.startsWith(":solr:modules
}

// An aggregate that configures lib and test-lib in a temporary location.
task assemblePackaging(type: Sync) {
tasks.register("assemblePackaging", Sync) {
from "README.md"

from (tasks.jar, {
Expand All @@ -94,7 +94,7 @@ configure(allprojects.findAll {project -> project.path.startsWith(":solr:modules
into deps
}

task syncLib(type: Sync) {
tasks.register("syncLib", Sync) {
dependsOn assemblePackaging

from(file("${deps}/lib"), {
Expand All @@ -103,7 +103,7 @@ configure(allprojects.findAll {project -> project.path.startsWith(":solr:modules
into file("${projectDir}/lib")
}

task syncTestLib(type: Sync) {
tasks.register("syncTestLib", Sync) {
// From test runtime classpath exclude:
// 1) project dependencies (and their dependencies)
// 2) runtime dependencies
Expand Down
2 changes: 1 addition & 1 deletion gradle/testing/alternative-jdk-support.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ JvmMetadataDetector jvmDetector = project.services.get(JvmMetadataDetector)

if (jvmGradle != jvmCurrent) {
configure(rootProject) {
task altJvmWarning() {
tasks.register("altJvmWarning") {
doFirst {

def jvmInfo = { JavaInfo javaInfo ->
Expand Down
6 changes: 3 additions & 3 deletions gradle/testing/beasting.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if (beastingMode) {

allprojects {
plugins.withType(JavaPlugin).configureEach {
task beast(type: BeastTask) {
tasks.register("beast", BeastTask) {
description "Run a test suite (or a set of tests) many times over (duplicate 'test' task)."
group "Verification"
}
Expand All @@ -56,7 +56,7 @@ if (beastingMode) {
// the test filter will be applied by the beast task once it is received from
// command line.
def subtasks = (1..dups).collect { value ->
return tasks.create(name: "test_${value}", type: Test, {
return tasks.register("test_${value}", Test) {
failFast = true
doFirst {
// If there is a global root seed, use it (all duplicated tasks will run
Expand All @@ -66,7 +66,7 @@ if (beastingMode) {
String.format("%08X", new Random(rootProject.rootSeedLong + value).nextLong()))
}
}
})
}
}

beast.dependsOn subtasks
Expand Down
6 changes: 3 additions & 3 deletions gradle/testing/randomization.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ configure(rootProject) {
projectSeedLong = rootSeedLong ^ project.path.hashCode()
}

task randomizationInfo() {
tasks.register("randomizationInfo") {
doFirst {
logger.lifecycle("Running tests with randomization seed: tests.seed=${rootSeed}")
}
Expand Down Expand Up @@ -173,7 +173,7 @@ allprojects {
}

// Append resolved test properties to the test task.
tasks.withType(Test) { task ->
tasks.withType(Test).configureEach { task ->
// TODO: we could remove some options that are only relevant to the build environment
// and not the test JVM itself.
systemProperties testOptionsResolved
Expand Down Expand Up @@ -233,7 +233,7 @@ allprojects {
// and descriptions.
allprojects {
plugins.withType(JavaPlugin).configureEach {
task testOpts() {
tasks.register("testOpts") {
group = 'Help (developer guides and hints)'
description = "Display values of randomization settings for a given seed"

Expand Down
6 changes: 4 additions & 2 deletions gradle/validation/check-broken-links.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

configure(rootProject) {
task checkBrokenLinks {
tasks.register("checkBrokenLinks") {
group 'Verification'
description 'Check broken links in the entire documentation'

Expand All @@ -25,7 +25,9 @@ configure(rootProject) {
}

configure(project(':solr:documentation')) {
task checkBrokenLinks(type: CheckBrokenLinksTask, 'dependsOn': 'documentation')
tasks.register("checkBrokenLinks", CheckBrokenLinksTask) {
dependsOn 'documentation'
}
check.dependsOn checkBrokenLinks
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/validation/ecj-lint.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ allprojects {
})
}

task ecjLint() {
tasks.register("ecjLint") {
description "Lint Java sources using ECJ."
group "Verification"

Expand Down
2 changes: 1 addition & 1 deletion gradle/validation/error-prone.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (!propertyOrDefault("validation.errorprone", isCIBuild).asBoolean()) {

if (skipReason) {
configure(rootProject) {
task errorProneSkipped() {
tasks.register("errorProneSkipped") {
doFirst {
logger.warn("WARNING: errorprone disabled (${skipReason})")
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/validation/git-status.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildscript {
}

configure(rootProject) {
task gitStatus() {
tasks.register("gitStatus") {
doFirst {
try {
def repository = new FileRepositoryBuilder()
Expand All @@ -61,7 +61,7 @@ configure(rootProject) {
}

// Verify git working copy does not have any unstaged modified files.
task checkWorkingCopyClean() {
tasks.register("checkWorkingCopyClean") {
dependsOn gitStatus
doFirst {
def status = rootProject.ext.gitStatus
Expand Down
2 changes: 1 addition & 1 deletion gradle/validation/gradlew-scripts-tweaked.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets
// don't fork a daemon subprocess on the initial run.

configure(rootProject) {
task gradlewScriptsTweaked() { task ->
tasks.register("gradlewScriptsTweaked") { task ->
def scripts = [
file("gradlew"),
file("gradlew.bat")
Expand Down
Loading

0 comments on commit 52b5ee4

Please sign in to comment.