// Apply necessary plugins apply plugin: 'java' apply plugin: 'maven-publish' apply plugin: 'signing' // Define the version and group for the Maven package version = "1.1.5" group = "net.servicestack" if (project.hasProperty('versionSuffix')) { version = "${version}-${versionSuffix}" } // Specify dependencies dependencies { implementation 'com.google.code.gson:gson:2.11.0' testImplementation 'junit:junit:4.13.2' testImplementation 'pl.pragmatists:JUnitParams:1.1.1' } tasks.register('sourceJar', Jar) { archiveClassifier.set("sources") from sourceSets.main.allJava } tasks.register('javadocJar', Jar) { dependsOn javadoc archiveClassifier.set("javadoc") from javadoc.destinationDir } artifacts { archives jar archives sourceJar archives javadocJar } // Configure the publishing block for Maven Central deployment publishing { publications { mavenJava(MavenPublication) { from components.java // Attach source and javadoc JARs artifact(sourceJar) { classifier = 'sources' } artifact(javadocJar) { classifier = 'javadoc' } pom { name = 'ServiceStack.Client' description = 'A client library to call your ServiceStack webservices.' url = 'https://github.com/ServiceStack/ServiceStack.Java' version = version licenses { license { name = 'The BSD 3-Clause License' url = 'https://servicestack.net/bsd-license.txt' } } developers { developer { id = 'mythz' name = 'Demis Bellot' email = 'team@servicestack.net' } developer { id = 'layoric' name = 'Darren Reid' email = 'team@servicestack.net' } } scm { connection = 'https://github.com/ServiceStack/ServiceStack.Java.git' developerConnection = 'https://github.com/ServiceStack/ServiceStack.Java.git' url = 'https://github.com/ServiceStack/ServiceStack.Java' } } } } repositories { maven { name = 'OSSRH' url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") credentials { username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME") password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_TOKEN") } } maven { name = 'GitHubPackages' url = uri("https://maven.pkg.github.com/ServiceStack/ServiceStack.Java") credentials { username = project.findProperty("gpr.user") ?: System.getenv("USERNAME_GITHUB") password = project.findProperty("gpr.token") ?: System.getenv("TOKEN_GITHUB") } } } } // Check if the environment variables are set def signingKey = System.getenv('SIGNING_KEY') def signingPassword = System.getenv('SIGNING_PASSWORD') // Conditionally apply the signing plugin and configuration if (signingKey && signingPassword) { println "Signing enabled" signing { useInMemoryPgpKeys(signingKey, signingPassword) sign publishing.publications.mavenJava } } else { println "Signing disabled" } java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 }