Less Spotless Gradle Warnings (#2614)

* Less Spotless Gradle Warnings

Spotless and Gradle 7.x does not play nicely with using a fileTree as a
target and should be using plain strings. This should get rid of the
`Execution optimizations have been disabled`... warnings.

* Move Generated Reference Tests into the `build` dir

Generated reference test are currently generated into `src`, which is in
violation of the standard maven layouts.  They should be in the `build`
directory as they are artifacts not maintained in source control.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
pull/2618/head
Danno Ferrin 3 years ago committed by GitHub
parent 19c34514a1
commit 78c50e995c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      build.gradle
  2. 41
      ethereum/core/build.gradle
  3. 0
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/.keep
  4. 0
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/vm/generalstate/.keep

@ -116,16 +116,7 @@ allprojects {
spotless {
java {
// This path needs to be relative to each project
target fileTree('.') {
include '**/src/*/java/**/*.java'
exclude '**/generalstate/GeneralStateReferenceTest*.java'
exclude '**/generalstate/GeneralStateRegressionReferenceTest*.java'
exclude '**/generalstate/LegacyGeneralStateReferenceTest*.java'
exclude '**/blockchain/BlockchainReferenceTest*.java'
exclude '**/blockchain/LegacyBlockchainReferenceTest*.java'
exclude '**/reference-test/resources/docker_interop/**'
exclude '**/.gradle/**'
}
target '**/src/*/java/**/*.java'
removeUnusedImports()
googleJavaFormat('1.10.0')
importOrder 'org.hyperledger', 'java', ''
@ -137,20 +128,10 @@ allprojects {
greclipse().configFile(rootProject.file('gradle/formatter.properties'))
endWithNewline()
}
// Below this line are currently only license header tasks
format 'groovy', { target '**/src/*/grovy/**/*.groovy' }
// Currently disabled due to referencetest issues
// format 'bash', {
// target fileTree('.') {
// include '**/*.sh'
// exclude '**/ansible/**'
// }
// }
// format 'sol', {
// target fileTree('.') { include '**/*.sol' }
// }
format 'bash', { target '**/*.sh' }
format 'sol', { target '**/*.sol' }
}
tasks.withType(JavaCompile) {

@ -27,6 +27,16 @@ jar {
}
}
sourceSets {
test {
java {
compileClasspath += main.output
runtimeClasspath += main.output
srcDirs += file('./build/generated/sources/referencetests/java/test')
}
}
}
dependencies {
annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess'
@ -115,6 +125,7 @@ test {
}
def generateTestFiles(FileTree jsonPath, File templateFile, String pathstrip, String destination, String namePrefix, String ... excludedPath) {
mkdir(destination)
def referenceTestTemplate = templateFile.text
// This is how many json files to include in each test file
@ -143,63 +154,79 @@ def generateTestFiles(FileTree jsonPath, File templateFile, String pathstrip, St
}
task blockchainReferenceTestsSetup {
inputs.files fileTree('../referencetests/src/test/resources/BlockchainTests')
outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain"
generateTestFiles(
fileTree('../referencetests/src/test/resources/BlockchainTests'),
file("./src/test/resources/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTest.java.template"),
"BlockchainTests",
"./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain",
"./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain",
"BlockchainReferenceTest",
("BlockchainTests/InvalidBlocks/bcExpectSection") // exclude test for test filling tool
)
}
task legacyBlockchainReferenceTestsSetup {
inputs.files fileTree('../referencetests/src/test/resources/LegacyTests/Constantinople/BlockchainTests')
outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain"
generateTestFiles(
fileTree('../referencetests/src/test/resources/LegacyTests/Constantinople/BlockchainTests'),
file("./src/test/resources/org/hyperledger/besu/ethereum/vm/BlockchainReferenceTest.java.template"),
"LegacyTests",
"./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain",
"./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/blockchain",
"LegacyBlockchainReferenceTest",
("BlockchainTests/InvalidBlocks/bcExpectSection") // exclude test for test filling tool
)
}
task generalstateReferenceTestsSetup {
inputs.files fileTree("../referencetests/src/test/resources/GeneralStateTests")
outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate"
generateTestFiles(
fileTree("../referencetests/src/test/resources/GeneralStateTests"),
file("./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template"),
"GeneralStateTests",
"./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate",
"./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate",
"GeneralStateReferenceTest"
)
}
task legacyGeneralstateReferenceTestsSetup {
inputs.files fileTree('../referencetests/src/test/resources/LegacyTests/Constantinople/GeneralStateTests')
outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate"
generateTestFiles(
fileTree('../referencetests/src/test/resources/LegacyTests/Constantinople/GeneralStateTests'),
file("./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template"),
"LegacyTests",
"./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate",
"./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate",
"LegacyGeneralStateReferenceTest"
)
}
task generalstateRegressionReferenceTestsSetup {
inputs.files fileTree("./src/test/resources/regressions/generalstate")
outputs.files "./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate"
generateTestFiles(
fileTree("./src/test/resources/regressions/generalstate"),
file("./src/test/resources/org/hyperledger/besu/ethereum/vm/GeneralStateReferenceTest.java.template"),
"regressions",
"./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate",
"./build/generated/sources/referencetests/java/test/org/hyperledger/besu/ethereum/vm/generalstate",
"GeneralStateRegressionReferenceTest"
)
}
//TODO delete in Jan 2022. This is left as a migration aid for reference tests moving to the build directory
task cleanupReferenceTests(type: Delete) {
delete fileTree("./src/test/java/org/hyperledger/besu/ethereum/vm/generalstate/") {
include("**/GeneralStateReferenceTest*.java")
include("**/GeneralStateRegressionReferenceTest*.java")
include("**/LegacyGeneralStateReferenceTest*.java")
include("**/LegacyGeneralStateRegressionReferenceTest*.java")
}
delete fileTree("./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/") {
include("**/BlockchainReferenceTest*.java")
include("**/LegacyBlockchainReferenceTest*.java")
}
delete fileTree("./src/test/java/org/hyperledger/besu/ethereum/vm/blockchain/") { include("**/BlockchainReferenceTest*.java") }
}
clean.dependsOn(cleanupReferenceTests)
@ -215,6 +242,8 @@ task referenceTests(type: Test, dependsOn: [
compileTestJava.mustRunAfter blockchainReferenceTestsSetup
compileTestJava.mustRunAfter generalstateReferenceTestsSetup
compileTestJava.mustRunAfter generalstateRegressionReferenceTestsSetup
compileTestJava.mustRunAfter legacyBlockchainReferenceTestsSetup
compileTestJava.mustRunAfter legacyGeneralstateReferenceTestsSetup
doFirst {
if (!file("../referencetests/src/test/resources/README.md").exists()) {
throw new GradleException("ethereum/referencetests/src/test/resources/README.md missing: please clone submodules (git submodule update --init --recursive)")

Loading…
Cancel
Save