plugins {
id 'java-library'
id 'c'
id 'maven-publish'
id 'signing'
id 'com.google.osdetector' version '1.7.1'
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.15'
}
repositories {
mavenCentral()
}
java {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
withJavadocJar()
withSourcesJar()
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
task buildRustRelease(type:Exec){
workingDir 'native'
if (!project.hasProperty('buildTarget')) {
commandLine 'cargo', 'build', '--release'
} else {
commandLine 'cargo', 'build', '--target=' + buildTarget, '--release'
}
}
archivesBaseName = 'iota-client'
jar {
dependsOn 'buildRustRelease'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
if (!project.hasProperty('buildTarget')) {
from('../../../../../../target/release') {
include '*.so', '*.dylib', '*.dll'
}
} else {
from('../../../../../../target/' + findProperty('buildTarget') + '/release') {
include '*.so', '*.dylib', '*.dll'
}
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
archiveClassifier = getJarClassifier()
}
task jarWithoutNativeLibs(type: Jar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
exclude '*.so', '*.dylib', '*.dll'
with jar
}
test {
doFirst {
classpath += jar.outputs.files
}
useJUnitPlatform()
}
version = project.getRootProject().properties.version
publishing {
publications {
allJars (MavenPublication) {
groupId = 'org.iota'
artifactId = 'iota-client'
artifact jarWithoutNativeLibs
from components.java
pom {
name = 'iota-client'
description = 'Java binding to the iota.rs library.'
url = 'https://github.com/iotaledger/iota.rs'
inceptionYear = '2022'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'samuel-rufi'
name = 'Samuel Rufinatscha'
email = 'samuel.rufinatscha@iota.org'
}
}
scm {
connection = 'scm:git:git:github.com/iotaledger/iota.rs.git'
developerConnection = 'scm:git:ssh://github.com/iotaledger/iota.rs.git'
url = 'https://github.com/iotaledger/iota.rs'
}
}
}
}
}
signing {
def signingKey = base64Decode(findProperty("base64EncodedAsciiArmoredSigningKey"))
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.allJars
}
def base64Decode(encodedString){
if(encodedString != null) {
byte[] decoded = encodedString.decodeBase64()
String decode = new String(decoded)
return decode
}
return null;
}
def getJarClassifier(){
def buildTarget = findProperty("buildTarget")
if(buildTarget != null)
return buildTarget
else
return osdetector.classifier
}