provs/build.gradle
2022-02-01 18:54:33 +01:00

216 lines
6.3 KiB
Groovy

buildscript {
ext.kotlin_version = '1.6.10'
ext.CI_PROJECT_ID = System.env.CI_PROJECT_ID
repositories { mavenCentral() }
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'java-library'
apply plugin: 'java-test-fixtures'
apply plugin: 'maven-publish'
apply plugin: 'kotlinx-serialization'
group = 'org.domaindrivenarchitecture.provs'
version = '0.9.3'
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
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)
}
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 {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.1"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.1"
implementation "org.jetbrains.kotlinx:kotlinx-cli:0.3.4"
implementation 'com.charleskorn.kaml:kaml:0.38.0'
implementation group: 'com.hierynomus', name: 'sshj', version: '0.32.0'
api "org.slf4j:slf4j-api:1.7.32"
api "ch.qos.logback:logback-classic:1.2.9"
api "ch.qos.logback:logback-core:1.2.9"
testFixturesApi 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testImplementation("io.mockk:mockk:1.12.1")
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
//create a single Jar with all dependencies excl. Kotlin libs without version-number
task fatJarLatest(type: Jar) {
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
manifest {
attributes 'Implementation-Title': 'Fatjar of provs',
'Implementation-Version': project.version,
'Main-Class': 'org.domaindrivenarchitecture.provs.desktop.application.CliWorkplaceKt'
}
with jar
archiveFileName = 'provs-desktop.jar'
}
task fatJarK3s(type: Jar) {
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
manifest {
attributes 'Implementation-Title': 'Fatjar of provs k3s',
'Implementation-Version': project.version,
'Main-Class': 'org.domaindrivenarchitecture.provs.server.application.ApplicationKt'
}
with jar
archiveFileName = 'provs-server.jar'
}
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.CliKt'
}
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 uberjarEntry(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': 'Gradle Jar File Example',
'Implementation-Version': project.version,
'Main-Class': 'org.domaindrivenarchitecture.provs.core.entry.EntryKt'
}
archiveFileName = 'provs-entry.jar'
}
task sourceJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allSource
archiveClassifier.set("sources")
}
publishing {
publications {
library(MavenPublication) {
from components.java
}
}
repositories {
if (System.getenv("CI_JOB_TOKEN") != null) {
// see https://docs.gitlab.com/ee/user/packages/maven_repository/index.html
maven {
url "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/maven"
name "GitLab"
credentials(HttpHeaderCredentials) {
name = 'Job-Token'
value = System.getenv("CI_JOB_TOKEN")
}
authentication {
header(HttpHeaderAuthentication)
}
}
} else {
mavenLocal()
}
}
}