Skip to content

Commit

Permalink
build: WiP
Browse files Browse the repository at this point in the history
Signed-off-by: Jendrik Johannes <[email protected]>
  • Loading branch information
jjohannes committed Sep 16, 2024
1 parent aaff32c commit 4294d00
Show file tree
Hide file tree
Showing 120 changed files with 1,161 additions and 1,178 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node-zxc-build-release-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ jobs:
NEXUS_PASSWORD: ${{ secrets.sdk-ossrh-password }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.swirlds --scan -PpublishSigningEnabled=true --no-configuration-cache"
arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.swirlds -Ps01SonatypeHost=true -PpublishSigningEnabled=true --scan --no-configuration-cache"

- name: Gradle Publish Services to ${{ inputs.version-policy == 'specified' && 'Maven Central' || 'Google Artifact Registry' }} (${{ inputs.release-profile }})
uses: gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3.1.0
Expand All @@ -855,7 +855,7 @@ jobs:
NEXUS_PASSWORD: ${{ secrets.svcs-ossrh-password }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.hedera --scan -PpublishSigningEnabled=true --no-configuration-cache"
arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.hedera.hashgraph -PpublishSigningEnabled=true --scan --no-configuration-cache"

- name: Upload SDK Release Archives
if: ${{ inputs.dry-run-enabled != true && inputs.version-policy == 'specified' && !cancelled() && !failure() }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/node-zxc-compile-application-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,9 @@ jobs:
) &&
!cancelled()
}}
run: sed -i 's/^org.gradle.configuration-cache=.*$/org.gradle.configuration-cache=false/' gradle.properties
run: |
sed -i 's/^org.gradle.configuration-cache=.*$/org.gradle.configuration-cache=false/' gradle.properties
touch build.gradle.kts
- name: Setup Snyk
env:
Expand Down
6 changes: 6 additions & 0 deletions developers.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is here for 'hapi', because that "product" is missing the toplevel folder
# (it contains the 'hapi' module directly)
[email protected]=Hedera Base Team
[email protected]=Hedera Services Team
[email protected]=Hedera Smart Contracts Team
[email protected]=Release Engineering Team
7 changes: 2 additions & 5 deletions example-apps/swirlds-platform-base-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
* limitations under the License.
*/

plugins {
id("application")
id("com.hedera.gradle.platform")
}
plugins { id("com.hedera.gradle.module.application") }

mainModuleInfo {
annotationProcessor("com.swirlds.config.processor")
annotationProcessor("com.google.auto.service.processor")
runtimeOnly("com.swirlds.config.impl")
}

application.mainClass.set("com.swirlds.platform.base.example.Application")
application.mainClass = "com.swirlds.platform.base.example.Application"
1 change: 1 addition & 0 deletions gradle/development-branch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
develop
38 changes: 38 additions & 0 deletions gradle/hedera-gradle-conventions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.
* 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.
*/

plugins {
`kotlin-dsl`
}

repositories { gradlePluginPortal() }

dependencies {
implementation("com.adarshr:gradle-test-logger-plugin:4.0.0")
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:2.0.1")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
implementation("com.gradle:develocity-gradle-plugin:3.18")
implementation(
"gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.2"
)
implementation("io.github.gradle-nexus:publish-plugin:1.3.0")
implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.2")
implementation("net.swiftzer.semver:semver:1.3.0")
implementation("org.gradlex:extra-java-module-info:1.8")
implementation("org.gradlex:jvm-dependency-conflict-resolution:2.1.2")
implementation("org.gradlex:java-module-dependencies:1.7")
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ plugins {
id("org.gradlex.extra-java-module-info")
}

jvmDependencyConflicts.consistentResolution {
providesVersions(":reports")
platform(":hedera-dependency-versions")
}

// Fix or enhance the metadata of third-party Modules. This is about the metadata in the
// repositories: '*.pom' and '*.module' files.
jvmDependencyConflicts.patch {
Expand Down Expand Up @@ -256,3 +261,6 @@ extraJavaModuleInfo {
module("org.testcontainers:testcontainers", "org.testcontainers")
module("org.mockito:mockito-junit-jupiter", "org.mockito.junit.jupiter")
}

// In case published versions of a module are also available, always prefer the local one
configurations.all { resolutionStrategy.preferProjectModules() }
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,21 @@
* limitations under the License.
*/

plugins {
id("base")
id("com.diffplug.spotless")
}
plugins { id("base") }

// Convenience for local development: when running './gradlew' without any parameters just show the
// tasks from the 'build' group
// Convenience for local development: when running './gradlew' without any parameters show the tasks
// from the 'build' group
defaultTasks("tasks")

tasks.named<TaskReportTask>("tasks") {
if (!isDetail) {
displayGroup = "build"
}
tasks.register("qualityCheck") {
group = "build"
description = "Run all spotless and quality checks."
dependsOn(tasks.assemble)
}

tasks.register("qualityGate") {
group = "build"
description = "Apply spotless rules and run all quality checks."
dependsOn(tasks.spotlessApply)
dependsOn(tasks.assemble)
}

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) 2016-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 @@ -14,4 +14,9 @@
* limitations under the License.
*/

plugins { id("com.hedera.gradle.root") }
version =
providers
.fileContents(isolated.rootProject.projectDirectory.file("version.txt"))
.asText
.get()
.trim()
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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.
* 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.
*/

import org.gradlex.javamodule.dependencies.initialization.JavaModulesExtension
import org.gradlex.javamodule.dependencies.initialization.RootPluginsExtension

plugins {
id("org.gradlex.java-module-dependencies")
id("com.hedera.gradle.feature.build-cache")
id("com.hedera.gradle.feature.repositories")
id("com.hedera.gradle.report.develocity")
}

// Allow projects inside a build to be addressed by dependency coordinates notation.
// https://docs.gradle.org/current/userguide/composite_builds.html#included_build_declaring_substitutions
// Some functionality of the 'java-module-dependencies' plugin relies on this.
includeBuild(".")

configure<JavaModulesExtension> {
// Project to aggregate code coverage data for the whole repository into one report
module("gradle/reports")

// "BOM" with versions of 3rd party dependencies
versions("hedera-dependency-versions")
}

// Plugins that are global, but are applied to the "root project" instead of settings.
// by having this block here, we do not require a "build.gradle.kts" in the repository roots.
configure<RootPluginsExtension> {
id("com.hedera.gradle.base.lifecycle")
id("com.hedera.gradle.feature.publish-maven-central.root")
id("com.hedera.gradle.feature.versioning")
id("com.hedera.gradle.check.spotless")
id("com.hedera.gradle.check.spotless-kotlin")
id("com.hedera.gradle.check.spotless-markdown")
id("com.hedera.gradle.check.spotless-misc")
id("com.hedera.gradle.check.spotless-yaml")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.
*/

import com.autonomousapps.DependencyAnalysisSubExtension
import org.gradlex.javamodule.dependencies.tasks.ModuleDirectivesOrderingCheck
import org.gradlex.javamodule.dependencies.tasks.ModuleDirectivesScopeCheck

plugins {
id("com.autonomousapps.dependency-analysis")
id("com.hedera.gradle.base.lifecycle")
id("com.hedera.gradle.base.jpms-modules")
}

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

// Do not report dependencies from one source set to another as 'required'.
// In particular, in case of test fixtures, the analysis would suggest to
// add as testModuleInfo { require(...) } to the main module. This is
// conceptually wrong, because in whitebox testing the 'main' and 'test'
// module are conceptually considered one module (main module extended with tests)
configure<DependencyAnalysisSubExtension> { issues { onAny { exclude(project.path) } } }

tasks.named("qualityGate") { dependsOn(tasks.withType<ModuleDirectivesScopeCheck>()) }
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import com.hedera.gradle.spotless.RepairDashedCommentsFormatterStep
import com.hedera.gradle.spotless.SortModuleInfoRequiresStep
import com.hedera.gradle.spotless.StripOldLicenseFormatterStep

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

spotless {
java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

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

spotless {
kotlinGradle {
Expand All @@ -39,8 +39,18 @@ spotless {
*/${"\n\n"}
"""
.trimIndent(),
"(import|plugins|pluginManagement|dependencyResolutionManagement|repositories|tasks|allprojects|subprojects)"
"(import|plugins|pluginManagement|dependencyResolutionManagement|repositories|tasks|allprojects|subprojects|buildCache|version)"
)
.updateYearWithLatest(true)
}

if (project.parent == null) {
// If this is the root project, we also check Gradle plugin scripts
kotlinGradle { target("gradle/plugins/**/*.gradle.kts") }
kotlin {
// For the Kotlin classes (*.kt files)
ktfmt().kotlinlangStyle()
target("gradle/plugins/**/*.kt")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
* limitations under the License.
*/

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

spotless {
flexmark {
target("**/*.md")
targetExclude("platform-sdk/sdk/**")
flexmark()
trimTrailingWhitespace()
indentWithSpaces()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
* limitations under the License.
*/

plugins {
id("java-library")
id("com.hedera.gradle.java")
plugins { id("com.diffplug.spotless") }

spotless {
format("misc") {
// define the files to apply `misc` to
target(".gitignore")

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,6 @@
plugins { id("com.diffplug.spotless") }

spotless {
// Disable the automatic application of Spotless to all source sets when the check task is run.
isEnforceCheck = false

// optional: limit format enforcement to just the files changed by this feature branch
ratchetFrom("origin/develop")

format("misc") {
// define the files to apply `misc` to
target(".gitignore")

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}

format("actionYaml") {
target(".github/workflows/*.yaml")
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.
* 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.
*/

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

spotless {
// Disable the automatic application of Spotless to all source sets when the check task is run.
isEnforceCheck = false

// limit format enforcement to just the files changed by this feature branch
@Suppress("UnstableApiUsage")
ratchetFrom(
"origin/" +
providers
.fileContents(
isolated.rootProject.projectDirectory.file("gradle/development-branch.txt")
)
.asText
.getOrElse("main")
)
}

tasks.withType<JavaCompile>().configureEach {
// When doing a 'qualityGate' run, make sure spotlessApply is done before doing compilation and
// other checks based on compiled code
mustRunAfter(tasks.spotlessApply)
}

tasks.named("qualityCheck") { dependsOn(tasks.spotlessCheck) }

tasks.named("qualityGate") { dependsOn(tasks.spotlessApply) }
Loading

0 comments on commit 4294d00

Please sign in to comment.