bitcoinj/core/build.gradle

129 lines
3.4 KiB
Groovy
Raw Normal View History

import org.gradle.util.GradleVersion
plugins {
id 'java-library'
id 'com.google.protobuf'
id 'maven-publish'
id 'eclipse'
}
2021-10-10 12:09:32 +02:00
version = '0.17-SNAPSHOT'
dependencies {
api 'org.bouncycastle:bcprov-jdk15to18:1.72'
api 'com.google.guava:guava:31.1-android'
api 'com.google.protobuf:protobuf-javalite:3.21.12'
implementation 'org.slf4j:slf4j-api:1.7.36'
implementation 'net.jcip:jcip-annotations:1.0'
2021-12-14 11:45:39 +01:00
testImplementation 'junit:junit:4.13.2'
2023-01-29 21:52:41 +01:00
testImplementation 'org.easymock:easymock:5.1.0'
2022-11-14 00:50:12 +01:00
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.14.0'
testImplementation 'org.slf4j:slf4j-jdk14:1.7.36'
testImplementation 'nl.jqno.equalsverifier:equalsverifier:3.11'
2021-12-14 15:57:01 +01:00
testImplementation 'org.hamcrest:hamcrest-library:2.2'
testImplementation 'pl.pragmatists:JUnitParams:1.1.1'
}
sourceCompatibility = 8
targetCompatibility = 8
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'
// Uncomment the following line to see all the JavaDoc warnings
//javadoc.options.addStringOption('Xmaxwarns', '10000')
compileJava {
options.compilerArgs.addAll(['--release', '8'])
options.compilerArgs << '-Xlint:deprecation'
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.21.12'
}
build.gradle: migrate from protobuf-java to protobuf-javalite This commit contains rather hard to review diffs to the protobuf test datasets in .txt format. To aid the review, this Python script can be used to convert the data from the old to the new format: ``` import sys file = open(sys.argv[1]) outfile = open(sys.argv[1] + ".lite", "w") line = file.readline() lines = [] def sortAndPrint(group, removeLastLB=False, removeFirstLB=False): group.sort() if removeFirstLB and group[0] == "\n": group.remove("\n") for i in range(len(group)): if i == len(group) - 1 and removeLastLB: group[i] = group[i].rstrip() print(group[i], end="", file=outfile) def sign32neg(value): if 0x80000000 <= value <= 0xFFFFFFFF: value &= 0x7FFFFFFF value = int(value) value = ~value value ^= 0x7FFFFFFF return value def processPath(path): parts = path.rstrip().split(":") number = int(parts[1].lstrip()) if number >= 0x80000000: number = sign32neg(number) return parts[0] + ": " + str(number) + "\n" groupcount = 0 while len(line) > 0: if line.startswith("type:"): if len(lines): sortAndPrint(lines, removeFirstLB=groupcount==0) groupcount += 1 lines.clear() lines.append(line) elif line.find("deterministic_key {") != -1: structure = line innerlines = [] line = file.readline() while not line.startswith('}'): if line.find("path") != -1: # preserve order of paths pathlines = processPath(line) line = file.readline() if line.startswith('}'): innerlines.append(pathlines) continue while line.find("path") != -1: pathlines += processPath(line) line = file.readline() innerlines.append(pathlines) if line.startswith('}'): continue if line.startswith(" sigsRequiredToSpend"): line = line.replace("sigsRequiredToSpend", "sigs_required_to_spend") innerlines.append(line) line = file.readline() innerlines.sort() for l in innerlines: structure += l structure += line.rstrip() + "\n" lines.append(structure) elif line.find("path") != -1: # preserve order of paths accountpathlines = processPath(line) line = file.readline() while line.find("path") != -1: accountpathlines += processPath(line) line = file.readline() lines.append(accountpathlines) lines.append(line) else: lines.append(line) line = file.readline() print(file=outfile) sortAndPrint(lines, removeLastLB=True) file.close() outfile.close() ```
2019-10-08 20:47:25 +02:00
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
}
}
generatedFilesBaseDir = new File(projectDir, '/src') // workaround for '$projectDir/src'
}
tasks.withType(Test) {
2019-03-15 12:09:05 +01:00
exclude 'org/bitcoinj/net/discovery/DnsDiscoveryTest*'
testLogging {
events "failed"
exceptionFormat "full"
}
}
// Test with default Java toolchain
test {
doFirst {
logger.lifecycle("Testing with default toolchain")
}
}
def gradleVersionToolchains = GradleVersion.version("6.7")
if (GradleVersion.current().compareTo(gradleVersionToolchains) > 0) {
// If the Gradle Java Toolchains feature is available, run tests on older JDKs
System.err.println "Adding 'testOnJdk8' task, because ${GradleVersion.current()}"
task('testOnJdk8', type: Test) {
doFirst {
logger.lifecycle("Testing with JDK ${javaLauncher.get().metadata.javaRuntimeVersion}")
}
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
}
}
// Activate if `testJdk8` is `true` in `gradle.properties` or `-PtestJdk8=true` is on command-line
if (Boolean.valueOf(findProperty('testJdk8'))) {
check.dependsOn testOnJdk8
}
}
ext.moduleName = 'org.bitcoinj.core'
jar {
inputs.property("moduleName", moduleName)
manifest {
attributes 'Automatic-Module-Name': moduleName
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
archives javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'bitcoinj-core'
from components.java
artifact sourcesJar
artifact javadocJar
pom {
description = 'A Java Bitcoin library'
}
}
}
}