Skip to content

Commit bcfef99

Browse files
committed
Improve and document how to work with detached test plugins project
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
1 parent 37f44c1 commit bcfef99

File tree

8 files changed

+412
-3
lines changed

8 files changed

+412
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Test plugins for Besu Acceptance Tests
2+
3+
## Summary
4+
5+
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).
6+
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.
7+
8+
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.
9+
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,
10+
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.
11+
12+
## Test plugins development
13+
14+
In case you need to work on test plugins, the suggested setup is that you work on this project as it is independent,
15+
so for example open it in a new IDE windows.
16+
The `besuVersion` property is automatically fetch from main Besu project, and when compiling, Besu artifacts are published to the Maven local repo,
17+
so you should be able to see the last changes made on the Besu side.
18+
19+
## Troubleshooting
20+
21+
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`

acceptance-tests/detached-test-plugins/build.gradle

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
plugins {
2-
id 'net.consensys.besu-plugin-distribution' version '0.1.4'
2+
id 'net.consensys.besu-plugin-distribution' version '0.1.5'
33
}
44

55
group = 'org.hyperledger.besu.tests'
6+
ext.besuVersion = getBesuVersion()
67
version = besuVersion
78

9+
besuPlugin {
10+
besuVersion = version
11+
}
12+
813
java {
914
sourceCompatibility = JavaVersion.VERSION_21
1015
targetCompatibility = JavaVersion.VERSION_21
@@ -20,4 +25,29 @@ jar {
2025
'Implementation-Version': project.version
2126
)
2227
}
28+
}
29+
30+
def preparePlugins = tasks.register('preparePlugins', GradleBuild) {
31+
dir = file('../..')
32+
tasks = ['prepareDetachedTestPlugins']
33+
}
34+
35+
tasks.withType(JavaCompile).configureEach {
36+
dependsOn preparePlugins
37+
}
38+
39+
def getBesuVersion() {
40+
def besuRootDir = project.projectDir.toPath().resolve('../..').toFile().canonicalFile
41+
def gradlewPath = new File(besuRootDir, 'gradlew').absolutePath
42+
def process = new ProcessBuilder(gradlewPath, 'printVersion', '-q')
43+
.directory(besuRootDir)
44+
.redirectErrorStream(true)
45+
.start()
46+
def output = process.inputStream.text
47+
process.waitFor()
48+
def versionLine = output.readLines().find { it.startsWith('Besu version:') }
49+
if (versionLine == null) {
50+
throw new GradleException("Could not find 'Besu version:' in output: ${output}")
51+
}
52+
return versionLine.replaceFirst('Besu version:\\s*', '').trim()
2353
}
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

acceptance-tests/detached-test-plugins/gradlew

Lines changed: 251 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)