provs/build.gradle
2023-06-13 18:49:48 +02:00

217 lines
7 KiB
Groovy

buildscript {
ext.kotlin_version = "1.7.0"
ext.CI_PROJECT_ID = System.env.CI_PROJECT_ID
repositories {
mavenCentral()
}
}
plugins {
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
id "java"
id "java-test-fixtures"
}
apply plugin: "maven-publish"
group = "org.domaindrivenarchitecture.provs"
version = "0.22.4-SNAPSHOT"
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
test {
// set properties for the tests
def propertiesForTests = ["testdockerwithoutsudo"]
for (def prop : propertiesForTests) {
def value = System.getProperty(prop)
if (value != null) {
systemProperty prop, value
}
}
useJUnitPlatform {
def excludedTags = System.getProperty("excludeTags")
if (System.getProperty("excludeTags") != null) {
excludeTags(excludedTags.split(","))
}
if (System.getenv("CI_JOB_TOKEN") != null) {
excludeTags("containernonci")
}
}
}
compileJava.options.debugOptions.debugLevel = "source,lines,vars"
compileTestFixturesJava.options.debugOptions.debugLevel = "source,lines,vars"
compileTestJava.options.debugOptions.debugLevel = "source,lines,vars"
// https://stackoverflow.com/questions/21904269/configure-gradle-to-publish-sources-and-javadoc
java {
withSourcesJar()
withJavadocJar()
}
dependencies {
api("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
api("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.2")
api("org.jetbrains.kotlinx:kotlinx-cli:0.3.4")
api('com.charleskorn.kaml:kaml:0.49.0')
api("org.slf4j:slf4j-api:1.7.36")
api('ch.qos.logback:logback-classic:1.2.11')
api('ch.qos.logback:logback-core:1.2.11')
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
implementation("com.hierynomus:sshj:0.32.0")
implementation("aws.sdk.kotlin:s3:0.17.1-beta")
testFixturesApi("org.junit.jupiter:junit-jupiter-api:5.8.2")
testFixturesApi('io.mockk:mockk:1.12.3')
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
}
task uberjarDesktop(type: Jar) {
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.findAll { it.name.endsWith("jar") }.collect { zipTree(it) }
} {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
}
manifest {
attributes "Implementation-Title": "Uberjar of provs",
"Implementation-Version": project.version,
"Main-Class": "org.domaindrivenarchitecture.provs.desktop.application.ApplicationKt"
}
archiveFileName = "provs-desktop.jar"
}
task uberjarServer(type: Jar) {
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.findAll { it.name.endsWith("jar") }.collect { zipTree(it) }
} {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
}
manifest {
attributes "Implementation-Title": "Uberjar of provs",
"Implementation-Version": project.version,
"Main-Class": "org.domaindrivenarchitecture.provs.server.application.ApplicationKt"
}
archiveFileName = "provs-server.jar"
}
task uberjarSyspec(type: Jar) {
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.findAll { it.name.endsWith("jar") }.collect { zipTree(it) }
} {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
}
manifest {
attributes "Implementation-Title": "Uberjar of provs",
"Implementation-Version": project.version,
"Main-Class": "org.domaindrivenarchitecture.provs.syspec.application.ApplicationKt"
}
archiveFileName = "provs-syspec.jar"
}
def projectRoot = rootProject.projectDir
// copy jar to /usr/local/bin and make it executable
// Remark: to be able to use it you must have jarwrapper installed (sudo apt install jarwrapper)
task installlocally {
dependsOn(uberjarServer, uberjarDesktop, uberjarSyspec)
doLast {
exec { commandLine("sh", "-c", "sudo apt-get update & sudo apt-get install jarwrapper") }
exec { commandLine("sh", "-c", "sudo cp $projectRoot/build/libs/provs-server.jar /usr/local/bin/") }
exec { commandLine("sh", "-c", "sudo cp $projectRoot/build/libs/provs-desktop.jar /usr/local/bin/") }
exec { commandLine("sh", "-c", "sudo cp $projectRoot/build/libs/provs-syspec.jar /usr/local/bin/") }
exec { commandLine("sh", "-c", "sudo chmod 755 /usr/local/bin/provs-server.jar") }
exec { commandLine("sh", "-c", "sudo chmod 755 /usr/local/bin/provs-desktop.jar") }
exec { commandLine("sh", "-c", "sudo chmod 755 /usr/local/bin/provs-syspec.jar") }
}
}
task sourceJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
archiveClassifier.set("sources")
}
// publish to repo.prod.meissa.de with task "publishLibraryPublicationToMeissaRepository" -- (using pattern "publishLibraryPublicationTo<MAVEN REPOSITORY NAME>Repository")
publishing {
publications {
library(MavenPublication) {
groupId 'org.domaindrivenarchitecture'
artifactId 'provs'
from components.java
}
}
repositories {
maven {
name = "meissa"
url = uri("https://repo.prod.meissa.de/api/packages/meissa/maven")
credentials(HttpHeaderCredentials) {
name = "Authorization"
if (System.getenv("CI_JOB_TOKEN") != null) {
value = "token " + System.getenv("meissa_repo_token")
} else {
// use project-property (define e.g. in "~/.gradle/gradle.properties") when not running in ci
// you can create a token in gitea "Profile and Settings ... > Settings > Applications", Token Name, Select scopes (write:package) > "Generate Token"
if (!project.hasProperty("meissa_repo_token")) {
// if meissa_repo_token is missing, provide a dummy in order to avoid error "Could not get unknown property 'meissa_repo_token' for Credentials [header: Authorization]" for other gradle tasks
ext.meissa_repo_token = "meissa_repo_token not provided in file \".gradle/gradle.properties\""
println "Error: meissa_repo_token not found"
}
value = "token $meissa_repo_token"
}
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}