iota-sdk 0.3.0

The IOTA SDK provides developers with a seamless experience to develop on IOTA by providing account abstractions and clients to interact with node APIs.
Documentation
plugins {
    // Apply the java-library plugin for API and implementation separation.
    id 'java-library'
    id 'c'
    id 'maven-publish'
    id 'signing'
    id 'com.google.osdetector' version '1.7.1'
}

dependencies {
    // Use JUnit Jupiter for testing.
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
    // Dependencies that are used internally, and not exposed to consumers on their own compile classpath.
    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 {
    // The ASCII armored signing key contains important new line characters that are lost when loading the content for example like: `def signingKey = findProperty("signingKey"))`
    // To solve this, encode the ASCII armored signing key in base64 and store it in the `ORG_GRADLE_PROJECT_base64EncodedAsciiArmoredSigningKey` environment variable.
    // The following line will decode it correctly:
    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
}