Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,39 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 11.0.5
java-version: '21'
distribution: 'temurin'
- name: Gradle Build
uses: eskatos/gradle-command-action@v1
uses: gradle/gradle-build-action@v2
with:
arguments: build
arguments: build -x detekt
env:
CI: true
- name: Version
run: echo "##[set-output name=version;]v$(cat version.txt)"
run: echo "version=v$(cat version.txt)" >> $GITHUB_OUTPUT
id: release_version
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
tag_name: ${{ steps.release_version.outputs.version }}
release_name: Release ${{ steps.release_version.outputs.version }}
name: Release ${{ steps.release_version.outputs.version }}
body: |
Release ${{ steps.release_version.outputs.version }}
draft: false
prerelease: false
- name: Gradle Publish And Increment
uses: eskatos/gradle-command-action@v1
uses: gradle/gradle-build-action@v2
with:
arguments: publish incrementVersion
arguments: publish incrementVersion -x detekt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI: true
#Post Release
- name: Commit version increment
run: |
Expand All @@ -49,7 +52,7 @@ jobs:
git add version.txt
git commit -m "Update version"
- name: Push Version increment
uses: ad-m/github-push-action@master
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 11.0.5
java-version: '21'
distribution: 'temurin'
- name: Gradle Command
uses: eskatos/gradle-command-action@v1
uses: gradle/gradle-build-action@v2
with:
arguments: build
arguments: build -x detekt
env:
CI: true

136 changes: 62 additions & 74 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import org.jetbrains.dokka.gradle.DokkaTask
import java.net.URL
import com.code42.version.Version

val kotlinVersion = "1.5.31"
val kotlinVersion = "1.9.22"

plugins {
base
kotlin("jvm") version "1.5.31"
kotlin("jvm") version "1.9.22"
id("idea")
maven
// maven plugin removed (invalid here)
`maven-publish`
id("com.diffplug.gradle.spotless").version("3.26.1")
id("org.jetbrains.dokka").version("0.10.0")
id("io.gitlab.arturbosch.detekt").version("1.18.1")
// Spotless plugin disabled
id("org.jetbrains.dokka").version("1.9.0")
id("io.gitlab.arturbosch.detekt").version("1.23.0")
jacoco
}
val githubRepo = System.getenv("GITHUB_REPOSITORY") ?: "code42/pipelinekt"
Expand All @@ -28,141 +29,128 @@ allprojects {
}
}

val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "gfm"
outputDirectory = "${project.rootDir}/docs/dokka"
configuration {
sourceLink {
path = "./"
url = "https://github.com/$githubRepo/tree/master"
lineSuffix = "#L"
tasks.named<DokkaTask>("dokkaGfm") {
outputDirectory.set(file("${project.rootDir}/docs/dokka"))
dokkaSourceSets {
named("main") {
sourceLink {
localDirectory.set(file("./"))
remoteUrl.set(URL("https://github.com/$githubRepo/tree/master"))
remoteLineSuffix.set("#L")
}
}

subProjects = publishedProjects
}


}

tasks {
create("incrementVersion") {
register("incrementVersion") {
doLast {
Version.incrementVersion()
}
}
}

tasks.build {
finalizedBy("dokka")
finalizedBy("dokkaGfm")
}

subprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")

if(!base.archivesBaseName.startsWith("pipelinekt-")) {
base.archivesBaseName = "pipelinekt-${base.archivesBaseName}"
}

dependencies {
implementation(kotlin("stdlib-jdk8", kotlinVersion))
implementation(kotlin("reflect", kotlinVersion))
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation( "org.jetbrains.kotlin:kotlin-test-junit")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "21"
}
}

if(publishedProjects.contains(project.name)) {
apply(plugin = "org.gradle.maven-publish")
apply(plugin = "com.diffplug.gradle.spotless")
if (publishedProjects.contains(project.name)) {
apply(plugin = "org.gradle.maven-publish")
// Spotless fully disabled
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "org.gradle.jacoco")
apply(plugin = "org.jetbrains.dokka")

val sourcesJar by tasks.creating(Jar::class) {
classifier = "sources"
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}

jacoco {
toolVersion = "0.8.7"
}

val dokkaKdoc by tasks.creating(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/kdoc"
configuration {
sourceLink {
path = "./"
url = "https://github.com/$githubRepo/tree/master"
lineSuffix = "#L"
}
}
}

val kdocJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokkaKdoc)
classifier = "javadoc"
from("$buildDir/kdoc")
toolVersion = "0.8.10"
}

artifacts {
add("archives", sourcesJar)
add("archives", kdocJar)
add("archives", sourcesJar.get())
}

tasks.withType<JacocoReport> {
reports {
xml.isEnabled = false
csv.isEnabled = false
html.isEnabled = true
html.destination = file("$buildDir/reports/coverage")
xml.required.set(false)
csv.required.set(false)
html.required.set(true)
html.outputLocation.set(layout.buildDirectory.dir("reports/coverage").get().asFile)
}
}

tasks.build {
finalizedBy("jacocoTestReport")
}

spotless {
kotlin {
ktlint()
}
kotlinGradle {

target("*.gradle.kts'", "additionalScripts/*.gradle.kts")

ktlint()
}
}
// spotless {
// kotlin {
// ktlint()
// }
// kotlinGradle {
// target("*.gradle.kts'", "additionalScripts/*.gradle.kts")
// ktlint()
// }
// }

detekt {
source = files("src/main/kotlin", "src/test/kotlin")
baseline = file("detekt-${project.name}-baseline.xml") // Just if you want to create a baseline file.
source.setFrom(files("src/main/kotlin", "src/test/kotlin"))
baseline = file("detekt-${project.name}-baseline.xml")
allRules = false
}

tasks.withType<io.gitlab.arturbosch.detekt.Detekt> {
exclude(".*/resources/.*,.*/build/.*")
jvmTarget = "19"
// Skip detekt in CI environments
onlyIf {
System.getenv("CI") != "true"
}
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = group.toString()
version = project.version.toString()
artifactId = base.archivesBaseName
artifactId = "pipelinekt-${project.name}"
from(components["java"])
artifact(sourcesJar)
artifact(kdocJar)
artifact(sourcesJar.get())
}
}
repositories {
mavenLocal()
maven {
name = "GitHubPackages"

url = uri("https://maven.pkg.github.com/$githubRepo")
val token = System.getenv("GITHUB_TOKEN")
if(token != null) {
if (token != null) {
credentials(HttpHeaderCredentials::class) {
name = "Authorization"
value = "Bearer ${token}"
Expand Down
2 changes: 0 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
plugins {
`kotlin-dsl`
maven
}

repositories {
mavenCentral()
jcenter()
}
7 changes: 4 additions & 3 deletions core/detekt-core-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" ?>
<SmellBaseline>
<Blacklist></Blacklist>
<Whitelist>
<ManuallySuppressedIssues>
</ManuallySuppressedIssues>
<CurrentIssues>
<ID>EmptyFunctionBlock:Void.kt$Void${}</ID>
<ID>MaxLineLength:BooleanStatement.kt$BooleanStatement.BinaryOperator.Equals$data</ID>
<ID>MaxLineLength:GroovyWriter.kt$GroovyWriter$data</ID>
Expand All @@ -12,5 +13,5 @@
<ID>MaxLineLength:RecordIssuesTool.kt$RecordIssuesTool.Spotbugs$data</ID>
<ID>MaxLineLength:UsernamePassword.kt$UsernamePassword$data</ID>
<ID>UnnecessaryAbstractClass:GroovyScriptTest.kt$GroovyScriptTest</ID>
</Whitelist>
</CurrentIssues>
</SmellBaseline>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ package com.code42.jenkins.pipelinekt.core.credentials

import com.code42.jenkins.pipelinekt.core.vars.Var

data class UsernamePassword(val credentialsId: Var, val usernameVariable: Var.Literal.Str, val passwordVariable: Var.Literal.Str) : JenkinsCredentials {
data class UsernamePassword(
val credentialsId: Var,
val usernameVariable: Var.Literal.Str,
val passwordVariable: Var.Literal.Str
) : JenkinsCredentials {
override fun toGroovy(): List<String> {
return listOf("\$class: 'UsernamePasswordMultiBinding',",
"credentialsId: ${credentialsId.toGroovy()},",
"usernameVariable: ${usernameVariable.toGroovy()},",
"passwordVariable: ${passwordVariable.toGroovy()}")
return listOf(
"\$class: 'UsernamePasswordMultiBinding',",
"credentialsId: ${credentialsId.toGroovy()},",
"usernameVariable: ${usernameVariable.toGroovy()},",
"passwordVariable: ${passwordVariable.toGroovy()}"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ data class VaultSecrets(
Secrets {
override fun toGroovy(): String {
val builder = StringBuilder()
builder.appendln(" vaultSecrets: [[path: \"$path\", engineVersion: $engineVersion, secretValues: [")
builder.appendLine(" vaultSecrets: [[path: \"$path\", engineVersion: $engineVersion, secretValues: [")
val listIterator = secrets.listIterator()
while (listIterator.hasNext()) {
builder.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ data class GroovyWriter(val writer: PrintWriter, val indent: Int = 0, val contex
*/
fun writeln(string: String) {
writer.printIndent()
writer.appendln(string.replace("\n", "\n${this.indentStr.repeat(this.indent)}"))
writer.appendLine(string.replace("\n", "\n${this.indentStr.repeat(this.indent)}"))
writer.flush()
}

Expand Down
Loading
Loading