Files
linea-monorepo/besu-plugins/linea-sequencer/gradle/dist.gradle
Alain Nicolas a3ad42a072 chore(license): update licensing (#1106)
* chore(license): update licensing

* chore(license): update licensing on Java files
2025-06-09 11:53:04 +02:00

134 lines
4.0 KiB
Groovy

/*
* Copyright Consensys Software Inc.
*
* This file is dual-licensed under either the MIT license or Apache License 2.0.
* See the LICENSE-MIT and LICENSE-APACHE files in the repository root for details.
*
* SPDX-License-Identifier: MIT OR Apache-2.0
*/
def lineaSequencerProject = project(lineaSequencerProjectPath)
tasks.register('sourcesJar', Jar) {
dependsOn classes
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
def besuDistTar = new File(new File(buildDir, "downloads"), lineaSequencerProject.besuFilename)
task downloadBesu {
outputs.file(besuDistTar)
doLast {
try {
download.run {
src lineaSequencerProject.besuUrl
dest besuDistTar
onlyIfModified true
}
} catch (Exception e) {
def localBesuDir =
project.hasProperty('useLocalBesuDir')
? file("${findProperty('useLocalBesuDir')}".replaceFirst('^~', System.getProperty('user.home')))
: new File(projectDir, "../../besu")
def localBesuFile = new File("${localBesuDir.canonicalPath}/build/distributions/${lineaSequencerProject.besuFilename}")
logger.warn("Could not download " + lineaSequencerProject.besuUrl + " trying local copy from " + localBesuFile + " as fallback")
if (!file(localBesuFile).exists()) {
throw new GradleException("Could not download Besu distribution from: " + lineaSequencerProject.besuUrl +
", and could not find it locally at ${localBesuFile} either")
}
copy {
from localBesuFile
into besuDistTar.parentFile
}
}
}
}
task unTarBesu(type: Copy) {
dependsOn downloadBesu
from tarTree(besuDistTar)
into besuDistTar.parentFile
}
def besuLibDir = new File(besuDistTar.parentFile, lineaSequencerProject.besuIdentifier + '/lib')
def besuLibs = []
def excludeBesuProvidedDeps = {
if(besuLibs.isEmpty()) {
// Get all the dependencies that are provided by Besu
fileTree(dir: besuLibDir, include: '*.jar').visit {
FileVisitDetails details ->
besuLibs << details.file.name
}
}
// include the dependency in the jar only if it is not already provided by Besu
!besuLibs.any { artifactName ->
if(artifactName == it.name) {
return true
}
// exclude Besu group
if(it.toString().contains(besuArtifactGroup)) {
return true
}
// try ignoring the version
def libName = it.name =~ dependencyNamePattern()
def artName = artifactName =~ dependencyNamePattern()
libName[0][1] == artName[0][1]
}
}
jar {
dependsOn unTarBesu
archiveBaseName = lineaSequencerProject.distributionIdentifier
version = calculateVersion()
manifest {
attributes(
'Specification-Title': 'arithmetization',
'Specification-Version': "${libs.versions.arithmetization.get()}",
'Implementation-Title': 'arithmetization',
'Implementation-Version': "${libs.versions.arithmetization.get()}"
)
}
from {
configurations.runtimeClasspath.filter(excludeBesuProvidedDeps).collect {
it.isDirectory() ? it : zipTree(it)
}
}
duplicatesStrategy('exclude')
}
/**
* Create a distribution of the plugin, that only contains the plugin jar and the
* dependencies that are not provided by Besu itself, so that is can be simply
* extracted in the Besu plugins dir.
*/
tasks.register('distPlugin', Zip) {
dependsOn installDist
archiveBaseName = lineaSequencerProject.distributionIdentifier
from("${buildDir}/libs/${lineaSequencerProject.distributionIdentifier}-${calculateVersion()}.jar")
from {
configurations.runtimeClasspath.filter(
excludeBesuProvidedDeps)
}
}
static def dependencyNamePattern() {
/(.*)(\-.*?)\.jar/
}