Skip to content
Merged
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
6 changes: 3 additions & 3 deletions gradle/scripts/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 23 additions & 0 deletions gradle/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!-- /MarkdownTOC -->

Expand Down Expand Up @@ -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.
Comment on lines +782 to +784

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Narrow the documented scope of mavenCentralMirror.

This text promises that all mavenCentral() declarations, including settings.gradle and buildSrc, are redirected, but the wiring in this PR only touches the repositories inside the shipped Gradle scripts. As written, users can still leave direct mavenCentral() calls in their own settings.gradle/buildSrc and hit the public repo unexpectedly. Please either scope the docs to the script-managed repositories or add the missing wiring.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gradle/scripts/README.md` around lines 782 - 784, The documented scope of
mavenCentralMirror is too broad compared with the current wiring. Update the
README text to match what the implementation actually redirects, or extend the
Gradle script handling so mavenCentral() is also replaced in settings.gradle,
buildSrc, and buildscript blocks; use the existing mavenCentralMirror repository
wiring and related script repository setup as the reference points. Keep the
wording precise about which repositories are affected so users do not expect
their own settings.gradle/buildSrc declarations to be rewritten unless that
behavior is actually implemented.

14 changes: 12 additions & 2 deletions gradle/scripts/lib/common-dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions gradle/scripts/lib/common-info.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -15,8 +15,8 @@ rootProject.ext {
scmDeveloperConnection = project.findProperty('scmDeveloperConnection')
copyrightFooter =
'&copy; Copyright ' + "${rootProject.ext.inceptionYear}&ndash;${LocalDateTime.now().year} " +
'<a href="' + rootProject.ext.authorUrl + '">' + rootProject.ext.authorName + '</a>. ' +
'All rights reserved.'
'<a href="' + rootProject.ext.authorUrl + '">' + rootProject.ext.authorName + '</a>. ' +
'All rights reserved.'
googleAnalyticsId = rootProject.findProperty('googleAnalyticsId')
}

Expand Down
2 changes: 2 additions & 0 deletions gradle/scripts/lib/common-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ if (publishToStaging) {
}
}

clientTimeout.set(Duration.ofMinutes(30))

Comment on lines +65 to +66

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n 'import java.time.Duration' gradle/scripts/lib/common-publish.gradle

Repository: line/centraldogma

Length of output: 155


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- file outline ---'
ast-grep outline gradle/scripts/lib/common-publish.gradle --view expanded || true

echo
echo '--- first 120 lines ---'
sed -n '1,120p' gradle/scripts/lib/common-publish.gradle | cat -n

echo
echo '--- search for Duration usage/imports in Gradle scripts ---'
rg -n '\bDuration\b|import java\.time\.Duration|java\.time\.' gradle/scripts/lib -g '*.gradle' -g '*.groovy' || true

Repository: line/centraldogma

Length of output: 5302


Import java.time.Duration at the top of this script. Duration.ofMinutes(30) and Duration.ofSeconds(20) both use an unqualified type here, so the script won’t compile without an explicit import.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gradle/scripts/lib/common-publish.gradle` around lines 65 - 66, The
common-publish Gradle script uses Duration.ofMinutes(30) and
Duration.ofSeconds(20) without an explicit import, so add the missing
java.time.Duration import at the top of the script. Update the
common-publish.gradle script near the clientTimeout and related timeout
configuration so the unqualified Duration references resolve correctly.

transitionCheckOptions {
maxRetries.set(100)
delayBetween.set(Duration.ofSeconds(20))
Expand Down
1 change: 0 additions & 1 deletion gradle/scripts/lib/java-javadoc.gradle
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
4 changes: 4 additions & 0 deletions gradle/scripts/lib/java-rpc-proto.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
62 changes: 50 additions & 12 deletions gradle/scripts/lib/java-shade.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -14,17 +18,44 @@ 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(",")
}
Comment on lines +23 to +28

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Trim shadowExclusions entries before storing them.

split(",") preserves whitespace and empty tokens, so a value like a, b produces " b" and the exclude no longer matches. Normalize the list here before copying it to subprojects.

Proposed fix
-    globalShadowExclusions = rawShadowExclusions.split(",")
+    globalShadowExclusions = rawShadowExclusions
+            .split(',')
+            .collect { it.trim() }
+            .findAll { !it.isEmpty() }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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(",")
}
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(',')
.collect { it.trim() }
.findAll { !it.isEmpty() }
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gradle/scripts/lib/java-shade.gradle` around lines 23 - 28, The
`shadowExclusions` parsing in `java-shade.gradle` is keeping whitespace around
comma-separated values, so entries like `a, b` won’t match excludes correctly.
Update the normalization where `rawShadowExclusions` is converted into
`globalShadowExclusions` to trim each token and ignore empty items before
storing the list for subprojects. Keep the existing type check in place and
apply the cleanup directly in the `split(",")` handling.

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)
Comment on lines +41 to +45

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Keep shade off api and drive shading from the resolved shade graph.

api.extendsFrom(shadeConfig) publishes shaded libraries as normal dependencies, while shadedDeps only tracks the direct declarations on shade. The current filter therefore drops transitives from the shadow JAR but still advertises the direct deps to consumers, which is the wrong contract for shaded artifacts. Use shade (or its resolved dependency graph) as the ShadowJar input, and if compilation needs those jars, wire them into a compile-only path instead of api.

Also applies to: 369-374, 400-403

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@gradle/scripts/lib/java-shade.gradle` around lines 41 - 45, The `shade`
configuration is being exposed through
`project.configurations.api.extendsFrom(shadeConfig)`, which incorrectly
publishes shaded libraries to consumers. Remove that `api` extension and instead
drive `ShadowJar` from the resolved `shade` dependency graph (or the `shade`
configuration itself), using `shadedDeps` only for selecting the shaded inputs.
If compile-time access is needed, wire those dependencies through a compile-only
path rather than `api`, and apply the same fix anywhere the same
`shade`/`shadedDeps` pattern appears.


// Generate the shaded JARs.
task shadedJar(
type: ShadowJar,
group: 'Build',
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.
Expand All @@ -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 {
Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -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<String>


relocations.each { props ->
task.relocate props['from'], props['to']
}
Expand All @@ -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}")
}
}
}
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/scripts/lib/thrift/dockerfile/Dockerfile.bionic
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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} && \
Expand Down
4 changes: 2 additions & 2 deletions gradle/scripts/lib/thrift/dockerfile/Dockerfile.centos7
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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} && \
Expand Down
4 changes: 2 additions & 2 deletions gradle/scripts/lib/thrift/dockerfile/Dockerfile.trusty
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand All @@ -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} && \
Expand Down
7 changes: 6 additions & 1 deletion gradle/scripts/version-catalog.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading