You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
provs/build.gradle

264 lines
10 KiB
Groovy

3 years ago
buildscript {
6 months ago
ext.kotlin_version_no = "1.7.20"
ext.CI_PROJECT_ID = System.env.CI_PROJECT_ID
repositories {
mavenCentral()
3 years ago
}
}
plugins {
6 months ago
id "org.jetbrains.kotlin.jvm" version "$kotlin_version_no"
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version_no"
id "java"
id "java-test-fixtures"
}
2 years ago
apply plugin: "maven-publish"
3 years ago
version = "0.29.4-SNAPSHOT"
2 years ago
group = "org.domaindrivenarchitecture.provs"
11 months ago
3 years ago
repositories {
mavenCentral()
}
java {
12 months ago
// https://stackoverflow.com/questions/21904269/configure-gradle-to-publish-sources-and-javadoc
withSourcesJar()
withJavadocJar()
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
3 years ago
test {
// set properties for the tests
def propertiesForTests = ["testdockerwithoutsudo"]
for (def prop : propertiesForTests) {
def value = System.getProperty(prop)
if (value != null) {
systemProperty prop, value
}
}
3 years ago
useJUnitPlatform {
def excludedTags = System.getProperty("excludeTags")
if (System.getProperty("excludeTags") != null) {
excludeTags(excludedTags.split(","))
}
if (System.getenv("CI_JOB_TOKEN") != null) {
2 years ago
excludeTags("containernonci")
}
3 years ago
}
}
compileJava.options.debugOptions.debugLevel = "source,lines,vars"
compileTestFixturesJava.options.debugOptions.debugLevel = "source,lines,vars"
3 years ago
compileTestJava.options.debugOptions.debugLevel = "source,lines,vars"
3 years ago
dependencies {
6 months ago
api("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version_no")
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")
12 months ago
api('com.charleskorn.kaml:kaml:0.54.0')
3 years ago
2 years ago
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')
3 years ago
6 months ago
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version_no")
2 years ago
implementation("com.hierynomus:sshj:0.32.0")
implementation("aws.sdk.kotlin:s3:0.17.1-beta")
2 years ago
testFixturesApi("org.junit.jupiter:junit-jupiter-api:5.8.2")
testFixturesApi('io.mockk:mockk:1.12.3')
2 years ago
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.2")
3 years ago
}
12 months ago
tasks.register('uberjarDesktop', Jar) {
3 years ago
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
from {
2 years ago
configurations.runtimeClasspath.findAll { it.name.endsWith("jar") }.collect { zipTree(it) }
3 years ago
} {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
2 years ago
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
3 years ago
}
manifest {
2 years ago
attributes "Implementation-Title": "Uberjar of provs",
"Implementation-Version": project.version,
"Main-Class": "org.domaindrivenarchitecture.provs.desktop.application.ApplicationKt"
3 years ago
}
2 years ago
archiveFileName = "provs-desktop.jar"
}
12 months ago
tasks.register('uberjarServer', Jar) {
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
from {
2 years ago
configurations.runtimeClasspath.findAll { it.name.endsWith("jar") }.collect { zipTree(it) }
} {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
2 years ago
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
}
manifest {
2 years ago
attributes "Implementation-Title": "Uberjar of provs",
"Implementation-Version": project.version,
"Main-Class": "org.domaindrivenarchitecture.provs.server.application.ApplicationKt"
}
2 years ago
archiveFileName = "provs-server.jar"
}
12 months ago
tasks.register('uberjarSyspec', Jar) {
2 years ago
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"
3 years ago
}
def projectRoot = rootProject.projectDir
3 years ago
// 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)
12 months ago
tasks.register('installlocally') {
2 years ago
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/") }
2 years ago
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") }
}
}
3 years ago
// publish to repo.prod.meissa.de with task "publishLibraryPublicationToMeissaRepository" -- (using pattern "publishLibraryPublicationTo<MAVEN REPOSITORY NAME>Repository")
3 years ago
publishing {
publications {
library(MavenPublication) {
groupId 'org.domaindrivenarchitecture'
artifactId 'provs'
3 years ago
from components.java
}
}
3 years ago
repositories {
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)
}
}
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) {
def tokenFromEnv = System.getenv("RELEASE_TOKEN")
if (tokenFromEnv == null) {
println "Error: RELEASE_TOKEN not found"
} else {
value = "token " + tokenFromEnv
println "RELEASE_TOKEN found - "
}
} 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"
12 months ago
if (!project.hasProperty("RELEASE_TOKEN")) {
// if RELEASE_TOKEN is missing, provide a dummy in order to avoid error "Could not get unknown property 'RELEASE_TOKEN' for Credentials [header: Authorization]" for other gradle tasks
ext.RELEASE_TOKEN = "RELEASE_TOKEN not provided in file \".gradle/gradle.properties\""
println "Error: RELEASE_TOKEN not found"
}
12 months ago
value = "token $RELEASE_TOKEN"
3 years ago
}
}
authentication {
header(HttpHeaderAuthentication)
}
3 years ago
}
}
}
tasks.register('createReleaseAndUploadAssets') {
dependsOn(uberjarServer, uberjarDesktop, uberjarSyspec)
doLast {
def token = project.properties.get("RELEASE_TOKEN") ?: System.getenv("RELEASE_TOKEN")
if (token == null) {
throw new GradleException('No token found.')
}
def output1 = new ByteArrayOutputStream()
exec {
standardOutput = output1
def TAG = project.version
commandLine("sh", "-c", "curl -X 'POST' 'https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{ \"body\": \"Provides jar-files for release $TAG\\nAttention: The \\\"Source Code\\\"-files below are not up-to-date!\", \"tag_name\": \"$TAG\" }' -H \"Authorization: token $token\"")
}
def matches = output1 =~ /\{"id":(\d+?),/
if (!matches) {
throw new GradleException('id of release could not be parsed in: ' + output1)
}
def releaseId = matches.group(1)
println "Release=$releaseId"
def releaseApiUrl = "https://repo.prod.meissa.de/api/v1/repos/meissa/provs/releases"
exec { commandLine("sh", "-c", "find build/libs/ -type f -exec sha256sum {} \\; | sort > build/libs/sha256sum.lst") }
exec { commandLine("sh", "-c", "find build/libs/ -type f -exec sha512sum {} \\; | sort > build/libs/sha512sum.lst") }
12 months ago
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@build/libs/provs-desktop.jar;type=application/x-java-archive'") }
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@build/libs/provs-server.jar;type=application/x-java-archive'") }
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@build/libs/provs-syspec.jar;type=application/x-java-archive'") }
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@build/libs/sha256sum.lst;type=text/plain'") }
exec { commandLine("sh", "-c", "curl -X 'POST' '$releaseApiUrl/$releaseId/assets' -H 'accept: application/json' -H \"Authorization: token $token\" -H 'Content-Type: multipart/form-data' -F 'attachment=@build/libs/sha512sum.lst;type=text/plain'") }
}
}