Skip to content

Commit 6206bd9

Browse files
committed
Merge branch 'main' into scoped-readonly
2 parents 045403d + e89d1d4 commit 6206bd9

37 files changed

Lines changed: 1646 additions & 120 deletions

build.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import org.jsoup.select.Elements
55
import static java.lang.Math.min
66

77
buildscript {
8+
repositories {
9+
def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull()
10+
if (mavenCentralMirror) {
11+
maven { url = mavenCentralMirror }
12+
} else {
13+
mavenCentral()
14+
}
15+
}
816
dependencies {
917
classpath libs.jsoup
1018
}
@@ -17,7 +25,12 @@ plugins {
1725

1826
allprojects {
1927
repositories {
20-
mavenCentral()
28+
def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull()
29+
if (mavenCentralMirror) {
30+
maven { url = mavenCentralMirror }
31+
} else {
32+
mavenCentral()
33+
}
2134
}
2235
}
2336

dist/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
buildscript {
22
repositories {
3-
mavenCentral()
3+
def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull()
4+
if (mavenCentralMirror) {
5+
maven { url = mavenCentralMirror }
6+
} else {
7+
mavenCentral()
8+
}
49
gradlePluginPortal()
510
}
611
dependencies {

gradle/scripts/.gitrepo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[subrepo]
77
remote = https://github.com/line/gradle-scripts.git
88
branch = main
9-
commit = ed4e32f6327760c009660d032a43a2eb1504c2c4
10-
parent = bc900cce0f63a5f3959a697c5c219e036192d4b8
11-
cmdver = 0.4.9
9+
commit = 164b0ab73666dc3d05456912aa93759bf312af52
10+
parent = b0011fd46b1114d5860ac58d48657babc78058b2
11+
cmdver = 0.4.6
1212
method = merge

gradle/scripts/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ sensible defaults. By applying them, you can:
3636
- [Setting a Kotlin target version with the `kotlin(\\d+\\.\\d+)` flag](#setting-a-koltin-target-version-with-the-kotlindd-flag)
3737
- [Automatic module names](#automatic-module-names)
3838
- [Tagging conveniently with `release` task](#tagging-conveniently-with-release-task)
39+
- [Using a Maven Central mirror](#using-a-maven-central-mirror)
3940

4041
<!-- /MarkdownTOC -->
4142

@@ -759,3 +760,25 @@ instructions after tagging:
759760
Note the `${tag}`, which is replaced with the tag name.
760761
See [Groovy `SimpleTemplateEngine`](http://docs.groovy-lang.org/docs/next/html/documentation/template-engines.html#_simpletemplateengine)
761762
for the syntax.
763+
764+
## Using a Maven Central mirror
765+
766+
If your organization blocks direct access to Maven Central (e.g. for supply chain security), you can
767+
redirect all Maven Central requests to an internal mirror by setting the `mavenCentralMirror` Gradle
768+
property.
769+
770+
Add to `~/.gradle/gradle.properties`:
771+
772+
```properties
773+
mavenCentralMirror=https://your-mirror.example.com/repository/maven-central/
774+
```
775+
776+
Or pass via the CLI:
777+
778+
```bash
779+
./gradlew build -PmavenCentralMirror=https://your-mirror.example.com/repository/maven-central/
780+
```
781+
782+
When set, the mirror URL replaces `mavenCentral()` in all repository declarations including
783+
`settings.gradle`, `buildSrc`, and `buildscript` blocks of applied scripts. When unset, behavior
784+
is identical to the default — fully backward compatible.

gradle/scripts/lib/common-dependencies.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import org.yaml.snakeyaml.Yaml
44

55
buildscript {
66
repositories {
7-
mavenCentral()
7+
def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull()
8+
if (mavenCentralMirror) {
9+
maven { url = mavenCentralMirror }
10+
} else {
11+
mavenCentral()
12+
}
813
gradlePluginPortal()
914
}
1015

@@ -36,7 +41,12 @@ configure(dependencyManagementProject) {
3641
google()
3742
// Since we manage plugin versions here too.
3843
gradlePluginPortal()
39-
mavenCentral()
44+
def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull()
45+
if (mavenCentralMirror) {
46+
maven { url = mavenCentralMirror }
47+
} else {
48+
mavenCentral()
49+
}
4050
}
4151

4252
javaPlatform {

gradle/scripts/lib/common-info.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ rootProject.ext {
44
projectName = project.findProperty('projectName')
55
projectUrl = project.findProperty('projectUrl')
66
projectDescription = project.findProperty('projectDescription')?: rootProject.name
7-
authorName = project.findProperty('authorName')?: 'LINE Corporation'
8-
authorEmail = project.findProperty('authorEmail')?: 'dl_oss_dev@linecorp.com'
7+
authorName = project.findProperty('authorName')?: 'LY Corporation'
8+
authorEmail = project.findProperty('authorEmail')?: 'dl_armeria@linecorp.com'
99
authorUrl = project.findProperty('authorUrl')?: 'https://engineering.linecorp.com/en/'
1010
inceptionYear = project.findProperty('inceptionYear')
1111
licenseName = project.findProperty('licenseName')
@@ -15,8 +15,8 @@ rootProject.ext {
1515
scmDeveloperConnection = project.findProperty('scmDeveloperConnection')
1616
copyrightFooter =
1717
'&copy; Copyright ' + "${rootProject.ext.inceptionYear}&ndash;${LocalDateTime.now().year} " +
18-
'<a href="' + rootProject.ext.authorUrl + '">' + rootProject.ext.authorName + '</a>. ' +
19-
'All rights reserved.'
18+
'<a href="' + rootProject.ext.authorUrl + '">' + rootProject.ext.authorName + '</a>. ' +
19+
'All rights reserved.'
2020
googleAnalyticsId = rootProject.findProperty('googleAnalyticsId')
2121
}
2222

gradle/scripts/lib/common-publish.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ if (publishToStaging) {
6262
}
6363
}
6464

65+
clientTimeout.set(Duration.ofMinutes(30))
66+
6567
transitionCheckOptions {
6668
maxRetries.set(100)
6769
delayBetween.set(Duration.ofSeconds(20))

gradle/scripts/lib/java-javadoc.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import groovy.json.JsonBuilder
22
import groovy.json.JsonSlurper
33

4-
import javax.inject.Inject
54
import java.security.MessageDigest
65

76
def offlineJavadoc = rootProject.hasProperty('offlineJavadoc')

gradle/scripts/lib/java-rpc-proto.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import org.gradle.internal.os.OperatingSystem
22

33
buildscript {
44
repositories {
5+
def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull()
6+
if (mavenCentralMirror) {
7+
maven { url = mavenCentralMirror }
8+
}
59
gradlePluginPortal()
610
}
711
dependencies {

gradle/scripts/lib/java-shade.gradle

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import java.util.concurrent.atomic.AtomicInteger
55

66
buildscript {
77
repositories {
8+
def mavenCentralMirror = providers.gradleProperty('mavenCentralMirror').getOrNull()
9+
if (mavenCentralMirror) {
10+
maven { url = mavenCentralMirror }
11+
}
812
gradlePluginPortal()
913
google()
1014
}
@@ -14,17 +18,44 @@ buildscript {
1418
}
1519
}
1620

21+
def globalShadowExclusions = []
22+
if (rootProject.hasProperty('shadowExclusions')) {
23+
def rawShadowExclusions = rootProject.findProperty("shadowExclusions")
24+
if (!(rawShadowExclusions instanceof String)) {
25+
throw new RuntimeException("Property 'shadowExclusions' must be a String but was: ${rawShadowExclusions.getClass().name}")
26+
}
27+
globalShadowExclusions = rawShadowExclusions.split(",")
28+
}
29+
subprojects {
30+
ext {
31+
shadowExclusions = globalShadowExclusions.collect()
32+
}
33+
}
34+
1735
def relocatedProjects = projectsWithFlags('java', 'relocate')
1836
def numConfiguredRelocatedProjects = new AtomicInteger()
1937
configure(relocatedProjects) {
38+
39+
// per-dependency shade configuration
40+
// while shade per-project shades all dependencies, shade per-dependency allows for finer control
41+
def shadeConfig = project.configurations.create("shade") {
42+
canBeResolved = true
43+
canBeConsumed = false
44+
}
45+
project.configurations.api.extendsFrom(shadeConfig)
46+
2047
// Generate the shaded JARs.
2148
task shadedJar(
2249
type: ShadowJar,
2350
group: 'Build',
2451
description: 'Builds the shaded main JAR.',
2552
dependsOn: tasks.classes) {
2653

27-
configureShadowTask(project, delegate, true)
54+
def self = this
55+
def delegate0 = delegate
56+
project.afterEvaluate {
57+
self.configureShadowTask(project, delegate0, true)
58+
}
2859
archiveClassifier.set('shaded')
2960

3061
// Exclude the legacy file listing.
@@ -49,14 +80,6 @@ configure(relocatedProjects) {
4980
return false
5081
}
5182

52-
def shadowExclusions = []
53-
if (rootProject.hasProperty('shadowExclusions')) {
54-
shadowExclusions = rootProject.findProperty('shadowExclusions').split(",")
55-
}
56-
shadowExclusions.each {
57-
exclude it
58-
}
59-
6083
// Set the 'Automatic-Module-Name' property in MANIFEST.MF.
6184
if (project.ext.automaticModuleName != null) {
6285
doFirst {
@@ -92,7 +115,11 @@ configure(relocatedProjects) {
92115
description: 'Builds the shaded test JAR.',
93116
dependsOn: tasks.testClasses) {
94117

95-
configureShadowTask(project, delegate, false)
118+
def self = this
119+
def delegate0 = delegate
120+
project.afterEvaluate {
121+
self.configureShadowTask(project, delegate0, false)
122+
}
96123
archiveBaseName.set("test-${tasks.jar.archiveBaseName.get()}-shaded")
97124
}
98125

@@ -335,9 +362,18 @@ private void configureShadowTask(Project project, ShadowJar task, boolean isMain
335362
// e.g. WEB-INF/lib/hello.jar
336363
exclude '**/*.jar'
337364
}
365+
project.ext.shadowExclusions.each {
366+
exclude it
367+
}
338368

339369
configurations = [project.configurations[isMain ? 'compileClasspath' : 'testCompileClasspath']]
340370

371+
def shadeConfig = project.configurations.findByName("shade")
372+
def shadedDeps = shadeConfig ?
373+
shadeConfig.dependencies.collect { "${it.group}:${it.name}" }.toSet() :
374+
[] as Set<String>
375+
376+
341377
relocations.each { props ->
342378
task.relocate props['from'], props['to']
343379
}
@@ -361,8 +397,10 @@ private void configureShadowTask(Project project, ShadowJar task, boolean isMain
361397
}
362398
}
363399
} else { // hasFlags('relocate')
364-
// Only want to rewrite source references, not bundle dependencies.
365-
exclude { true }
400+
// Only want to shade if explicitly specified on the dependency
401+
exclude {
402+
return !shadedDeps.contains("${it.moduleGroup}:${it.moduleName}")
403+
}
366404
}
367405
}
368406
}

0 commit comments

Comments
 (0)