Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ANCHOR-867] Create Uber JAR #157

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ subprojects {
spotless {
val javaVersion = JavaVersion.current()

if (javaVersion >= JavaVersion.VERSION_17) {
logger.warn("!!! WARNING !!!")
logger.warn("=================")
logger.warn(
" You are running Java version:[{}]. Spotless may not work well with JDK 17.",
javaVersion
)
logger.warn(
" In IntelliJ, go to [File -> Build -> Execution, Build, Deployment -> Gradle] and check Gradle JVM"
)
}

if (javaVersion < JavaVersion.VERSION_11) {
throw GradleException("Java 11 or greater is required for spotless Gradle plugin.")
}
Expand Down
61 changes: 45 additions & 16 deletions wallet-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

// The alias call in plugins scope produces IntelliJ false error which is suppressed here.
Expand All @@ -8,10 +9,11 @@ plugins {
signing
alias(libs.plugins.kotlin.serialization)
idea
id("com.github.johnrengelman.shadow") version "7.1.2"
}

fun DependencyHandler.testIntegrationImplementation(dependencyNotation: Any): Dependency? =
add("testIntegrationImplementation", dependencyNotation)
add("testIntegrationImplementation", dependencyNotation)

sourceSets {
val testIntegration by creating {
Expand Down Expand Up @@ -59,14 +61,14 @@ idea.module {
}

val testIntegration by
tasks.register<Test>("integrationTest") {
useJUnitPlatform()
tasks.register<Test>("integrationTest") {
useJUnitPlatform()

testClassesDirs = sourceSets.getByName("testIntegration").output.classesDirs
classpath = sourceSets.getByName("testIntegration").runtimeClasspath
testClassesDirs = sourceSets.getByName("testIntegration").output.classesDirs
classpath = sourceSets.getByName("testIntegration").runtimeClasspath

mustRunAfter(tasks.test)
}
mustRunAfter(tasks.test)
}

tasks.getByName("compileTestIntegrationKotlin") {
(this as KotlinCompile).kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
Expand All @@ -79,20 +81,47 @@ val dokkaOutputDir = buildDir.resolve("dokka")
tasks.dokkaHtml { outputDirectory.set(dokkaOutputDir) }

val deleteDokkaOutputDir by
tasks.register<Delete>("deleteDokkaOutputDirectory") { delete(dokkaOutputDir) }
tasks.register<Delete>("deleteDokkaOutputDirectory") { delete(dokkaOutputDir) }

val javadocJar =
tasks.register<Jar>("javadocJar") {
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}
tasks.register<Jar>("javadocJar") {
dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}

val sourcesJar by
tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(kotlin.sourceSets.main.get().kotlin)
tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(kotlin.sourceSets.main.get().kotlin)
}

val uberJar =
tasks.register<ShadowJar>("uberJar") {
archiveBaseName.set("kotlin-wallet-sdk-uber")
archiveClassifier.set("") // No classifier

// Include all runtime dependencies
from(sourceSets.main.get().output)
configurations = listOf(project.configurations.runtimeClasspath.get())

// Relocations
relocate("com", "shadow.wallet-sdk.com")
relocate("io", "shadow.wallet-sdk.io")
relocate("mu", "shadow.wallet-sdk.mu")
relocate("net", "shadow.wallet-sdk.net")
relocate("okhttp3", "shadow.wallet-sdk.okhttp3")
relocate("okio", "shadow.wallet-sdk.okio")
relocate("org", "shadow.wallet-sdk.org") { exclude("org.stellar.walletsdk") }
}

tasks {
build {
dependsOn(javadocJar)
dependsOn(sourcesJar)
dependsOn(uberJar)
}
}

publishing {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SponsorTest {
private val stellar = wallet.stellar()
private val account = wallet.stellar().account()
private val sponsoringKey =
SigningKeyPair.fromSecret("SAHXRL7XY2RMUETMIRORXSQ7JJ73FOOF4OMLDSCJW22HRPMULKY4M7KP")
SigningKeyPair.fromSecret("SBHTWEF5U7FK53FLGDMBQYGXRUJ24VBM3M6VDXCHRIGCRG3Z64PH45LW")

@Test @Order(0) fun testSponsorNewAccount(): Unit = runBlocking { createAccount() }

Expand Down
Loading