blob: 91d04ddbaacfc894a6be87d1e3072e525c3f4ed4 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
* file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to You 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.
*/
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import org.gradle.crypto.checksum.Checksum
plugins { id 'com.bmuschko.docker-remote-api' version '3.2.3' }
description = 'Tuweni distribution.'
apply plugin: 'distribution'
jar { enabled = false }
static def mandatoryFiles(CopySpec spec) {
spec.into('') {
from ".."
include 'DISCLAIMER'
include 'LICENSE'
include 'NOTICE'
}
spec.into('licenses') { from '../build/reports/license' }
}
task builtGradleProperties() {
doLast {
project.buildDir.mkdirs()
new File(project.buildDir, "gradle.properties").text = """
# Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
# file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
# to You 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.
buildRelease=true
kotlin.code.style=official
asfNexusUsername=none
asfNexusPassword=
"""
}
}
assemble.dependsOn builtGradleProperties
distributions {
main {
distributionBaseName = 'tuweni-bin'
contents {
mandatoryFiles(it)
into('') {
from ".."
include 'README.md'
}
def libs = []
def sources = []
rootProject.subprojects.each { s ->
if (s.name != 'eth-reference-tests' && s.name != 'eth2-reference-tests' && s.name != 'dist') {
libs << s.signArchives.signatureFiles[0]
sources << s.signArchives.signatureFiles[1]
libs << s.jar.outputs
sources << s.sourcesJar.outputs
}
}
into('lib') {
from rootProject.jar
from rootProject.signArchives.signatureFiles[0]
from libs
}
into('site') {
from rootProject.dokka.outputDirectory
}
into('bin') {
from { project(':gossip').startScripts.outputs.files }
from { project(':hobbits-relayer').startScripts.outputs.files }
from { project(':eth-client-app').startScripts.outputs.files }
from { project(':devp2p').startScripts.outputs.files }
fileMode = 0755
}
}
}
sources {
distributionBaseName = 'tuweni-src'
contents {
into('') {
from 'build'
include 'gradle.properties'
}
mandatoryFiles(it)
into('') {
from ".."
include 'README.md'
include 'build.sh'
include 'build.bat'
include '*.md'
include '*.gradle'
include 'dependency-versions.gradle'
include 'gradle/resources/*'
include 'gradle/*'
include 'gradle/docker/*'
}
rootProject.subprojects.each { s ->
into(s.name) {
from s.projectDir.toPath().resolve("build.gradle")
}
into("${s.name}/src/main") {
from s.projectDir.toPath().resolve("src/main")
}
}
}
}
}
task addDependencies() {
doLast {
def deps = []
rootProject.subprojects.each { s ->
s.configurations.runtimeClasspath.each {
if (!it.toString().contains("libs/tuweni")) {
deps << it
}
}
}
deps = deps.unique()
distributions.main.contents.into('lib') {
from(deps)
}
}
}
distZip.dependsOn addDependencies
distTar.dependsOn addDependencies
rootProject.subprojects.each {
if (it != project) {
project.distZip.dependsOn it.assemble
project.distTar.dependsOn it.assemble
project.sourcesDistZip.dependsOn it.sourcesJar
project.sourcesDistTar.dependsOn it.sourcesJar
}
}
sourcesDistZip { zip64 = true }
distTar { compression = Compression.GZIP }
sourcesDistTar { compression = Compression.GZIP }
if (System.getenv('ENABLE_SIGNING') == 'true') {
signing {
useGpgCmd()
sign distZip
sign distTar
sign sourcesDistZip
sign sourcesDistTar
}
}
task createChecksums(type: Checksum, dependsOn: [
'distZip',
'distTar',
'sourcesDistZip',
'sourcesDistTar',
]) {
files = distZip.outputs.files + distTar.outputs.files + sourcesDistZip.outputs.files + sourcesDistTar.outputs.files
outputDir = new File(project.buildDir, "distributions")
algorithm = Checksum.Algorithm.SHA512
}
build.dependsOn('createChecksums')
task buildGossipImage(type: DockerBuildImage) {
dependsOn distTar
inputDir = projectDir
dockerFile = file("docker/gossip.Dockerfile")
tag = "apache-tuweni/gossip:$project.version"
}
task buildRelayerImage(type: DockerBuildImage) {
dependsOn distTar
inputDir = projectDir
dockerFile = file("docker/relayer.Dockerfile")
tag = "apache-tuweni/relayer:$project.version"
}
integrationTest.dependsOn build
dependencies {
integrationTestImplementation 'org.junit.jupiter:junit-jupiter-api'
integrationTestImplementation 'org.junit.jupiter:junit-jupiter-params'
integrationTestRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}