1- // discovery v5
1+ buildscript {
2+ configurations. classpath {
3+ // Force JGit 6.x to resolve conflict between git-versioning (7.x) and JReleaser (5.x)
4+ // JGit 7.x removed GpgObjectSigner which JReleaser still references
5+ // See: https://github.com/jreleaser/jreleaser/discussions/1897
6+ resolutionStrategy. force ' org.eclipse.jgit:org.eclipse.jgit:6.10.0.202406032230-r'
7+ }
8+ }
29
310plugins {
411 id ' java-library'
12+ id ' maven-publish'
513 id ' com.diffplug.spotless' version ' 6.25.0'
614 id ' com.github.ben-manes.versions' version ' 0.51.0'
715 id ' com.github.hierynomus.license' version ' 0.16.1'
816 id ' io.spring.dependency-management' version ' 1.1.5'
9- id ' net.ltgt.errorprone' version ' 4.0.1'
10- id ' org.ajoberstar.grgit' version ' 5.2.2'
17+ id ' net.ltgt.errorprone' version ' 5.1.0'
18+ id ' me.qoomon.git-versioning' version ' 6.4.4'
19+ id ' org.jreleaser' version ' 1.23.0'
1120}
1221
13- rootProject. version = calculatePublishVersion()
14- def specificVersion = calculateVersion()
22+ group = " io.consensys.protocols"
23+ version = " UNKNOWN"
24+
25+ gitVersioning. apply {
26+ refs {
27+ tag(" .+" ) {
28+ version = " \$ {ref}"
29+ }
30+ branch(" master" ) {
31+ version = " develop"
32+ }
33+ branch(" release-.+" ) {
34+ version = " \$ {ref}-develop"
35+ }
36+ branch(" .+" ) {
37+ version = " \$ {ref}"
38+ }
39+ }
40+ rev {
41+ version = " UNKNOWN"
42+ }
43+ }
1544
1645apply from : " ${ rootDir} /gradle/versions.gradle"
1746apply from : " ${ rootDir} /gradle/check-licenses.gradle"
@@ -48,7 +77,7 @@ dependencies {
4877 testRuntimeOnly ' org.apache.logging.log4j:log4j-slf4j-impl'
4978
5079 errorprone(" com.google.errorprone:error_prone_core" )
51- errorprone(" tech.pegasys.tools.epchecks :errorprone-checks" )
80+ errorprone(" io.consensys.protocols :errorprone-checks" )
5281}
5382
5483spotless {
@@ -104,6 +133,8 @@ tasks.withType(JavaCompile) {
104133 check(' CanIgnoreReturnValueSuggester' , net.ltgt.gradle.errorprone.CheckSeverity . OFF )
105134 // We prefer to be more explicit in address selection especially in tests, so removing this check
106135 check(' AddressSelection' , net.ltgt.gradle.errorprone.CheckSeverity . OFF )
136+ // Interface constant initializing a subclass is intentional in IdentitySchemaInterpreter
137+ check(' ClassInitializationDeadlock' , net.ltgt.gradle.errorprone.CheckSeverity . OFF )
107138
108139 // These are experimental checks that we want enabled.
109140 check(' MissingBraces' , net.ltgt.gradle.errorprone.CheckSeverity . WARN )
@@ -135,12 +166,17 @@ tasks.withType(JavaCompile) {
135166 ' Specification-Title' : project. name,
136167 ' Specification-Version' : project. version,
137168 ' Implementation-Title' : project. name,
138- ' Implementation-Version' : specificVersion
169+ ' Implementation-Version' : project . version
139170 )
140171 }
141172 }
142173}
143174
175+ java {
176+ withJavadocJar()
177+ withSourcesJar()
178+ }
179+
144180test {
145181 jvmArgs = [
146182 ' -Xmx4g' ,
@@ -153,57 +189,43 @@ test {
153189}
154190
155191javadoc {
156- options. addStringOption(' Xdoclint:all' , ' -quiet' )
192+ options. addStringOption(' Xdoclint:all,-missing ' , ' -quiet' )
157193 options. addStringOption(' Xwerror' , ' -html5' )
158194 options. encoding = ' UTF-8'
159195}
160196
161- task sourcesJar (type : Jar , dependsOn : classes) {
162- archiveClassifier = ' sources'
163- from sourceSets. main. allSource
164- }
165-
166197task runTestDiscovery (type :JavaExec ) {
167198 mainClass = ' org.ethereum.beacon.discovery.app.DiscoveryTestServer'
168199 classpath = sourceSets. main. runtimeClasspath + sourceSets. test. runtimeClasspath
169200 systemProperty " log4j.configurationFile" , " log4j2-test-discovery.xml"
170201}
171202
172- def cloudsmithUser = project. hasProperty(' cloudsmithUser' ) ? project. property(' cloudsmithUser' ) : System . getenv(' CLOUDSMITH_USER' )
173- def cloudsmithKey = project. hasProperty(' cloudsmithApiKey' ) ? project. property(' cloudsmithApiKey' ) : System . getenv(' CLOUDSMITH_API_KEY' )
174-
175- apply plugin : ' maven-publish'
176203publishing {
177- repositories {
178- maven {
179- name = " cloudsmith"
180- url = " https://api-g.cloudsmith.io/maven/consensys/maven/"
181- credentials {
182- username = cloudsmithUser
183- password = cloudsmithKey
184- }
185- }
186- }
187204 publications {
188205 mavenJava(MavenPublication ) {
189- groupId " tech.pegasys.discovery"
190- version project. version
206+ groupId " io.consensys.protocols"
191207 from components. java
192- artifact sourcesJar
193-
194208 versionMapping {
195209 usage(' java-api' ) { fromResolutionOf(' runtimeClasspath' ) }
196210 usage(' java-runtime' ) { fromResolutionResult() }
197211 }
198212 pom {
199213 name = " ${ project.name} "
200- url = ' http://github.com/ConsenSys/discovery'
214+ description = ' Java implementation of the Ethereum Discovery v5 protocol'
215+ url = ' https://github.com/ConsenSys/discovery'
201216 licenses {
202217 license {
203218 name = ' The Apache License, Version 2.0'
204219 url = ' http://www.apache.org/licenses/LICENSE-2.0.txt'
205220 }
206221 }
222+ developers {
223+ developer {
224+ id = " consensys"
225+ name = " Protocols Team"
226+ email = " devops@consensys.net"
227+ }
228+ }
207229 scm {
208230 connection = ' scm:git:git://github.com/ConsenSys/discovery.git'
209231 developerConnection = ' scm:git:ssh://github.com/ConsenSys/discovery.git'
@@ -212,46 +234,38 @@ publishing {
212234 }
213235 }
214236 }
215- }
216-
217-
218- // Calculate the version that this build would be published under (if it is published)
219- // If this exact commit is tagged, use the tag
220- // If this is on a release-* branch, use the most recent tag appended with +develop (e.g. 0.1.1-RC1+develop)
221- // Otherwise, use develop
222- def calculatePublishVersion () {
223- if (! grgit) {
224- return ' UNKNOWN'
225- }
226- def specificVersion = calculateVersion()
227- def isReleaseBranch = grgit. branch. current(). name. startsWith(' release-' )
228- if (specificVersion. contains(' +' )) {
229- return isReleaseBranch ? " ${ specificVersion.substring(0, specificVersion.indexOf('+'))} +develop" : " develop"
237+ repositories {
238+ maven {
239+ url = layout. buildDirectory. dir(" staging-deploy" )
240+ }
230241 }
231- return specificVersion
232242}
233243
234- // Calculate the version that teku --version will report (among other places)
235- // If this exact commit is tagged, use the tag
236- // Otherwise use git describe --tags and replace the - after the tag with a +
237- def calculateVersion () {
238- if (! grgit) {
239- return ' UNKNOWN'
240- }
241- String version = grgit. describe(tags : true )
242- if (version == null ) {
243- return " UNKNOWN+g${ grgit.head().abbreviatedId} "
244+ jreleaser {
245+ release {
246+ github {
247+ // Creating and tagging a release is done manually
248+ skipRelease = true
249+ skipTag = true
250+ // injecting a fake value to make JReleaser happy
251+ token = " foobar"
252+ }
244253 }
245- def versionPattern = ~/ ^(?<lastVersion>.*)-(?<devVersion>[0-9]+-g[a-z0-9]+)$/
246- def matcher = version =~ versionPattern
247- if (matcher. find()) {
248- return " ${ matcher.group("lastVersion")} +${ matcher.group("devVersion")} "
254+ signing {
255+ active = ' ALWAYS'
256+ armored = true
249257 }
250- return version
251- }
252-
253- task printVersion () {
254- doFirst {
255- print " Specific version: ${ specificVersion} Publish version: ${ project.version} "
258+ deploy {
259+ maven {
260+ mavenCentral {
261+ sonatype {
262+ active = ' ALWAYS'
263+ url = ' https://central.sonatype.com/api/v1/publisher'
264+ stagingRepository(' build/staging-deploy' )
265+ retryDelay = 15
266+ maxRetries = 100
267+ }
268+ }
269+ }
256270 }
257271}
0 commit comments