Skip to content

Commit

Permalink
Gradle build: cleanup of dependency resolution and consolidation of d…
Browse files Browse the repository at this point in the history
…ependency versions (apache#13484)
  • Loading branch information
dweiss authored Jun 17, 2024
1 parent 8f50976 commit dc28786
Show file tree
Hide file tree
Showing 72 changed files with 2,267 additions and 1,039 deletions.
42 changes: 31 additions & 11 deletions buildSrc/build.gradle → build-tools/build-infra/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,50 @@
* limitations under the License.
*/

repositories {
mavenCentral()
plugins {
id "java-gradle-plugin"
alias(deps.plugins.spotless) apply false
alias(deps.plugins.forbiddenapis) apply false
}

ext {
// Minimum Java version required to compile buildSrc.
minJavaVersion = JavaVersion.VERSION_21
repositories {
mavenCentral()
}

group = "org.apache"

// Make sure the build environment is consistent.
apply from: file('../gradle/validation/check-environment.gradle')
apply from: file('../../gradle/conventions.gradle')
apply from: file('../../gradle/validation/check-environment.gradle')

// Add spotless/ tidy.
tasks.register("checkJdkInternalsExportedToGradle") {}
apply from: file('../../gradle/validation/spotless.gradle')
apply from: file('../../gradle/validation/forbidden-apis.gradle')

// Load common buildSrc and script deps.
apply from: file("scriptDepVersions.gradle")
java {
sourceCompatibility = JavaVersion.toVersion(deps.versions.minJava.get())
targetCompatibility = JavaVersion.toVersion(deps.versions.minJava.get())
}

gradlePlugin {
automatedPublishing = false

plugins {
buildInfra {
id = 'lucene.build-infra'
implementationClass = 'org.apache.lucene.gradle.buildinfra.BuildInfraPlugin'
}
}
}

dependencies {
implementation gradleApi()
implementation localGroovy()

implementation "commons-codec:commons-codec:${scriptDepVersions['commons-codec']}"
implementation deps.commons.codec
}

if (!rootProject.hasJavaFlightRecorder) {
if (!hasJavaFlightRecorder) {
logger.warn('Module jdk.jfr is not available; skipping compilation of Java Flight Recorder support.')
tasks.named('compileJava').configure {
exclude('**/ProfileResults.java')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@
* limitations under the License.
*/

plugins {
id 'java-library'
}

version = "1.0.0-SNAPSHOT"
group = "org.apache.lucene.tools"
description = 'Doclet-based javadoc validation'

sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
rootProject.name = 'build-infra'

tasks.withType(JavaCompile) {
options.compilerArgs += ["--release", targetCompatibility.toString()]
options.encoding = "UTF-8"
dependencyResolutionManagement {
versionCatalogs {
deps {
from(files('../../versions.toml'))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@

package org.apache.lucene.gradle;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Locale;
import org.apache.commons.codec.digest.DigestUtils;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
Expand All @@ -39,16 +44,10 @@
import org.gradle.work.Incremental;
import org.gradle.work.InputChanges;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Locale;

public class Checksum extends DefaultTask {
private FileCollection files;
private File outputDir;
private Algorithm algorithm;
private Algorithm algorithm = Algorithm.SHA512;

public enum Algorithm {
MD5(new DigestUtils(DigestUtils.getMd5Digest())),
Expand Down Expand Up @@ -190,6 +189,8 @@ private FileCollection allPossibleChecksumFiles() {

private FileCollection filesFor(final Algorithm algo) {
return getProject()
.fileTree(getOutputDir(), files -> files.include("**/*." + algo.toString().toLowerCase(Locale.ROOT)));
.fileTree(
getOutputDir(),
files -> files.include("**/*." + algo.toString().toLowerCase(Locale.ROOT)));
}
}
Loading

0 comments on commit dc28786

Please sign in to comment.