2021-02-10 19:24:43 +00:00
buildscript {
2024-03-08 22:02:15 +00:00
ext . kotlin_version_no = "1.8.20"
2021-03-31 10:09:03 +00:00
ext . CI_PROJECT_ID = System . env . CI_PROJECT_ID
2023-06-13 16:49:48 +00:00
repositories {
mavenCentral ( )
2021-02-10 19:24:43 +00:00
}
}
2023-06-13 16:49:48 +00:00
plugins {
2023-11-24 22:10:02 +00:00
id "org.jetbrains.kotlin.jvm" version "$kotlin_version_no"
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version_no"
2023-06-13 16:49:48 +00:00
id "java"
id "java-test-fixtures"
}
2022-03-25 15:31:29 +00:00
apply plugin: "maven-publish"
2021-08-07 13:50:55 +00:00
2021-02-10 19:24:43 +00:00
2024-10-21 17:08:24 +00:00
version = "0.38.6-SNAPSHOT"
2022-03-25 15:31:29 +00:00
group = "org.domaindrivenarchitecture.provs"
2023-06-30 12:31:14 +00:00
2021-02-10 19:24:43 +00:00
repositories {
mavenCentral ( )
}
2021-12-27 21:18:55 +00:00
java {
2023-06-18 21:31:06 +00:00
// https://stackoverflow.com/questions/21904269/configure-gradle-to-publish-sources-and-javadoc
withSourcesJar ( )
withJavadocJar ( )
2021-12-27 21:18:55 +00:00
toolchain {
languageVersion = JavaLanguageVersion . of ( 11 )
2021-08-08 14:27:21 +00:00
}
}
2021-02-10 19:24:43 +00:00
test {
2021-02-25 18:57:06 +00:00
// set properties for the tests
def propertiesForTests = [ "testdockerwithoutsudo" ]
for ( def prop : propertiesForTests ) {
def value = System . getProperty ( prop )
if ( value ! = null ) {
systemProperty prop , value
}
}
2021-02-10 19:24:43 +00:00
useJUnitPlatform {
2021-12-06 14:04:41 +00:00
def excludedTags = System . getProperty ( "excludeTags" )
if ( System . getProperty ( "excludeTags" ) ! = null ) {
2022-04-08 15:14:58 +00:00
excludeTags ( excludedTags . split ( "," ) )
2021-12-06 14:04:41 +00:00
}
2021-02-25 18:57:06 +00:00
if ( System . getenv ( "CI_JOB_TOKEN" ) ! = null ) {
2022-03-25 15:31:29 +00:00
excludeTags ( "containernonci" )
2021-02-25 18:57:06 +00:00
}
2021-02-10 19:24:43 +00:00
}
}
compileJava . options . debugOptions . debugLevel = "source,lines,vars"
2021-05-15 17:33:56 +00:00
compileTestFixturesJava . options . debugOptions . debugLevel = "source,lines,vars"
2021-02-10 19:24:43 +00:00
compileTestJava . options . debugOptions . debugLevel = "source,lines,vars"
2021-04-19 19:02:21 +00:00
2021-02-10 19:24:43 +00:00
dependencies {
2021-08-07 13:50:55 +00:00
2023-11-24 22:10:02 +00:00
api ( "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version_no" )
2022-03-26 11:07:16 +00:00
api ( "org.jetbrains.kotlinx:kotlinx-cli:0.3.4" )
2021-09-07 15:59:03 +00:00
2023-06-18 21:31:06 +00:00
api ( 'com.charleskorn.kaml:kaml:0.54.0' )
2021-02-10 19:24:43 +00:00
2022-03-25 15:31:29 +00:00
api ( "org.slf4j:slf4j-api:1.7.36" )
2024-02-24 19:28:39 +00:00
api ( 'ch.qos.logback:logback-classic:1.4.14' )
api ( 'ch.qos.logback:logback-core:1.4.14' )
2021-02-10 19:24:43 +00:00
2024-09-30 20:06:46 +00:00
implementation ( "com.hierynomus:sshj:0.38.0" )
2022-03-26 17:10:03 +00:00
2022-03-26 11:07:16 +00:00
testFixturesApi ( 'io.mockk:mockk:1.12.3' )
2024-09-30 20:06:46 +00:00
testFixturesApi ( "org.junit.jupiter:junit-jupiter-api:5.8.2" )
2022-03-25 15:31:29 +00:00
testRuntimeOnly ( "org.junit.jupiter:junit-jupiter-engine:5.8.2" )
2021-02-10 19:24:43 +00:00
}
2021-12-01 20:19:08 +00:00
2023-06-18 21:31:06 +00:00
tasks . register ( 'uberjarDesktop' , Jar ) {
2021-02-10 19:24:43 +00:00
from sourceSets . main . output
dependsOn configurations . runtimeClasspath
from {
2022-03-25 15:31:29 +00:00
configurations . runtimeClasspath . findAll { it . name . endsWith ( "jar" ) } . collect { zipTree ( it ) }
2021-02-10 19:24:43 +00:00
} {
2021-07-28 14:31:41 +00:00
duplicatesStrategy ( DuplicatesStrategy . EXCLUDE )
2022-03-25 15:31:29 +00:00
exclude "META-INF/*.RSA" , "META-INF/*.SF" , "META-INF/*.DSA"
2021-02-10 19:24:43 +00:00
}
manifest {
2022-03-25 15:31:29 +00:00
attributes "Implementation-Title" : "Uberjar of provs" ,
"Implementation-Version" : project . version ,
"Main-Class" : "org.domaindrivenarchitecture.provs.desktop.application.ApplicationKt"
2021-02-10 19:24:43 +00:00
}
2022-03-25 15:31:29 +00:00
archiveFileName = "provs-desktop.jar"
2022-01-21 17:15:23 +00:00
}
2022-02-22 16:26:02 +00:00
2023-06-18 21:31:06 +00:00
tasks . register ( 'uberjarServer' , Jar ) {
2022-01-21 17:15:23 +00:00
from sourceSets . main . output
dependsOn configurations . runtimeClasspath
from {
2022-03-25 15:31:29 +00:00
configurations . runtimeClasspath . findAll { it . name . endsWith ( "jar" ) } . collect { zipTree ( it ) }
2022-01-21 17:15:23 +00:00
} {
duplicatesStrategy ( DuplicatesStrategy . EXCLUDE )
2022-03-25 15:31:29 +00:00
exclude "META-INF/*.RSA" , "META-INF/*.SF" , "META-INF/*.DSA"
2022-01-21 17:15:23 +00:00
}
manifest {
2022-03-25 15:31:29 +00:00
attributes "Implementation-Title" : "Uberjar of provs" ,
"Implementation-Version" : project . version ,
"Main-Class" : "org.domaindrivenarchitecture.provs.server.application.ApplicationKt"
2022-01-21 17:15:23 +00:00
}
2022-03-25 15:31:29 +00:00
archiveFileName = "provs-server.jar"
}
2023-06-18 21:31:06 +00:00
tasks . register ( 'uberjarSyspec' , Jar ) {
2022-03-25 15:31:29 +00:00
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"
2021-02-10 19:24:43 +00:00
}
2022-04-13 10:59:52 +00:00
def projectRoot = rootProject . projectDir
2021-02-10 19:24:43 +00:00
2022-03-04 14:53:42 +00:00
// 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)
2023-06-18 21:31:06 +00:00
tasks . register ( 'installlocally' ) {
2022-03-25 15:31:29 +00:00
dependsOn ( uberjarServer , uberjarDesktop , uberjarSyspec )
2022-03-04 14:53:42 +00:00
doLast {
2022-06-10 10:16:15 +00:00
exec { commandLine ( "sh" , "-c" , "sudo apt-get update & sudo apt-get install jarwrapper" ) }
2022-04-13 10:59:52 +00:00
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/" ) }
2022-03-25 15:31:29 +00:00
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" ) }
2022-03-04 14:53:42 +00:00
}
}
2021-02-10 19:24:43 +00:00
2024-10-04 13:04:13 +00:00
// create binaries and install into /usr/local/bin
// PREREQUISITE: graalvm / native-image must be installed - see https://www.graalvm.org/
2024-10-25 07:13:52 +00:00
tasks . register ( 'binariesInstall' ) {
2024-10-04 13:04:13 +00:00
dependsOn ( uberjarServer , uberjarDesktop , uberjarSyspec )
doLast {
println "Building binaries ..."
2024-10-09 20:02:23 +00:00
exec { commandLine ( "sh" , "-c" , "cd build/libs/ && native-image --no-fallback --initialize-at-build-time=kotlin.DeprecationLevel -H:+UnlockExperimentalVMOptions -H:IncludeResources=\".*org/domaindrivenarchitecture/provs/.*(conf|ssh_config|sshd_config|sh|vimrc|xml|yaml)\" -jar provs-desktop.jar" ) }
exec { commandLine ( "sh" , "-c" , "cd build/libs/ && native-image --no-fallback --initialize-at-build-time=kotlin.DeprecationLevel -H:+UnlockExperimentalVMOptions -H:IncludeResources=\".*org/domaindrivenarchitecture/provs/.*(conf|ssh_config|sshd_config|sh|vimrc|xml|yaml)\" -jar provs-server.jar" ) }
exec { commandLine ( "sh" , "-c" , "cd build/libs/ && native-image --no-fallback --initialize-at-build-time=kotlin.DeprecationLevel -H:+UnlockExperimentalVMOptions -H:IncludeResources=\".*org/domaindrivenarchitecture/provs/.*(conf|ssh_config|sshd_config|sh|vimrc|xml|yaml)\" -jar provs-syspec.jar" ) }
2024-10-09 16:31:06 +00:00
exec { commandLine ( "sh" , "-c" , "sudo cp build/libs/provs-desktop /usr/local/bin/" ) }
exec { commandLine ( "sh" , "-c" , "sudo cp build/libs/provs-server /usr/local/bin/" ) }
exec { commandLine ( "sh" , "-c" , "sudo cp build/libs/provs-syspec /usr/local/bin/" ) }
2024-10-04 13:04:13 +00:00
}
}
2023-06-13 16:49:48 +00:00
// publish to repo.prod.meissa.de with task "publishLibraryPublicationToMeissaRepository" -- (using pattern "publishLibraryPublicationTo<MAVEN REPOSITORY NAME>Repository")
2021-02-10 19:24:43 +00:00
publishing {
publications {
2021-02-11 18:24:16 +00:00
library ( MavenPublication ) {
2023-06-13 16:49:48 +00:00
groupId 'org.domaindrivenarchitecture'
artifactId 'provs'
2021-02-10 19:24:43 +00:00
from components . java
}
}
2023-06-13 16:49:48 +00:00
2021-02-10 19:24:43 +00:00
repositories {
2023-06-30 11:56:31 +00:00
maven {
name = "gitlab"
url = "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/maven"
credentials ( HttpHeaderCredentials ) {
name = "Job-Token"
value = System . getenv ( "CI_JOB_TOKEN" )
}
authentication {
header ( HttpHeaderAuthentication )
}
}
2023-06-13 16:49:48 +00:00
maven {
name = "meissa"
url = uri ( "https://repo.prod.meissa.de/api/packages/meissa/maven" )
credentials ( HttpHeaderCredentials ) {
name = "Authorization"
2023-11-25 17:39:27 +00:00
def publishPackageTokenName = "MEISSA_PUBLISH_PACKAGE_TOKEN"
2023-06-13 16:49:48 +00:00
if ( System . getenv ( "CI_JOB_TOKEN" ) ! = null ) {
2023-11-25 17:39:27 +00:00
def tokenFromEnv = System . getenv ( publishPackageTokenName )
2023-06-30 11:56:31 +00:00
if ( tokenFromEnv = = null ) {
2023-11-25 17:39:27 +00:00
println "Error: $publishPackageTokenName not found"
2023-06-30 10:44:56 +00:00
} else {
2023-06-30 11:56:31 +00:00
value = "token " + tokenFromEnv
2023-11-25 17:39:27 +00:00
println "$publishPackageTokenName found - "
2023-06-30 10:44:56 +00:00
}
2023-06-13 16:49:48 +00:00
} 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"
2023-11-25 17:39:27 +00:00
if ( ! project . hasProperty ( publishPackageTokenName ) ) {
// if token is missing, provide a dummy in order to avoid error "Could not get unknown property 'MEISSA_PUBLISH_PACKAGE_TOKEN' for Credentials [header: Authorization]" for other gradle tasks
ext . MEISSA_PUBLISH_PACKAGE_TOKEN = "Token $publishPackageTokenName not provided in file \".gradle/gradle.properties\""
println "Error: Token $publishPackageTokenName not found"
} else {
value = "token " + project . property ( publishPackageTokenName )
2023-06-13 16:49:48 +00:00
}
2021-02-10 19:24:43 +00:00
}
}
2023-06-13 16:49:48 +00:00
authentication {
header ( HttpHeaderAuthentication )
}
2021-02-10 19:24:43 +00:00
}
}
2021-09-07 15:59:03 +00:00
}