Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build-tools/build-infra/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ rootProject.name = 'build-infra'

// Use project's version catalog for centralized dependency management
dependencyResolutionManagement {
versionCatalogs {
libs {
from(files("../../gradle/libs.versions.toml"))
}
versionCatalogs {
libs {
from(files("../../gradle/libs.versions.toml"))
}
}
}
5 changes: 4 additions & 1 deletion build-tools/missing-doclet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ java {
}

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ["--release", targetCompatibility.toString()]
options.compilerArgs += [
"--release",
targetCompatibility.toString()
]
options.encoding = "UTF-8"
}
8 changes: 4 additions & 4 deletions build-tools/missing-doclet/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ rootProject.name = "missing-doclet"

// Use project's version catalog for centralized dependency management
dependencyResolutionManagement {
versionCatalogs {
libs {
from(files("../../gradle/libs.versions.toml"))
}
versionCatalogs {
libs {
from(files("../../gradle/libs.versions.toml"))
}
}
}
18 changes: 12 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ version = {

// On a release explicitly set release version in one go:
// -Dversion.release=x.y.z

// Jenkins can just set just a suffix, overriding SNAPSHOT, e.g. using build id:
// -Dversion.suffix=jenkins123

String versionSuffix = propertyOrDefault('version.suffix', 'SNAPSHOT')
String v = propertyOrDefault('version.release', "${baseVersion}-${versionSuffix}")
if (v.endsWith("-")) {
Expand All @@ -73,7 +73,7 @@ allprojects {

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000"
options.compilerArgs << "-Xmaxerrs" << "1000"
}
}
}
Expand Down Expand Up @@ -110,8 +110,8 @@ ext {
logger.info("External tool '${name}' resolved to: ${resolved}")
return resolved
}
luceneBaseVersionProvider = project.provider {

luceneBaseVersionProvider = project.provider {
def luceneVersion = libs.versions.apache.lucene.get()
def m = (luceneVersion =~ /^\d+\.\d+\.\d+\b/)
if (!m) {
Expand All @@ -123,7 +123,13 @@ ext {
}

// For testing code
vectorIncubatorJavaVersions = [ JavaVersion.VERSION_21, JavaVersion.VERSION_22, JavaVersion.VERSION_23, JavaVersion.VERSION_24, JavaVersion.VERSION_25 ] as Set
vectorIncubatorJavaVersions = [
JavaVersion.VERSION_21,
JavaVersion.VERSION_22,
JavaVersion.VERSION_23,
JavaVersion.VERSION_24,
JavaVersion.VERSION_25
] as Set

// Use gradle flag in root project for further referencing
withUiModule = gradle.ext.withUiModule
Expand Down
5 changes: 5 additions & 0 deletions changelog/unreleased/spotlessGradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
title: Spotless/tidy now applies to gradle build files.
type: other # added, changed, fixed, deprecated, removed, dependency_update, security, other
authors:
- name: David Smiley

16 changes: 8 additions & 8 deletions gradle/conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
*/

configure(allprojects) {
tasks.register("tidy").configure {
description "Applies formatters and cleanups to sources."
group "verification"
}
tasks.register("tidy").configure {
description "Applies formatters and cleanups to sources."
group "verification"
}
}

// Locate script-relative resource folder. This is context-sensitive so pass
// the right buildscript (top-level).
configure(rootProject) {
ext {
scriptResources = { buildscript ->
return file(buildscript.sourceFile.absolutePath.replaceAll('.gradle$', ""))
}
ext {
scriptResources = { buildscript ->
return file(buildscript.sourceFile.absolutePath.replaceAll('.gradle$', ""))
}
}
}
64 changes: 35 additions & 29 deletions gradle/develocity.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,44 +21,50 @@ def isCIBuild = System.getenv().keySet().any { it ==~ /(?i)((JENKINS|HUDSON)(_\w
// https://docs.gradle.com/enterprise/gradle-plugin/

develocity {
server = "https://develocity.apache.org"
projectId = "solr"
server = "https://develocity.apache.org"
projectId = "solr"

buildScan {
uploadInBackground = !isCIBuild
buildScan {
uploadInBackground = !isCIBuild

publishing.onlyIf { it.authenticated }
obfuscation {
ipAddresses { addresses -> addresses.collect { address -> "0.0.0.0"} }
publishing.onlyIf { it.authenticated }
obfuscation {
ipAddresses { addresses ->
addresses.collect { address ->
"0.0.0.0"
}
}
}

tag("JDK" + System.getProperty("java.version").find(/\d+/)) // major version
value("Java Vendor", System.getProperty("java.vendor"))
value("Java Version", System.getProperty("java.version"))
tag("JDK" + System.getProperty("java.version").find(/\d+/)) // major version
value("Java Vendor", System.getProperty("java.vendor"))
value("Java Version", System.getProperty("java.version"))

// Jenkins job name, less redundant "Solr" parts
String jenkinsJobName = System.getenv("JOB_NAME")
if (jenkinsJobName) { // looks like "Solr/Solr-Smoketest-9.5"
tag(jenkinsJobName.replaceAll(/Solr\W/,"")) // like "Smoketest-9.5"
}
// Jenkins job name, less redundant "Solr" parts
String jenkinsJobName = System.getenv("JOB_NAME")
if (jenkinsJobName) {
// looks like "Solr/Solr-Smoketest-9.5"
tag(jenkinsJobName.replaceAll(/Solr\W/,"")) // like "Smoketest-9.5"
}

// https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if (System.getenv("GITHUB_BASE_REF")) { // only exists for PRs
tag("PR")
}
String ghWorkflowName = System.getenv("GITHUB_WORKFLOW")
if (ghWorkflowName) {
tag(ghWorkflowName)
}
// https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if (System.getenv("GITHUB_BASE_REF")) {
// only exists for PRs
tag("PR")
}
String ghWorkflowName = System.getenv("GITHUB_WORKFLOW")
if (ghWorkflowName) {
tag(ghWorkflowName)
}
}
}

buildCache {
local {
enabled = !isCIBuild
}
local {
enabled = !isCIBuild
}

remote(develocity.buildCache) {
enabled = false
}
remote(develocity.buildCache) {
enabled = false
}
}
18 changes: 9 additions & 9 deletions gradle/documentation/changes-to-html.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ChangesToHtmlTask extends DefaultTask {

@OutputDirectory
final DirectoryProperty targetDir = project.objects.directoryProperty()
.fileProvider(project.providers.provider { project.file("${project.docroot}/changes") })
.fileProvider(project.providers.provider { project.file("${project.docroot}/changes") })

@InputFile
def script
Expand All @@ -63,8 +63,8 @@ class ChangesToHtmlTask extends DefaultTask {

// Check if Python is available
if (!pythonExists()) {
logger.warn("WARNING: Python is not installed, skipping creating Changes.html")
return
logger.warn("WARNING: Python is not installed, skipping creating Changes.html")
return
}

def result = project.exec {
Expand All @@ -74,8 +74,8 @@ class ChangesToHtmlTask extends DefaultTask {
ignoreExitValue = true

args += [
script.toString(),
changesFile.toString()
script.toString(),
changesFile.toString()
]
}

Expand All @@ -101,11 +101,11 @@ class ChangesToHtmlTask extends DefaultTask {

def pythonExists() {
try {
def process = "python3 --version".execute()
process.waitFor()
return process.exitValue() == 0
def process = "python3 --version".execute()
process.waitFor()
return process.exitValue() == 0
} catch (Exception e) {
return false
return false
}
}
}
6 changes: 3 additions & 3 deletions gradle/documentation/documentation.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ configure(project(':solr:documentation')) {
prj.tasks.matching { it.name == 'renderSiteJavadoc' }
}
dependsOn 'changesToHtml','copyDocumentationAssets',
'markdownToHtml','createDocumentationIndex'
'markdownToHtml','createDocumentationIndex'
}

task copyDocumentationAssets(type: Copy) {
includeEmptyDirs = false
from(project.assets)
into project.docroot
}

assemble {
dependsOn documentation
}

configurations {
site
}

artifacts {
site project.docroot, {
builtBy documentation
Expand Down
32 changes: 19 additions & 13 deletions gradle/documentation/markdown.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ buildscript {
configure(project(':solr:documentation')) {
task markdownToHtml(type: Copy) {
dependsOn copyDocumentationAssets

filteringCharset = 'UTF-8'
includeEmptyDirs = false
into project.docroot
Expand Down Expand Up @@ -93,27 +93,31 @@ class MarkdownFilter extends FilterReader {
// converts it and provides result downstream as a StringReader
super(new StringReader(convert(reader.text)));
}

public static String convert(String markdownSource) {
// first replace LUCENE and SOLR issue numbers with a markdown link
markdownSource = markdownSource.replaceAll(/(?s)\b(LUCENE|SOLR)\-\d+\b/,
'[$0](https://issues.apache.org/jira/browse/$0)');
'[$0](https://issues.apache.org/jira/browse/$0)');

// convert the markdown
MutableDataSet options = new MutableDataSet();
options.setFrom(ParserEmulationProfile.MARKDOWN);
options.set(Parser.EXTENSIONS, [ AbbreviationExtension.create(), AutolinkExtension.create(), AttributesExtension.create() ]);
options.set(Parser.EXTENSIONS, [
AbbreviationExtension.create(),
AutolinkExtension.create(),
AttributesExtension.create()
]);
options.set(HtmlRenderer.RENDER_HEADER_ID, true);
options.set(HtmlRenderer.MAX_TRAILING_BLANK_LINES, 0);
Document parsed = Parser.builder(options).build().parse(markdownSource);

StringBuilder html = new StringBuilder('<html>\n<head>\n');
CharSequence title = parsed.getFirstChildAny(Heading.class)?.getText();
CharSequence title = parsed.getFirstChildAny(Heading.class)?.getText();
if (title != null) {
html.append('<title>').append(Escaping.escapeHtml(title, false)).append('</title>\n');
}
html.append('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n')
.append('</head>\n<body>\n');
.append('</head>\n<body>\n');
HtmlRenderer.builder(options).build().render(parsed, html);
html.append('</body>\n</html>\n');
return html;
Expand All @@ -132,19 +136,21 @@ class MarkdownTemplateTask extends DefaultTask {

@OutputFile
File outputFile

@Input
@Optional
final MapProperty<String,Object> binding = project.objects.mapProperty(String, Object)

/** adds a property "projectList" containing all subprojects with javadocs as markdown bullet list */
void withProjectList() {
binding.put('projectList', project.providers.provider{
def projects = productProject.subprojects.findAll{ it.tasks.findByName('renderSiteJavadoc')?.enabled }
.sort(false, Comparator.comparing{ (it.name != 'core') as Boolean }
.thenComparing(Comparator.comparing{ (! it.name.startsWith('solrj')) as Boolean })
.thenComparing(Comparator.comparing{ (it.name == 'test-framework') as Boolean })
.thenComparing(Comparator.comparing{ it.path }));
.sort(false, Comparator.comparing{
(it.name != 'core') as Boolean
}
.thenComparing(Comparator.comparing{ (! it.name.startsWith('solrj')) as Boolean })
.thenComparing(Comparator.comparing{ (it.name == 'test-framework') as Boolean })
.thenComparing(Comparator.comparing{ it.path }));
return projects.collect{ project ->
def text = "**[${project.relativeDocPath.replace('/','-')}](${project.relativeDocPath}/index.html):** ${project.description}"
if (project.name == 'core') {
Expand Down
Loading
Loading