diff --git a/gradle/scripts/.gitrepo b/gradle/scripts/.gitrepo index 109d6379a..2a6724546 100644 --- a/gradle/scripts/.gitrepo +++ b/gradle/scripts/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/line/gradle-scripts.git branch = main - commit = ed4e32f6327760c009660d032a43a2eb1504c2c4 - parent = bc900cce0f63a5f3959a697c5c219e036192d4b8 - cmdver = 0.4.9 + commit = 164b0ab73666dc3d05456912aa93759bf312af52 + parent = b0011fd46b1114d5860ac58d48657babc78058b2 + cmdver = 0.4.6 method = merge diff --git a/gradle/scripts/README.md b/gradle/scripts/README.md index 5da3e8a56..fe3e6d35c 100644 --- a/gradle/scripts/README.md +++ b/gradle/scripts/README.md @@ -36,6 +36,7 @@ sensible defaults. By applying them, you can: - [Setting a Kotlin target version with the `kotlin(\\d+\\.\\d+)` flag](#setting-a-koltin-target-version-with-the-kotlindd-flag) - [Automatic module names](#automatic-module-names) - [Tagging conveniently with `release` task](#tagging-conveniently-with-release-task) +- [Using a Maven Central mirror](#using-a-maven-central-mirror) @@ -759,3 +760,25 @@ instructions after tagging: Note the `${tag}`, which is replaced with the tag name. See [Groovy `SimpleTemplateEngine`](http://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html#_simpletemplateengine) for the syntax. + +## Using a Maven Central mirror + +If your organization blocks direct access to Maven Central (e.g. for supply chain security), you can +redirect all Maven Central requests to an internal mirror by setting the `mavenCentralMirror` Gradle +property. + +Add to `~/.gradle/gradle.properties`: + +```properties +mavenCentralMirror=https://your-mirror.example.com/repository/maven-central/ +``` + +Or pass via the CLI: + +```bash +./gradlew build -PmavenCentralMirror=https://your-mirror.example.com/repository/maven-central/ +``` + +When set, the mirror URL replaces `mavenCentral()` in all repository declarations including +`settings.gradle`, `buildSrc`, and `buildscript` blocks of applied scripts. When unset, behavior +is identical to the default — fully backward compatible. diff --git a/gradle/scripts/lib/common-dependencies.gradle b/gradle/scripts/lib/common-dependencies.gradle index 6299ff39e..385fba1dd 100644 --- a/gradle/scripts/lib/common-dependencies.gradle +++ b/gradle/scripts/lib/common-dependencies.gradle @@ -4,7 +4,12 @@ import org.yaml.snakeyaml.Yaml buildscript { repositories { - mavenCentral() + def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull() + if (mavenCentralMirror) { + maven { url = mavenCentralMirror } + } else { + mavenCentral() + } gradlePluginPortal() } @@ -36,7 +41,12 @@ configure(dependencyManagementProject) { google() // Since we manage plugin versions here too. gradlePluginPortal() - mavenCentral() + def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull() + if (mavenCentralMirror) { + maven { url = mavenCentralMirror } + } else { + mavenCentral() + } } javaPlatform { diff --git a/gradle/scripts/lib/common-info.gradle b/gradle/scripts/lib/common-info.gradle index fd4b671c2..17aad54a9 100644 --- a/gradle/scripts/lib/common-info.gradle +++ b/gradle/scripts/lib/common-info.gradle @@ -4,8 +4,8 @@ rootProject.ext { projectName = project.findProperty('projectName') projectUrl = project.findProperty('projectUrl') projectDescription = project.findProperty('projectDescription')?: rootProject.name - authorName = project.findProperty('authorName')?: 'LINE Corporation' - authorEmail = project.findProperty('authorEmail')?: 'dl_oss_dev@linecorp.com' + authorName = project.findProperty('authorName')?: 'LY Corporation' + authorEmail = project.findProperty('authorEmail')?: 'dl_armeria@linecorp.com' authorUrl = project.findProperty('authorUrl')?: 'https://engineering.linecorp.com/en/' inceptionYear = project.findProperty('inceptionYear') licenseName = project.findProperty('licenseName') @@ -15,8 +15,8 @@ rootProject.ext { scmDeveloperConnection = project.findProperty('scmDeveloperConnection') copyrightFooter = '© Copyright ' + "${rootProject.ext.inceptionYear}–${LocalDateTime.now().year} " + - '' + rootProject.ext.authorName + '. ' + - 'All rights reserved.' + '' + rootProject.ext.authorName + '. ' + + 'All rights reserved.' googleAnalyticsId = rootProject.findProperty('googleAnalyticsId') } diff --git a/gradle/scripts/lib/common-publish.gradle b/gradle/scripts/lib/common-publish.gradle index 07d1f6b3c..6c7d36318 100644 --- a/gradle/scripts/lib/common-publish.gradle +++ b/gradle/scripts/lib/common-publish.gradle @@ -62,6 +62,8 @@ if (publishToStaging) { } } + clientTimeout.set(Duration.ofMinutes(30)) + transitionCheckOptions { maxRetries.set(100) delayBetween.set(Duration.ofSeconds(20)) diff --git a/gradle/scripts/lib/java-javadoc.gradle b/gradle/scripts/lib/java-javadoc.gradle index 9930904b8..74d0fce51 100644 --- a/gradle/scripts/lib/java-javadoc.gradle +++ b/gradle/scripts/lib/java-javadoc.gradle @@ -1,7 +1,6 @@ import groovy.json.JsonBuilder import groovy.json.JsonSlurper -import javax.inject.Inject import java.security.MessageDigest def offlineJavadoc = rootProject.hasProperty('offlineJavadoc') diff --git a/gradle/scripts/lib/java-rpc-proto.gradle b/gradle/scripts/lib/java-rpc-proto.gradle index 4187d08ef..761244be4 100644 --- a/gradle/scripts/lib/java-rpc-proto.gradle +++ b/gradle/scripts/lib/java-rpc-proto.gradle @@ -2,6 +2,10 @@ import org.gradle.internal.os.OperatingSystem buildscript { repositories { + def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull() + if (mavenCentralMirror) { + maven { url = mavenCentralMirror } + } gradlePluginPortal() } dependencies { diff --git a/gradle/scripts/lib/java-shade.gradle b/gradle/scripts/lib/java-shade.gradle index e9120d00e..3126310b7 100644 --- a/gradle/scripts/lib/java-shade.gradle +++ b/gradle/scripts/lib/java-shade.gradle @@ -5,6 +5,10 @@ import java.util.concurrent.atomic.AtomicInteger buildscript { repositories { + def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull() + if (mavenCentralMirror) { + maven { url = mavenCentralMirror } + } gradlePluginPortal() google() } @@ -14,9 +18,32 @@ buildscript { } } +def globalShadowExclusions = [] +if (rootProject.hasProperty('shadowExclusions')) { + def rawShadowExclusions = rootProject.findProperty("shadowExclusions") + if (!(rawShadowExclusions instanceof String)) { + throw new RuntimeException("Property 'shadowExclusions' must be a String but was: ${rawShadowExclusions.getClass().name}") + } + globalShadowExclusions = rawShadowExclusions.split(",") +} +subprojects { + ext { + shadowExclusions = globalShadowExclusions.collect() + } +} + def relocatedProjects = projectsWithFlags('java', 'relocate') def numConfiguredRelocatedProjects = new AtomicInteger() configure(relocatedProjects) { + + // per-dependency shade configuration + // while shade per-project shades all dependencies, shade per-dependency allows for finer control + def shadeConfig = project.configurations.create("shade") { + canBeResolved = true + canBeConsumed = false + } + project.configurations.api.extendsFrom(shadeConfig) + // Generate the shaded JARs. task shadedJar( type: ShadowJar, @@ -24,7 +51,11 @@ configure(relocatedProjects) { description: 'Builds the shaded main JAR.', dependsOn: tasks.classes) { - configureShadowTask(project, delegate, true) + def self = this + def delegate0 = delegate + project.afterEvaluate { + self.configureShadowTask(project, delegate0, true) + } archiveClassifier.set('shaded') // Exclude the legacy file listing. @@ -49,14 +80,6 @@ configure(relocatedProjects) { return false } - def shadowExclusions = [] - if (rootProject.hasProperty('shadowExclusions')) { - shadowExclusions = rootProject.findProperty('shadowExclusions').split(",") - } - shadowExclusions.each { - exclude it - } - // Set the 'Automatic-Module-Name' property in MANIFEST.MF. if (project.ext.automaticModuleName != null) { doFirst { @@ -92,7 +115,11 @@ configure(relocatedProjects) { description: 'Builds the shaded test JAR.', dependsOn: tasks.testClasses) { - configureShadowTask(project, delegate, false) + def self = this + def delegate0 = delegate + project.afterEvaluate { + self.configureShadowTask(project, delegate0, false) + } archiveBaseName.set("test-${tasks.jar.archiveBaseName.get()}-shaded") } @@ -335,9 +362,18 @@ private void configureShadowTask(Project project, ShadowJar task, boolean isMain // e.g. WEB-INF/lib/hello.jar exclude '**/*.jar' } + project.ext.shadowExclusions.each { + exclude it + } configurations = [project.configurations[isMain ? 'compileClasspath' : 'testCompileClasspath']] + def shadeConfig = project.configurations.findByName("shade") + def shadedDeps = shadeConfig ? + shadeConfig.dependencies.collect { "${it.group}:${it.name}" }.toSet() : + [] as Set + + relocations.each { props -> task.relocate props['from'], props['to'] } @@ -361,8 +397,10 @@ private void configureShadowTask(Project project, ShadowJar task, boolean isMain } } } else { // hasFlags('relocate') - // Only want to rewrite source references, not bundle dependencies. - exclude { true } + // Only want to shade if explicitly specified on the dependency + exclude { + return !shadedDeps.contains("${it.moduleGroup}:${it.moduleName}") + } } } } diff --git a/gradle/scripts/lib/thrift/0.23/thrift.linux-aarch_64 b/gradle/scripts/lib/thrift/0.23/thrift.linux-aarch_64 new file mode 100755 index 000000000..44941cc12 Binary files /dev/null and b/gradle/scripts/lib/thrift/0.23/thrift.linux-aarch_64 differ diff --git a/gradle/scripts/lib/thrift/0.23/thrift.linux-x86_64 b/gradle/scripts/lib/thrift/0.23/thrift.linux-x86_64 new file mode 100755 index 000000000..521fa47a6 Binary files /dev/null and b/gradle/scripts/lib/thrift/0.23/thrift.linux-x86_64 differ diff --git a/gradle/scripts/lib/thrift/0.23/thrift.osx-aarch_64 b/gradle/scripts/lib/thrift/0.23/thrift.osx-aarch_64 new file mode 100755 index 000000000..312f436b4 Binary files /dev/null and b/gradle/scripts/lib/thrift/0.23/thrift.osx-aarch_64 differ diff --git a/gradle/scripts/lib/thrift/0.23/thrift.osx-x86_64 b/gradle/scripts/lib/thrift/0.23/thrift.osx-x86_64 new file mode 100755 index 000000000..3221e2c18 Binary files /dev/null and b/gradle/scripts/lib/thrift/0.23/thrift.osx-x86_64 differ diff --git a/gradle/scripts/lib/thrift/0.23/thrift.windows-x86_64.exe b/gradle/scripts/lib/thrift/0.23/thrift.windows-x86_64.exe new file mode 100755 index 000000000..9e4e77f60 Binary files /dev/null and b/gradle/scripts/lib/thrift/0.23/thrift.windows-x86_64.exe differ diff --git a/gradle/scripts/lib/thrift/dockerfile/Dockerfile.bionic b/gradle/scripts/lib/thrift/dockerfile/Dockerfile.bionic index f7bee4e24..8803caed2 100644 --- a/gradle/scripts/lib/thrift/dockerfile/Dockerfile.bionic +++ b/gradle/scripts/lib/thrift/dockerfile/Dockerfile.bionic @@ -5,7 +5,7 @@ FROM ubuntu:bionic AS builder ENV DEBIAN_FRONTEND=noninteractive # See https://archive.apache.org/dist/thrift/ -ENV THRIFT_VERSION=0.22.0 +ENV THRIFT_VERSION=0.23.0 # See https://thrift.apache.org/docs/install/debian.html RUN apt-get update -yq && \ @@ -25,7 +25,7 @@ RUN apt-get update -yq && \ ADD https://archive.apache.org/dist/thrift/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}.tar.gz /tmp/thrift.tar.gz -RUN echo "794a0e455787960d9f27ab92c38e34da27e8deeda7a5db0e59dc64a00df8a1e5 /tmp/thrift.tar.gz" | sha256sum -c && \ +RUN echo "1859d932d2ae1f13d16c5a196931208c116310a5ff50f2bfd11d3db03be8f46f /tmp/thrift.tar.gz" | sha256sum -c && \ tar xzf /tmp/thrift.tar.gz -C /tmp RUN cd /tmp/thrift-${THRIFT_VERSION} && \ diff --git a/gradle/scripts/lib/thrift/dockerfile/Dockerfile.centos7 b/gradle/scripts/lib/thrift/dockerfile/Dockerfile.centos7 index cda890c09..292575564 100644 --- a/gradle/scripts/lib/thrift/dockerfile/Dockerfile.centos7 +++ b/gradle/scripts/lib/thrift/dockerfile/Dockerfile.centos7 @@ -12,7 +12,7 @@ RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/CentOS-*.repo sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/CentOS-*.repo # See https://archive.apache.org/dist/thrift/ -ENV THRIFT_VERSION=0.22.0 +ENV THRIFT_VERSION=0.23.0 # See https://thrift.apache.org/docs/install/centos.html RUN yum update -y -q && \ @@ -32,7 +32,7 @@ RUN yum update -y -q && \ ADD https://archive.apache.org/dist/thrift/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}.tar.gz /tmp/thrift.tar.gz -RUN echo "794a0e455787960d9f27ab92c38e34da27e8deeda7a5db0e59dc64a00df8a1e5 /tmp/thrift.tar.gz" | sha256sum -c && \ +RUN echo "1859d932d2ae1f13d16c5a196931208c116310a5ff50f2bfd11d3db03be8f46f /tmp/thrift.tar.gz" | sha256sum -c && \ tar xzf /tmp/thrift.tar.gz -C /tmp RUN cd /tmp/thrift-${THRIFT_VERSION} && \ diff --git a/gradle/scripts/lib/thrift/dockerfile/Dockerfile.trusty b/gradle/scripts/lib/thrift/dockerfile/Dockerfile.trusty index abb4646ba..213e552ab 100644 --- a/gradle/scripts/lib/thrift/dockerfile/Dockerfile.trusty +++ b/gradle/scripts/lib/thrift/dockerfile/Dockerfile.trusty @@ -5,7 +5,7 @@ FROM ubuntu:trusty AS builder ENV DEBIAN_FRONTEND=noninteractive # See https://archive.apache.org/dist/thrift/ -ENV THRIFT_VERSION=0.22.0 +ENV THRIFT_VERSION=0.23.0 # See https://thrift.apache.org/docs/install/debian.html RUN apt-get update -yq && \ @@ -25,7 +25,7 @@ RUN apt-get update -yq && \ ADD https://archive.apache.org/dist/thrift/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}.tar.gz /tmp/thrift.tar.gz -RUN echo "794a0e455787960d9f27ab92c38e34da27e8deeda7a5db0e59dc64a00df8a1e5 /tmp/thrift.tar.gz" | sha256sum -c && \ +RUN echo "1859d932d2ae1f13d16c5a196931208c116310a5ff50f2bfd11d3db03be8f46f /tmp/thrift.tar.gz" | sha256sum -c && \ tar xzf /tmp/thrift.tar.gz -C /tmp RUN cd /tmp/thrift-${THRIFT_VERSION} && \ diff --git a/gradle/scripts/version-catalog.gradle b/gradle/scripts/version-catalog.gradle index d95e4a28f..dd26daf70 100644 --- a/gradle/scripts/version-catalog.gradle +++ b/gradle/scripts/version-catalog.gradle @@ -4,7 +4,12 @@ import org.tomlj.TomlArray buildscript { repositories { - mavenCentral() + def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull() + if (mavenCentralMirror) { + maven { url = mavenCentralMirror } + } else { + mavenCentral() + } } dependencies {