Skip to content

Commit d69a147

Browse files
committed
Sync with develop
Signed-off-by: Artem Ananev <[email protected]>
2 parents 4966c2e + 6d26f56 commit d69a147

File tree

443 files changed

+8694
-4251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

443 files changed

+8694
-4251
lines changed

.github/workflows/node-zxcron-release-fsts-regression.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
major="${BASH_REMATCH[1]}"
5252
minor="${BASH_REMATCH[2]}"
5353
54-
if [[ "${major}" -eq 0 && "${minor}" -lt 48 ]]; then
54+
if [[ "${major}" -eq 0 && "${minor}" -lt 50 ]]; then
5555
continue
5656
fi
5757

.github/workflows/platform-zxcron-release-jrs-regression.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
major="${BASH_REMATCH[1]}"
5252
minor="${BASH_REMATCH[2]}"
5353
54-
if [[ "${major}" -eq 0 && "${minor}" -lt 48 ]]; then
54+
if [[ "${major}" -eq 0 && "${minor}" -lt 50 ]]; then
5555
continue
5656
fi
5757

block-node/blocknode-core/src/main/java/module-info.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
exports com.hedera.node.blocknode.core to
44
com.hedera.storage.blocknode.core.test;
55

6-
// Require the modules needed for compilation.
7-
requires com.hedera.storage.blocknode.filesystem.local;
8-
requires com.hedera.storage.blocknode.filesystem.s3;
9-
10-
// Require modules which are needed for compilation and should be available to all modules that depend on this
11-
// module (including tests and other source sets).
6+
// 'requires transitive' - modules which are needed for compilation and should be available to
7+
// all modules that depend on this module (including tests and other source sets)
8+
// 'require' - modules needed only for compilation of this module
9+
requires transitive com.hedera.node.hapi;
1210
requires transitive com.hedera.storage.blocknode.core.spi;
1311
requires transitive com.hedera.storage.blocknode.filesystem.api;
1412
requires transitive com.hedera.storage.blocknode.grpc.api;
1513
requires transitive com.hedera.storage.blocknode.state;
16-
requires transitive com.hedera.node.hapi;
14+
requires com.hedera.storage.blocknode.filesystem.local;
15+
requires com.hedera.storage.blocknode.filesystem.s3;
1716
}

block-node/blocknode-filesystem-local/src/main/java/module-info.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
com.hedera.storage.blocknode.filesystem.local.test,
55
com.hedera.storage.blocknode.core;
66

7-
// Require the modules needed for compilation.
8-
requires com.hedera.storage.blocknode.core.spi;
9-
10-
// Require modules which are needed for compilation and should be available to all modules that depend on this
11-
// module (including tests and other source sets).
7+
// 'requires transitive' - modules which are needed for compilation and should be available to
8+
// all modules that depend on this module (including tests and other source sets)
9+
// 'require' - modules needed only for compilation of this module
1210
requires transitive com.hedera.storage.blocknode.filesystem.api;
11+
requires com.hedera.storage.blocknode.core.spi;
1312
}

block-node/blocknode-filesystem-s3/src/main/java/module-info.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
com.hedera.storage.blocknode.filesystem.s3.test,
55
com.hedera.storage.blocknode.core;
66

7-
// Require the modules needed for compilation.
8-
requires com.hedera.storage.blocknode.core.spi;
9-
10-
// Require modules which are needed for compilation and should be available to all modules that depend on this
11-
// module (including tests and other source sets).
7+
// 'requires transitive' - modules which are needed for compilation and should be available to
8+
// all modules that depend on this module (including tests and other source sets)
9+
// 'require' - modules needed only for compilation of this module
1210
requires transitive com.hedera.storage.blocknode.filesystem.api;
11+
requires com.hedera.storage.blocknode.core.spi;
1312
}

block-node/blocknode-state/src/main/java/module-info.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// Export the packages that should be available to other modules.
33
exports com.hedera.node.blocknode.state;
44

5-
// Require the modules needed for compilation.
6-
requires com.hedera.storage.blocknode.core.spi;
7-
8-
// Require modules which are needed for compilation and should be available to all modules that depend on this
9-
// module (including tests and other source sets
5+
// 'requires transitive' - modules which are needed for compilation and should be available to
6+
// all modules that depend on this module (including tests and other source sets)
7+
// 'require' - modules needed only for compilation of this module
108
requires transitive com.swirlds.platform.core;
9+
requires com.hedera.storage.blocknode.core.spi;
1110
}

gradle/plugins/src/main/kotlin/com.hedera.gradle.blocknode.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ plugins {
2020
}
2121

2222
group = "com.hedera.storage"
23-
24-
tasks.checkModuleInfo { moduleNamePrefix = "com.hedera.storage" }

gradle/plugins/src/main/kotlin/com.hedera.gradle.java.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import com.autonomousapps.AbstractExtension
1919
import com.autonomousapps.DependencyAnalysisSubExtension
2020
import com.hedera.gradle.services.TaskLockService
2121
import com.hedera.gradle.utils.Utils.versionTxt
22+
import org.gradlex.javamodule.dependencies.tasks.ModuleDirectivesOrderingCheck
2223

2324
plugins {
2425
id("java")
@@ -211,6 +212,8 @@ tasks.withType<Javadoc>().configureEach {
211212
"implSpec:a:Implementation Requirements:",
212213
"implNote:a:Implementation Note:"
213214
)
215+
options.windowTitle = "Hedera Consensus Node"
216+
options.memberLevel = JavadocMemberLevel.PACKAGE
214217
}
215218
}
216219

@@ -345,6 +348,9 @@ tasks.check { dependsOn(tasks.jacocoTestReport) }
345348

346349
tasks.named("qualityGate") { dependsOn(tasks.checkAllModuleInfo) }
347350

351+
// ordering check is done by SortModuleInfoRequiresStep
352+
tasks.withType<ModuleDirectivesOrderingCheck> { enabled = false }
353+
348354
tasks.withType<JavaCompile>() {
349355
// When ding a 'qualityGate' run, make sure spotlessApply is done before doing compilation and
350356
// other checks based on compiled code

gradle/plugins/src/main/kotlin/com.hedera.gradle.platform.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ plugins {
2121

2222
group = "com.swirlds"
2323

24-
tasks.checkModuleInfo { moduleNamePrefix = "com.swirlds" }
25-
2624
// All below configuration should eventually be removed once all 'sdk' tests in 'src/test'
2725
// are able to run in parallel without restrictions.
2826
tasks.test {

gradle/plugins/src/main/kotlin/com.hedera.gradle.root.gradle.kts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ plugins {
2727
id("com.autonomousapps.dependency-analysis")
2828
}
2929

30-
spotless { kotlinGradle { target("gradle/plugins/**/*.gradle.kts") } }
30+
spotless {
31+
kotlinGradle { target("gradle/plugins/**/*.gradle.kts") }
32+
kotlin {
33+
// For the Kotlin classes (*.kt files)
34+
ktfmt().kotlinlangStyle()
35+
target("gradle/plugins/**/*.kt")
36+
}
37+
}
3138

3239
val productVersion = layout.projectDirectory.versionTxt().asFile.readText().trim()
3340

gradle/plugins/src/main/kotlin/com.hedera.gradle.spotless-java.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,22 @@
1515
*/
1616

1717
import com.hedera.gradle.spotless.RepairDashedCommentsFormatterStep
18+
import com.hedera.gradle.spotless.SortModuleInfoRequiresStep
1819
import com.hedera.gradle.spotless.StripOldLicenseFormatterStep
1920

2021
plugins { id("com.hedera.gradle.spotless") }
2122

2223
spotless {
2324
java {
24-
targetExclude("build/generated/sources/**/*.java")
25-
targetExclude("build/generated/source/**/*.java")
25+
targetExclude("build/generated/sources/**/*.java", "build/generated/source/**/*.java")
26+
2627
// fix errors due to dashed comment blocks (eg: /*-, /*--, etc)
2728
addStep(RepairDashedCommentsFormatterStep.create())
2829
// Remove the old license headers as the spotless licenseHeader formatter
2930
// cannot find them if they are located between the package and import statements.
3031
addStep(StripOldLicenseFormatterStep.create())
32+
// Sort the 'requires' entries in Module Info files
33+
addStep(SortModuleInfoRequiresStep.create())
3134
// enable toggle comment support
3235
toggleOffOn()
3336
// don't need to set target, it is inferred from java

gradle/plugins/src/main/kotlin/com/hedera/gradle/services/TaskLockService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
2+
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

gradle/plugins/src/main/kotlin/com/hedera/gradle/spotless/RepairDashedCommentsFormatterStep.kt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
2+
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@ import com.diffplug.spotless.FormatterFunc
2020
import com.diffplug.spotless.FormatterStep
2121

2222
/**
23-
* Adds self-correcting behavior as spotless step which properly removes the comments which causes the
24-
* google-java-formatter plugin to rupture (eg: \/\*-).
23+
* Adds self-correcting behavior as spotless step which properly removes the comments which causes
24+
* the google-java-formatter plugin to rupture (eg: \/\*-).
2525
*/
2626
class RepairDashedCommentsFormatterStep {
2727
companion object {
@@ -42,10 +42,6 @@ class RepairDashedCommentsFormatterStep {
4242

4343
private class State(val openingCommentRegex: Regex, val closingCommentRegex: Regex) :
4444
java.io.Serializable {
45-
companion object {
46-
private const val serialVersionUID = -113
47-
}
48-
4945

5046
fun toFormatter(): FormatterFunc {
5147
return FormatterFunc { unixStr ->
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright (C) 2024 Hedera Hashgraph, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.hedera.gradle.spotless
18+
19+
import com.diffplug.spotless.FormatterFunc
20+
import com.diffplug.spotless.FormatterStep
21+
22+
class SortModuleInfoRequiresStep {
23+
companion object {
24+
private const val NAME = "SortModuleInfoRequires"
25+
private val OWN_PACKAGES = listOf("com.swirlds.", "com.hedera.node.", "com.hedera.storage.")
26+
27+
fun create(): FormatterStep {
28+
return FormatterStep.create(NAME, State(), State::toFormatter)
29+
}
30+
}
31+
32+
private class State : java.io.Serializable {
33+
34+
fun toFormatter(): FormatterFunc {
35+
return FormatterFunc { unixStr ->
36+
val lines = unixStr.split('\n')
37+
val blockStartIndex = lines.indexOfFirst { it.trim().startsWith("requires") }
38+
val blockEndIndex = lines.indexOfLast { it.trim().startsWith("requires") }
39+
40+
if (blockStartIndex == -1) {
41+
unixStr // not a module-info.java or no 'requires'
42+
} else {
43+
val nonRequiresLines = mutableListOf<String>()
44+
45+
val requiresTransitive = mutableListOf<String>()
46+
val requires = mutableListOf<String>()
47+
val requiresStaticTransitive = mutableListOf<String>()
48+
val requiresStatic = mutableListOf<String>()
49+
50+
lines.subList(blockStartIndex, blockEndIndex + 1).forEach { line ->
51+
when {
52+
line.trim().startsWith("requires static transitive") ->
53+
requiresStaticTransitive.add(line)
54+
line.trim().startsWith("requires static") -> requiresStatic.add(line)
55+
line.trim().startsWith("requires transitive") ->
56+
requiresTransitive.add(line)
57+
line.trim().startsWith("requires") -> requires.add(line)
58+
line.isNotBlank() && !line.trim().startsWith("requires") ->
59+
nonRequiresLines.add(line)
60+
}
61+
}
62+
63+
val comparator =
64+
Comparator<String> { a, b ->
65+
val nameA = a.split(" ").first { it.endsWith(";") }
66+
val nameB = b.split(" ").first { it.endsWith(";") }
67+
if (
68+
OWN_PACKAGES.any { nameA.startsWith(it) } &&
69+
OWN_PACKAGES.none { nameB.startsWith(it) }
70+
) {
71+
-1
72+
} else if (
73+
OWN_PACKAGES.none { nameA.startsWith(it) } &&
74+
OWN_PACKAGES.any { nameB.startsWith(it) }
75+
) {
76+
1
77+
} else {
78+
nameA.compareTo(nameB)
79+
}
80+
}
81+
82+
requiresTransitive.sortWith(comparator)
83+
requires.sortWith(comparator)
84+
requiresStaticTransitive.sortWith(comparator)
85+
requiresStatic.sortWith(comparator)
86+
87+
val blockStart = lines.subList(0, blockStartIndex)
88+
val blockEnd = lines.subList(blockEndIndex + 1, lines.size)
89+
90+
(blockStart +
91+
nonRequiresLines +
92+
requiresTransitive +
93+
requires +
94+
requiresStaticTransitive +
95+
requiresStatic +
96+
blockEnd)
97+
.joinToString("\n")
98+
}
99+
}
100+
}
101+
}
102+
}

gradle/plugins/src/main/kotlin/com/hedera/gradle/spotless/StripOldLicenseFormatterStep.kt

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
2+
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,28 +19,22 @@ package com.hedera.gradle.spotless
1919
import com.diffplug.spotless.FormatterFunc
2020
import com.diffplug.spotless.FormatterStep
2121

22-
/*
23-
Removes the old copyright statements which were incorrectly located between the package and import statements.
24-
These legacy copyright blocks also uses with an unexpected opening comment tag. This FormatterStep removes those
25-
comment blocks using a very conservative approach to avoid mutilating actual code.
22+
/**
23+
* Removes the old copyright statements which were incorrectly located between the package and
24+
* import statements. These legacy copyright blocks also uses with an unexpected opening comment
25+
* tag. This FormatterStep removes those comment blocks using a very conservative approach to avoid
26+
* mutilating actual code.
2627
*/
2728
class StripOldLicenseFormatterStep {
2829
companion object {
2930
private const val NAME = "StripOldLicense"
3031

3132
fun create(): FormatterStep {
32-
return FormatterStep.create(
33-
NAME,
34-
State(),
35-
State::toFormatter
36-
)
33+
return FormatterStep.create(NAME, State(), State::toFormatter)
3734
}
3835
}
3936

40-
private class State() : java.io.Serializable {
41-
companion object {
42-
private const val serialVersionUID = -113
43-
}
37+
private class State : java.io.Serializable {
4438

4539
fun toFormatter(): FormatterFunc {
4640
return FormatterFunc { unixStr ->
@@ -57,8 +51,7 @@ class StripOldLicenseFormatterStep {
5751
}
5852
}
5953

60-
val finalStr = result.joinToString("\n")
61-
finalStr
54+
result.joinToString("\n")
6255
}
6356
}
6457
}

0 commit comments

Comments
 (0)