Skip to content

Commit

Permalink
Sync with develop
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Ananev <[email protected]>
  • Loading branch information
artemananiev committed Jun 7, 2024
2 parents 4966c2e + 6d26f56 commit d69a147
Show file tree
Hide file tree
Showing 443 changed files with 8,694 additions and 4,251 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node-zxcron-release-fsts-regression.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
if [[ "${major}" -eq 0 && "${minor}" -lt 48 ]]; then
if [[ "${major}" -eq 0 && "${minor}" -lt 50 ]]; then
continue
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
if [[ "${major}" -eq 0 && "${minor}" -lt 48 ]]; then
if [[ "${major}" -eq 0 && "${minor}" -lt 50 ]]; then
continue
fi
Expand Down
13 changes: 6 additions & 7 deletions block-node/blocknode-core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
exports com.hedera.node.blocknode.core to
com.hedera.storage.blocknode.core.test;

// Require the modules needed for compilation.
requires com.hedera.storage.blocknode.filesystem.local;
requires com.hedera.storage.blocknode.filesystem.s3;

// Require modules which are needed for compilation and should be available to all modules that depend on this
// module (including tests and other source sets).
// 'requires transitive' - modules which are needed for compilation and should be available to
// all modules that depend on this module (including tests and other source sets)
// 'require' - modules needed only for compilation of this module
requires transitive com.hedera.node.hapi;
requires transitive com.hedera.storage.blocknode.core.spi;
requires transitive com.hedera.storage.blocknode.filesystem.api;
requires transitive com.hedera.storage.blocknode.grpc.api;
requires transitive com.hedera.storage.blocknode.state;
requires transitive com.hedera.node.hapi;
requires com.hedera.storage.blocknode.filesystem.local;
requires com.hedera.storage.blocknode.filesystem.s3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
com.hedera.storage.blocknode.filesystem.local.test,
com.hedera.storage.blocknode.core;

// Require the modules needed for compilation.
requires com.hedera.storage.blocknode.core.spi;

// Require modules which are needed for compilation and should be available to all modules that depend on this
// module (including tests and other source sets).
// 'requires transitive' - modules which are needed for compilation and should be available to
// all modules that depend on this module (including tests and other source sets)
// 'require' - modules needed only for compilation of this module
requires transitive com.hedera.storage.blocknode.filesystem.api;
requires com.hedera.storage.blocknode.core.spi;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
com.hedera.storage.blocknode.filesystem.s3.test,
com.hedera.storage.blocknode.core;

// Require the modules needed for compilation.
requires com.hedera.storage.blocknode.core.spi;

// Require modules which are needed for compilation and should be available to all modules that depend on this
// module (including tests and other source sets).
// 'requires transitive' - modules which are needed for compilation and should be available to
// all modules that depend on this module (including tests and other source sets)
// 'require' - modules needed only for compilation of this module
requires transitive com.hedera.storage.blocknode.filesystem.api;
requires com.hedera.storage.blocknode.core.spi;
}
9 changes: 4 additions & 5 deletions block-node/blocknode-state/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
// Export the packages that should be available to other modules.
exports com.hedera.node.blocknode.state;

// Require the modules needed for compilation.
requires com.hedera.storage.blocknode.core.spi;

// Require modules which are needed for compilation and should be available to all modules that depend on this
// module (including tests and other source sets
// 'requires transitive' - modules which are needed for compilation and should be available to
// all modules that depend on this module (including tests and other source sets)
// 'require' - modules needed only for compilation of this module
requires transitive com.swirlds.platform.core;
requires com.hedera.storage.blocknode.core.spi;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ plugins {
}

group = "com.hedera.storage"

tasks.checkModuleInfo { moduleNamePrefix = "com.hedera.storage" }
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.autonomousapps.AbstractExtension
import com.autonomousapps.DependencyAnalysisSubExtension
import com.hedera.gradle.services.TaskLockService
import com.hedera.gradle.utils.Utils.versionTxt
import org.gradlex.javamodule.dependencies.tasks.ModuleDirectivesOrderingCheck

plugins {
id("java")
Expand Down Expand Up @@ -211,6 +212,8 @@ tasks.withType<Javadoc>().configureEach {
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
options.windowTitle = "Hedera Consensus Node"
options.memberLevel = JavadocMemberLevel.PACKAGE
}
}

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

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

// ordering check is done by SortModuleInfoRequiresStep
tasks.withType<ModuleDirectivesOrderingCheck> { enabled = false }

tasks.withType<JavaCompile>() {
// When ding a 'qualityGate' run, make sure spotlessApply is done before doing compilation and
// other checks based on compiled code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ plugins {

group = "com.swirlds"

tasks.checkModuleInfo { moduleNamePrefix = "com.swirlds" }

// All below configuration should eventually be removed once all 'sdk' tests in 'src/test'
// are able to run in parallel without restrictions.
tasks.test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ plugins {
id("com.autonomousapps.dependency-analysis")
}

spotless { kotlinGradle { target("gradle/plugins/**/*.gradle.kts") } }
spotless {
kotlinGradle { target("gradle/plugins/**/*.gradle.kts") }
kotlin {
// For the Kotlin classes (*.kt files)
ktfmt().kotlinlangStyle()
target("gradle/plugins/**/*.kt")
}
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@
*/

import com.hedera.gradle.spotless.RepairDashedCommentsFormatterStep
import com.hedera.gradle.spotless.SortModuleInfoRequiresStep
import com.hedera.gradle.spotless.StripOldLicenseFormatterStep

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

spotless {
java {
targetExclude("build/generated/sources/**/*.java")
targetExclude("build/generated/source/**/*.java")
targetExclude("build/generated/sources/**/*.java", "build/generated/source/**/*.java")

// fix errors due to dashed comment blocks (eg: /*-, /*--, etc)
addStep(RepairDashedCommentsFormatterStep.create())
// Remove the old license headers as the spotless licenseHeader formatter
// cannot find them if they are located between the package and import statements.
addStep(StripOldLicenseFormatterStep.create())
// Sort the 'requires' entries in Module Info files
addStep(SortModuleInfoRequiresStep.create())
// enable toggle comment support
toggleOffOn()
// don't need to set target, it is inferred from java
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,8 +20,8 @@ import com.diffplug.spotless.FormatterFunc
import com.diffplug.spotless.FormatterStep

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

private class State(val openingCommentRegex: Regex, val closingCommentRegex: Regex) :
java.io.Serializable {
companion object {
private const val serialVersionUID = -113
}


fun toFormatter(): FormatterFunc {
return FormatterFunc { unixStr ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (C) 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.hedera.gradle.spotless

import com.diffplug.spotless.FormatterFunc
import com.diffplug.spotless.FormatterStep

class SortModuleInfoRequiresStep {
companion object {
private const val NAME = "SortModuleInfoRequires"
private val OWN_PACKAGES = listOf("com.swirlds.", "com.hedera.node.", "com.hedera.storage.")

fun create(): FormatterStep {
return FormatterStep.create(NAME, State(), State::toFormatter)
}
}

private class State : java.io.Serializable {

fun toFormatter(): FormatterFunc {
return FormatterFunc { unixStr ->
val lines = unixStr.split('\n')
val blockStartIndex = lines.indexOfFirst { it.trim().startsWith("requires") }
val blockEndIndex = lines.indexOfLast { it.trim().startsWith("requires") }

if (blockStartIndex == -1) {
unixStr // not a module-info.java or no 'requires'
} else {
val nonRequiresLines = mutableListOf<String>()

val requiresTransitive = mutableListOf<String>()
val requires = mutableListOf<String>()
val requiresStaticTransitive = mutableListOf<String>()
val requiresStatic = mutableListOf<String>()

lines.subList(blockStartIndex, blockEndIndex + 1).forEach { line ->
when {
line.trim().startsWith("requires static transitive") ->
requiresStaticTransitive.add(line)
line.trim().startsWith("requires static") -> requiresStatic.add(line)
line.trim().startsWith("requires transitive") ->
requiresTransitive.add(line)
line.trim().startsWith("requires") -> requires.add(line)
line.isNotBlank() && !line.trim().startsWith("requires") ->
nonRequiresLines.add(line)
}
}

val comparator =
Comparator<String> { a, b ->
val nameA = a.split(" ").first { it.endsWith(";") }
val nameB = b.split(" ").first { it.endsWith(";") }
if (
OWN_PACKAGES.any { nameA.startsWith(it) } &&
OWN_PACKAGES.none { nameB.startsWith(it) }
) {
-1
} else if (
OWN_PACKAGES.none { nameA.startsWith(it) } &&
OWN_PACKAGES.any { nameB.startsWith(it) }
) {
1
} else {
nameA.compareTo(nameB)
}
}

requiresTransitive.sortWith(comparator)
requires.sortWith(comparator)
requiresStaticTransitive.sortWith(comparator)
requiresStatic.sortWith(comparator)

val blockStart = lines.subList(0, blockStartIndex)
val blockEnd = lines.subList(blockEndIndex + 1, lines.size)

(blockStart +
nonRequiresLines +
requiresTransitive +
requires +
requiresStaticTransitive +
requiresStatic +
blockEnd)
.joinToString("\n")
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
* Copyright (C) 2022-2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,28 +19,22 @@ package com.hedera.gradle.spotless
import com.diffplug.spotless.FormatterFunc
import com.diffplug.spotless.FormatterStep

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

fun create(): FormatterStep {
return FormatterStep.create(
NAME,
State(),
State::toFormatter
)
return FormatterStep.create(NAME, State(), State::toFormatter)
}
}

private class State() : java.io.Serializable {
companion object {
private const val serialVersionUID = -113
}
private class State : java.io.Serializable {

fun toFormatter(): FormatterFunc {
return FormatterFunc { unixStr ->
Expand All @@ -57,8 +51,7 @@ class StripOldLicenseFormatterStep {
}
}

val finalStr = result.joinToString("\n")
finalStr
result.joinToString("\n")
}
}
}
Expand Down
Loading

0 comments on commit d69a147

Please sign in to comment.