Skip to content

Commit

Permalink
merge from upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony Petrov <anthony@swirldslabs.com>
  • Loading branch information
anthony-swirldslabs committed Feb 13, 2024
2 parents 36b45cd + e0eef7e commit b883243
Show file tree
Hide file tree
Showing 49 changed files with 370 additions and 692 deletions.
6 changes: 3 additions & 3 deletions build-logic/project-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ dependencies {
)
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.6.1")
implementation("org.gradlex:java-ecosystem-capabilities:1.3.1")
implementation("org.gradlex:java-module-dependencies:1.5")
implementation("org.gradlex:extra-java-module-info:1.8")
implementation("org.gradlex:java-ecosystem-capabilities:1.5.1")
implementation("org.gradlex:java-module-dependencies:1.6.1")
implementation("org.owasp:dependency-check-gradle:9.0.9")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 org.gradle.api.component.AdhocComponentWithVariants
import org.gradle.kotlin.dsl.get

/*
* 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("java-test-fixtures") }

tasks.testFixturesJar { setGroup(null) }

// Disable publishing of test fixture if 'java-test-fixtures' plugin is used
// https://docs.gradle.org/current/userguide/java_testing.html#ex-disable-publishing-of-test-fixtures-variants
(components["java"] as AdhocComponentWithVariants).apply {
withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() }
withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ import Utils.Companion.versionTxt
import com.adarshr.gradle.testlogger.theme.ThemeType
import com.autonomousapps.AbstractExtension
import com.autonomousapps.DependencyAnalysisSubExtension
import com.hedera.hashgraph.gradlebuild.service.TaskLockService
import com.hedera.hashgraph.gradlebuild.services.TaskLockService

plugins {
id("java")
id("jacoco")
id("checkstyle")
id("com.adarshr.test-logger")
id("com.hedera.hashgraph.lifecycle")
id("com.hedera.hashgraph.jpms-modules")
id("com.hedera.hashgraph.jpms-module-dependencies")
id("com.hedera.hashgraph.repositories")
Expand Down Expand Up @@ -60,7 +61,16 @@ configurations.getByName("mainRuntimeClasspath") { extendsFrom(internal.get()) }

dependencies { "internal"(platform("com.hedera.hashgraph:hedera-dependency-versions")) }

tasks.buildDependents { setGroup(null) }

tasks.buildNeeded { setGroup(null) }

tasks.jar { setGroup(null) }

sourceSets.all {
// Remove 'classes' tasks from 'build' group to keep it cleaned up
tasks.named(classesTaskName) { group = null }

configurations.getByName(compileClasspathConfigurationName) { extendsFrom(internal.get()) }
configurations.getByName(runtimeClasspathConfigurationName) { extendsFrom(internal.get()) }

Expand Down Expand Up @@ -162,6 +172,7 @@ testing {
useJUnitJupiter()
targets.all {
testTask {
group = "build"
maxHeapSize = "4g"
// Some tests overlap due to using the same temp folders within one project
// maxParallelForks = 4 <- set this, once tests can run in parallel
Expand All @@ -174,6 +185,7 @@ testing {
testType.set("hammer")
targets.all {
testTask {
group = "build"
shouldRunAfter(tasks.test)
usesService(
gradle.sharedServices.registerIfAbsent("lock", TaskLockService::class) {
Expand All @@ -190,6 +202,7 @@ testing {
testType.set("time-consuming")
targets.all {
testTask {
group = "build"
shouldRunAfter(tasks.test)
maxHeapSize = "16g"
}
Expand All @@ -201,6 +214,7 @@ testing {
testType.set(TestSuiteType.INTEGRATION_TEST)
targets.all {
testTask {
group = "build"
shouldRunAfter(tasks.test)
maxHeapSize = "8g"
addTestListener(testLogger())
Expand All @@ -213,8 +227,10 @@ testing {
testType.set("end-to-end-test")
targets.all {
testTask {
group = "build"
shouldRunAfter(tasks.test)
maxHeapSize = "8g"
jvmArgs("-XX:ActiveProcessorCount=6")
}
}
}
Expand All @@ -232,6 +248,22 @@ testing {
}
}

// If user gave the argument '-PactiveProcessorCount', then do:
// - run all test tasks in sequence
// - give the -XX:ActiveProcessorCount argument to the test JVMs
val activeProcessorCount = providers.gradleProperty("activeProcessorCount")

if (activeProcessorCount.isPresent) {
tasks.withType<Test>().configureEach {
usesService(
gradle.sharedServices.registerIfAbsent("lock", TaskLockService::class) {
maxParallelUsages = 1
}
)
jvmArgs("-XX:ActiveProcessorCount=${activeProcessorCount.get()}")
}
}

tasks.jacocoTestReport {
// Configure Jacoco so it outputs XML reports (needed by SonarCloud)
reports {
Expand Down Expand Up @@ -263,6 +295,14 @@ tasks.assemble {

tasks.check { dependsOn(tasks.jacocoTestReport) }

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

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

// 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
Expand Down

0 comments on commit b883243

Please sign in to comment.