Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions acceptance-tests/detached-test-plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Test plugins for Besu Acceptance Tests

## Summary

This project consists of test plugins, used for Besu acceptance tests, they are developed using the [Gradle plugin for Besu plugins](https://github.com/Consensys/besu-plugin-gradle-plugin).
This way the acceptance tests are closer to the standard way of using plugins, and it is also compatible with the plugin verification on startup implemented by Besu.

To achieve that the test-plugins subproject had to be moved to this detached project, due to circular dependencies between Besu and the Gradle plugin. The move as basically no impact to the DevUX in case you are not touching these plugins, since Gradle on Besu will take care of building this project when needed.
More in the technical details, since the Gradle plugin needs to know the version of Besu to use, and we want to use the current local development version,
before building anything in the detached project, Besu project must publish its artifacts to mavenLocal, for this helper tasks have been added to Besu's `build.gradle` to automate that part, and normally a developer should not know about them, because the normal development workflow remains the same, unless you need to work directly on the test plugins, in that case follow to the next section.

## Test plugins development

In case you need to work on test plugins, the suggested setup is that you work on this project as it is independent,
so for example open it in a new IDE windows.
The `besuVersion` property is automatically fetch from main Besu project, and when compiling, Besu artifacts are published to the Maven local repo,
so you should be able to see the last changes made on the Besu side.

## Troubleshooting

In case you see that some Besu dependencies are not found when building this project, this can happen on your first build, then go to the main Besu project and run `./gradlew buildDetachedTestPlugins`
80 changes: 67 additions & 13 deletions acceptance-tests/detached-test-plugins/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,77 @@
plugins {
id 'net.consensys.besu-plugin-distribution' version '0.1.4'
id 'net.consensys.besu-plugin-distribution' version '0.1.5'
id 'com.diffplug.spotless' version '7.0.3'
}

group = 'org.hyperledger.besu.tests'
ext.besuVersion = getBesuVersion()
version = besuVersion

besuPlugin {
besuVersion = version
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

jar {
archiveFileName = 'testPlugins.jar'
manifest {
attributes(
'Specification-Title': archiveBaseName,
'Specification-Version': project.version,
'Implementation-Title': archiveBaseName,
'Implementation-Version': project.version
)
}
}
archiveFileName = 'testPlugins.jar'
manifest {
attributes(
'Specification-Title': archiveBaseName,
'Specification-Version': project.version,
'Implementation-Title': archiveBaseName,
'Implementation-Version': project.version
)
}
}

spotless {
java {
// This path needs to be relative to each project
target 'src/**/*.java'
targetExclude '**/src/reference-test/**', '**/src/main/generated/**', '**/src/test/generated/**', '**/src/jmh/generated/**'
removeUnusedImports()
googleJavaFormat('1.25.2')
importOrder 'org.hyperledger', 'java', ''
trimTrailingWhitespace()
endWithNewline()
// apply appropriate license header files.
licenseHeaderFile("${rootDir}/gradle/spotless/java.former.license").named("older").onlyIfContentMatches("^/\\*\\r?\\n.*Copyright ConsenSys AG\\.")
licenseHeaderFile("${rootDir}/gradle/spotless/java.former.date.license").named("older.year").onlyIfContentMatches("^/\\*\\r?\\n.* Copyright \\d{4} ConsenSys AG\\.")
licenseHeaderFile("${rootDir}/gradle/spotless/java.current.license").named("current").onlyIfContentMatches("^(?!/\\*\\r?\\n \\*.*(ConsenSys AG|Hyperledger Besu)\\.)")
}
// spotless check applied to build.gradle (groovy) files
groovyGradle {
target '*.gradle'
greclipse('4.31').configFile(rootProject.file('gradle/spotless/greclipse.properties'))
endWithNewline()
}
}

def preparePlugins = tasks.register('preparePlugins', GradleBuild) {
dir = file('../..')
tasks = ['prepareDetachedTestPlugins']
}

tasks.withType(JavaCompile).configureEach {
dependsOn preparePlugins
}

def getBesuVersion() {
def besuRootDir = project.projectDir.toPath().resolve('../..').toFile().canonicalFile
def gradlewPath = new File(besuRootDir, 'gradlew').absolutePath
def process = new ProcessBuilder(gradlewPath, 'printVersion', '-q')
.directory(besuRootDir)
.redirectErrorStream(true)
.start()
def output = process.inputStream.text
process.waitFor()
def versionLine = output.readLines().find { it.startsWith('Besu version:') }
if (versionLine == null) {
throw new GradleException("Could not find 'Besu version:' in output: ${output}")
}
return versionLine.replaceFirst('Besu version:\\s*', '').trim()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#Whether to use 'space', 'tab' or 'mixed' (both) characters for indentation.
#The default value is 'tab'.
org.eclipse.jdt.core.formatter.tabulation.char=space

#Number of spaces used for indentation in case 'space' characters
#have been selected. The default value is 4.
org.eclipse.jdt.core.formatter.tabulation.size=2

#Number of spaces used for indentation in case 'mixed' characters
#have been selected. The default value is 4.
org.eclipse.jdt.core.formatter.indentation.size=1

#Whether or not indentation characters are inserted into empty lines.
#The default value is 'true'.
org.eclipse.jdt.core.formatter.indent_empty_lines=false

#Number of spaces used for multiline indentation.
#The default value is 2.
groovy.formatter.multiline.indentation=1

#Length after which list are considered too long. These will be wrapped.
#The default value is 30.
groovy.formatter.longListLength=30

#Whether opening braces position shall be the next line.
#The default value is 'same'.
groovy.formatter.braces.start=same

#Whether closing braces position shall be the next line.
#The default value is 'next'.
groovy.formatter.braces.end=next

#Remove unnecessary semicolons. The default value is 'false'.
groovy.formatter.remove.unnecessary.semicolons=false

org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line

org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert

# Formatter can be buggy in CI
ignoreFormatterProblems=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright contributors to Besu.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright $YEAR ConsenSys AG.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright ConsenSys AG.
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading