-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
130 lines (114 loc) · 3.46 KB
/
build.gradle
File metadata and controls
130 lines (114 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Copyright Hyperledger Besu contributors.
*
* 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
*/
plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
alias libs.plugins.git.versioning
alias libs.plugins.spotless
alias libs.plugins.besu.plugin.distribution
alias libs.plugins.errorprone
}
version = "0.0.0-SNAPSHOT"
gitVersioning.apply {
refs {
tag("\\d+\\.\\d+\\.\\d+") {
version = "\${ref}"
}
branch("main") {
version = "\${ref}-SNAPSHOT"
}
branch(".+") {
version = "\${ref}-SNAPSHOT"
}
}
rev {
version = "\${commit.short}-SNAPSHOT"
}
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
besuPlugin {
besuVersion = libs.versions.besu.asProvider().get()
}
dependencies {
errorprone libs.errorprone.core
// Use JUnit Jupiter for testing.
testImplementation libs.junit.jupiter
testImplementation libs.assertj.core
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.named('jar') {
manifest {
attributes(
'Implementation-Title': project.name,
'Implementation-Version': project.version,
)
}
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
// Integration test source set and task
sourceSets {
integrationTest {
java.srcDir 'src/integrationTest/java'
resources.srcDir 'src/integrationTest/resources'
compileClasspath += sourceSets.main.output + sourceSets.test.output
runtimeClasspath += sourceSets.main.output + sourceSets.test.output
}
}
configurations {
integrationTestImplementation.extendsFrom testImplementation
integrationTestRuntimeOnly.extendsFrom testRuntimeOnly
}
dependencies {
integrationTestImplementation libs.testcontainers
integrationTestImplementation libs.testcontainers.junit.jupiter
}
tasks.register('integrationTest', Test) {
description = 'Runs integration tests.'
group = 'verification'
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
dependsOn distZip
distZip.outputs.upToDateWhen { false }
useJUnitPlatform()
outputs.upToDateWhen { false } // Always re-run; Docker container state is not tracked by Gradle
}
spotless {
java {
importOrder('org.hyperledger', 'java', '')
removeUnusedImports()
googleJavaFormat()
licenseHeaderFile(layout.projectDirectory.file("gradle/spotless/java.license.template"))
}
// spotless check applied to build.gradle (groovy) files
groovyGradle {
target '*.gradle'
greclipse('4.31').configFile(layout.projectDirectory.file('gradle/spotless/greclipse.properties'))
endWithNewline()
}
}