diff --git a/arithmetization/build.gradle b/arithmetization/build.gradle index 980f759d4..6de4224a6 100644 --- a/arithmetization/build.gradle +++ b/arithmetization/build.gradle @@ -15,6 +15,7 @@ plugins { id 'java' + id 'java-library-distribution' id 'common-plugins' id 'com.github.hierynomus.license' id "de.undercouch.download" @@ -34,51 +35,39 @@ apply from: rootProject.file("gradle/lint.gradle") apply from: rootProject.file("gradle/trace-files.gradle") dependencies { + /** + * Use pluginImplementation for dependencies that are specific to this plugin + * and are not already provided by Besu. + * These dependencies are the only ones that are included in the final jar. + */ + pluginImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' + // annotationProcessor generates the file META-INF/services/org.hyperledger.besu.plugin.BesuPlugin annotationProcessor 'com.google.auto.service:auto-service' - compileOnly "${besuArtifactGroup}:evm" - compileOnly 'com.google.auto.service:auto-service' - compileOnly 'com.google.auto.service:auto-service-annotations' + implementation "${besuArtifactGroup}:besu-datatypes" implementation "${besuArtifactGroup}:evm" implementation "${besuArtifactGroup}:plugin-api" - implementation "${besuArtifactGroup}:besu-datatypes" + implementation "${besuArtifactGroup}.internal:algorithms" implementation "${besuArtifactGroup}.internal:api" implementation "${besuArtifactGroup}.internal:clique" implementation "${besuArtifactGroup}.internal:core" implementation "${besuArtifactGroup}.internal:rlp" - implementation "${besuArtifactGroup}.internal:algorithms" - implementation 'info.picocli:picocli' + implementation 'com.google.auto.service:auto-service' - implementation 'io.vertx:vertx-core' - implementation 'io.vertx:vertx-web' - - implementation 'com.fasterxml.jackson.core:jackson-databind' - implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' + implementation 'info.picocli:picocli' implementation 'io.tmio:tuweni-bytes' implementation 'io.tmio:tuweni-units' implementation 'io.tmio:tuweni-toml' - implementation 'org.bouncycastle:bcprov-jdk18on' - implementation 'org.hibernate.validator:hibernate-validator' + + implementation 'io.vertx:vertx-web' testImplementation project(path: ':testing') - testImplementation "${besuArtifactGroup}:evm" - testImplementation "${besuArtifactGroup}:besu-datatypes" - testImplementation "${besuArtifactGroup}.internal:core" - testImplementation "${besuArtifactGroup}.internal:rlp" - testImplementation "${besuArtifactGroup}.internal:core" - testImplementation "${besuArtifactGroup}.internal:referencetests" testImplementation 'org.junit.platform:junit-platform-launcher' } -configurations { - installedJars { - transitive = false - } -} - apply from: rootProject.file("gradle/dist.gradle") apply from: rootProject.file("gradle/publishing.gradle") diff --git a/gradle/dependency-management.gradle b/gradle/dependency-management.gradle index b11d13987..7079c5972 100644 --- a/gradle/dependency-management.gradle +++ b/gradle/dependency-management.gradle @@ -26,20 +26,20 @@ repositories { url 'https://artifacts.consensys.net/public/maven/maven/' content { includeGroupByRegex('tech\\.pegasys(\\..*)?') } } - maven { - url 'https://splunk.jfrog.io/splunk/ext-releases-local' - content { includeGroupByRegex('com\\.splunk\\..*') } - } mavenCentral() mavenLocal() } -configurations.all { - resolutionStrategy { - cacheChangingModulesFor 0, 'seconds' +configurations { + pluginImplementation + resolvable('pluginClasspath') { + extendsFrom(pluginImplementation) } } +sourceSets.main.compileClasspath += configurations.pluginImplementation +sourceSets.main.runtimeClasspath += configurations.pluginImplementation + apply plugin: 'io.spring.dependency-management' dependencyManagement { @@ -58,6 +58,8 @@ dependencyManagement { entry 'logback-classic' } + dependency 'com.google.code.gson:gson:2.11.0' + dependency 'com.slack.api:slack-api-client:1.32.1' } } diff --git a/gradle/dist.gradle b/gradle/dist.gradle index 5f2ba132d..9e14e85e5 100644 --- a/gradle/dist.gradle +++ b/gradle/dist.gradle @@ -1,5 +1,3 @@ -import de.undercouch.gradle.tasks.download.Download - /* * Copyright Consensys Software Inc. * @@ -14,6 +12,7 @@ import de.undercouch.gradle.tasks.download.Download * * SPDX-License-Identifier: Apache-2.0 */ +import de.undercouch.gradle.tasks.download.Download tasks.register('sourcesJar', Jar) { dependsOn classes @@ -29,7 +28,59 @@ tasks.register('javadocJar', Jar) { version = project.hasProperty('releaseVersion') ? project.getProperty('releaseVersion') : 'snapshot' +def lineaBesuDistTar = new File(new File(buildDir, "tmp"), rootProject.besuFilename) +tasks.register('downloadLineaBesu', Download) { + src rootProject.besuUrl + dest lineaBesuDistTar + onlyIfModified true +} + +tasks.register('copyLocalLineaBesu', Copy) { + onlyIf { + downloadLineaBesu.state.failure + } + def localLineaBesuDir = + project.hasProperty('useLocalLineaBesuDir') + ? file("${findProperty('useLocalLineaBesuDir')}".replaceFirst('^~', System.getProperty('user.home'))) + : new File(projectDir, "../../linea-besu") + + def localLineaBesuFile = new File("${localLineaBesuDir.absoluteFile}/build/distributions/${rootProject.besuFilename}") + doFirst { + if (!file(localLineaBesuFile).exists()) { + throw new GradleException("Could not download Linea Besu distribution from: " + rootProject.besuUrl + + ", and could not find it locally at ${localLineaBesuFile} either") + } + } + from localLineaBesuFile + into lineaBesuDistTar.parentFile +} + +task unTarLineaBesu(type: Copy) { + dependsOn downloadLineaBesu + dependsOn copyLocalLineaBesu + + from tarTree(lineaBesuDistTar) + into lineaBesuDistTar.parentFile +} + +// Get all the dependencies that are provided by Besu, removing the version and suffix +def lineaBesuLibDir = new File(lineaBesuDistTar.parentFile, rootProject.besuIdentifier + '/lib') +def lineaBesuLibs = [] +fileTree(dir: lineaBesuLibDir, include: '*.jar').visit { + FileVisitDetails details -> + def libPrefix = details.file.name =~ dependencyNamePattern() + lineaBesuLibs << libPrefix[0][1] +} + +def excludeBesuProvidedDeps = { + // include the dependency in the jar only if it is not already provided by Besu + def libName = it.name =~ dependencyNamePattern() + def libPrefix = libName[0][1] + !lineaBesuLibs.contains(libPrefix) +} + jar { + dependsOn unTarLineaBesu archiveBaseName = distributionIdentifier manifest { @@ -41,12 +92,12 @@ jar { ) } + from { - configurations.runtimeClasspath.filter( {! (it.name =~ /log4j.*\.jar/ ) && ! (it.name =~ /vertx.*\.jar/ ) && it.name != 'jc-kzg-4844-2.0.0.jar'} ) - .collect {it.isDirectory() ? it : zipTree(it) } + configurations.pluginClasspath.filter(excludeBesuProvidedDeps +).collect {it.isDirectory() ? it : zipTree(it) } } - exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA', 'ch.qos.logback' - duplicatesStrategy(DuplicatesStrategy.INCLUDE) + duplicatesStrategy('exclude') } // Takes the version, and if -SNAPSHOT is part of it replaces SNAPSHOT @@ -60,7 +111,27 @@ def calculateVersion() { return version } +/** + * 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 + + from("${buildDir}/libs") + from { + configurations.pluginClasspath.filter( + excludeBesuProvidedDeps) + + } +} + static def getCheckedOutGitCommitHash() { def hashLength = 8 "git rev-parse HEAD".execute().text.take(hashLength) } + +static def dependencyNamePattern() { + /(.*)(\-.*?)\.jar/ +} \ No newline at end of file diff --git a/testing/build.gradle b/testing/build.gradle index aecee8c3b..def0471af 100644 --- a/testing/build.gradle +++ b/testing/build.gradle @@ -16,8 +16,10 @@ apply from: rootProject.file("gradle/lint.gradle") dependencies { implementation project(path: ':arithmetization') + implementation "${besuArtifactGroup}:besu-datatypes" implementation "${besuArtifactGroup}:evm" + implementation "${besuArtifactGroup}:plugin-api" implementation "${besuArtifactGroup}.internal:clique" implementation "${besuArtifactGroup}.internal:common" implementation "${besuArtifactGroup}.internal:config" @@ -28,17 +30,12 @@ dependencies { implementation "${besuArtifactGroup}.internal:services" implementation "${besuArtifactGroup}.internal:testutil" implementation "${besuArtifactGroup}.internal:algorithms" - implementation "${besuArtifactGroup}:plugin-api" - implementation 'org.junit.platform:junit-platform-launcher' - implementation 'org.junit.jupiter:junit-jupiter-api' - runtimeOnly 'org.junit.jupiter:junit-jupiter-engine' - implementation 'org.junit.jupiter:junit-jupiter-params' - runtimeOnly 'org.junit.vintage:junit-vintage-engine' + implementation 'com.google.code.gson:gson' + implementation 'com.google.guava:guava' - implementation 'org.mockito:mockito-core' - implementation 'org.mockito:mockito-junit-jupiter' implementation 'org.assertj:assertj-core' + implementation 'org.junit.jupiter:junit-jupiter-api' } node {