Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VSS Processor Plugin #71

Merged
merged 32 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
aa3d2d2
feature: Add VSS Processor Plugin
Chrylo Dec 20, 2023
121a0e6
chore: Add publish of VSS Processor Plugin
Chrylo Jan 15, 2024
848f019
chore: Enable publish for VSS Processor Plugin
Chrylo Jan 31, 2024
aad0a0c
docs: Add VSS Processor Plugin docs
Chrylo Jan 31, 2024
09411de
chore: Update Checkout to v4
Chrylo Jan 31, 2024
e997a91
chore: Add automatic search to VSS files
Chrylo Feb 1, 2024
3227633
chore: Switch to gradle publish plugin
Chrylo Feb 2, 2024
c35e53e
chore: Update documentation
Chrylo Feb 6, 2024
ba976fe
Merge branch 'main' into feature-45
Chrylo Feb 6, 2024
bf74188
chore: Support incremental builds Vss Plugin tasks
Chrylo Feb 9, 2024
eef025c
chore: Enable Gradle configuration cache
Chrylo Feb 9, 2024
f08a5a9
chore: Add support for config caches
Chrylo Feb 13, 2024
f4b3882
chore: Change SemanticVersion handling
Chrylo Feb 13, 2024
25345ad
chore: Update dependencies
Chrylo Feb 13, 2024
4d56a1d
Merge branch 'main' into feature-45
Chrylo Feb 13, 2024
486b371
chore: Improve semantic version handling
Chrylo Feb 14, 2024
6b5c34a
chore: Fix clean builds for VSS Plugin
Chrylo Feb 14, 2024
49729c4
chore: Fix buildDir for javadocJar task
Chrylo Feb 15, 2024
ac9d61a
chore: Link composite plugin build only to vss-processor
Chrylo Feb 21, 2024
3a03c0f
test: Add VSS Processor Plugin tests
Chrylo Feb 21, 2024
1b2dfc0
test: Add tests for outdated cache
Chrylo Feb 22, 2024
33441b7
chore: Improve logging
Chrylo Feb 22, 2024
8f00509
chore: Link :clean task with VSS Processor Plugin
Chrylo Feb 22, 2024
e4d6734
chore: Correct composite task linking logging
Chrylo Feb 22, 2024
890393d
chore: Reverse logging order for linked composite tasks
Chrylo Feb 22, 2024
77efd21
chore: Remove FunctionTests run config
Chrylo Feb 22, 2024
889b329
chore: Fix missing oss/all folder during clean build
Chrylo Feb 22, 2024
fb3e8fd
chore: Add comment to be mindful of oss licenses
Chrylo Feb 23, 2024
9da0507
chore: Add known issue explanation for build warning
Chrylo Feb 23, 2024
6c3d7bc
chore: Disable config cache for maven task
Chrylo Feb 26, 2024
d4ebab1
chore: Remove clean from composite linking
Chrylo Feb 27, 2024
f591fb5
Merge branch 'main' into feature-45
Chrylo Feb 27, 2024
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
4 changes: 2 additions & 2 deletions .github/actions/setup-project/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ description: Setups the gradle and java environment
runs:
using: "composite"
steps:
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
2 changes: 1 addition & 1 deletion .github/workflows/build-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Project
uses: ./.github/actions/setup-project
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Run Docker Container of Databroker in detached mode"
run: docker run --pull=always --rm --publish 55556:55556/tcp --detach --name databroker ghcr.io/eclipse/kuksa.val/databroker:master --port 55556 --insecure
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# required to grab the history of the PR
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: wagoid/commitlint-github-action@v5
2 changes: 1 addition & 1 deletion .github/workflows/dash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Project
uses: ./.github/actions/setup-project
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Project
uses: ./.github/actions/setup-project
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Project
uses: ./.github/actions/setup-project
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ within an Android App. The main functionality consists of fetching, updating and

## Integration

*build.gradle*
Chrylo marked this conversation as resolved.
Show resolved Hide resolved
*app/build.gradle.kts*
```
implementation("org.eclipse.kuksa:kuksa-sdk:<VERSION>")
```
Expand Down
16 changes: 12 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.eclipse.kuksa.property.PropertiesLoader

/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
Expand All @@ -19,9 +17,16 @@ import org.eclipse.kuksa.property.PropertiesLoader
*
*/

@file:Suppress("UnstableApiUsage")

import org.eclipse.kuksa.property.PropertiesLoader
import org.eclipse.kuksa.version.SemanticVersion
import org.eclipse.kuksa.version.VERSION_FILE_DEFAULT_PATH_KEY

plugins {
id("com.android.application")
id("com.google.devtools.ksp")
id("org.eclipse.kuksa.vss-processor-plugin") // Always take the newest version since it's locally included
kotlin("plugin.serialization")
kotlin("android")
}
Expand Down Expand Up @@ -55,11 +60,14 @@ android {
applicationId = "org.eclipse.kuksa.testapp"
minSdk = 27
targetSdk = 34
versionCode = rootProject.extra["projectVersionCode"].toString().toInt()
versionName = rootProject.extra["projectVersion"].toString()
vectorDrawables {
useSupportLibrary = true
}

val versionPath = rootProject.ext[VERSION_FILE_DEFAULT_PATH_KEY] as String
val semanticVersion = SemanticVersion(versionPath)
versionCode = semanticVersion.versionCode
versionName = semanticVersion.versionName
}
signingConfigs {
create("release") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import org.eclipse.kuksa.testapp.ui.theme.KuksaAppAndroidTheme
import org.eclipse.kuksa.vsscore.annotation.VssDefinition
import org.eclipse.kuksa.vsscore.model.VssSpecification

@VssDefinition("vss_rel_4.0.yaml")
@VssDefinition
class KuksaDataBrokerActivity : ComponentActivity() {
private lateinit var connectionInfoRepository: ConnectionInfoRepository

Expand Down
49 changes: 34 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@
*
*/

import org.jetbrains.kotlin.incremental.createDirectory
import org.eclipse.kuksa.version.VERSION_FILE_DEFAULT_NAME
import org.eclipse.kuksa.version.VERSION_FILE_DEFAULT_PATH_KEY
import java.nio.file.FileVisitResult
import java.nio.file.Path
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.bufferedWriter
import kotlin.io.path.createDirectories
import kotlin.io.path.createFile
import kotlin.io.path.deleteIfExists
import kotlin.io.path.name
import kotlin.io.path.useLines
import kotlin.io.path.visitFileTree

val versionDefaultPath = "$rootDir/$VERSION_FILE_DEFAULT_NAME"
rootProject.ext[VERSION_FILE_DEFAULT_PATH_KEY] = versionDefaultPath

plugins {
base
Expand Down Expand Up @@ -47,6 +61,7 @@ subprojects {
}
}

@OptIn(ExperimentalPathApi::class)
tasks.register("mergeDashFiles") {
group = "oss"

Expand All @@ -56,26 +71,30 @@ tasks.register("mergeDashFiles") {
},
)

val buildDir = layout.buildDirectory.asFile.get()
val buildDirPath = Path.of(buildDir.path)

doLast {
val sortedLinesSet = sortedSetOf<String>()
files("build/oss").asFileTree.forEach { file ->
if (file.name != "dependencies.txt") return@forEach
val ossDir = buildDirPath.resolve("oss").createDirectories()
val ossAllDir = ossDir.resolve("all").createDirectories()
val ossDependenciesFile = ossAllDir.resolve("all-dependencies.txt")
ossDependenciesFile.deleteIfExists()
ossDependenciesFile.createFile()

file.useLines {
sortedLinesSet.addAll(it)
}
}
val sortedLinesSet = sortedSetOf<String>()
ossDir.visitFileTree {
onVisitFile { file, _ ->
if (file.name != "dependencies.txt") return@onVisitFile FileVisitResult.CONTINUE

val folder = File("$rootDir/build/oss/all")
folder.createDirectory()
file.useLines {
sortedLinesSet.addAll(it)
}

val file = File("$folder/all-dependencies.txt")
if (file.exists()) {
file.delete()
FileVisitResult.CONTINUE
}
}
file.createNewFile()

val bufferedWriter = file.bufferedWriter()
val bufferedWriter = ossDependenciesFile.bufferedWriter()
bufferedWriter.use { writer ->
sortedLinesSet.forEach { line ->
writer.write(line + System.lineSeparator())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@

package org.eclipse.kuksa.version

import java.io.File
import java.util.Locale

class SemanticVersion(semanticVersion: String) {
const val VERSION_FILE_DEFAULT_PATH_KEY = "versionFilePathKey"
const val VERSION_FILE_DEFAULT_NAME = "version.txt"

class SemanticVersion(versionFilePath: String) {
val major: Int
val minor: Int
val patch: Int
var suffix: String = ""

val versionString: String
val versionFile: File

val versionName: String
get() {
var version = "$major.$minor.$patch"
if (suffix.isNotEmpty()) {
Expand All @@ -47,6 +53,9 @@ class SemanticVersion(semanticVersion: String) {
}

init {
versionFile = File(versionFilePath)

val semanticVersion = versionFile.readText()
val versions = semanticVersion.trim()
.substringBefore("-") // Ignore suffixes like -SNAPSHOT
.split(".")
Expand All @@ -56,7 +65,5 @@ class SemanticVersion(semanticVersion: String) {
minor = versions[1].toInt()
patch = versions[2].toInt()
this.suffix = suffix

print("Current SemanticVersion($versionString)\n")
}
}
16 changes: 5 additions & 11 deletions buildSrc/src/main/kotlin/publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,12 @@ afterEvaluate {
)

sign(publishing.publications)
}
}

gradle.taskGraph.whenReady {
tasks.withType(Sign::class) {
val publishToMavenLocalTask = allTasks.find { it.name.contains("publishToMavenLocal") }
val isPublishingToMavenLocal = publishToMavenLocalTask != null

if (isPublishingToMavenLocal) {
println(":${project.name}:$name - Signing is disabled (publishToMavenLocal)")
}
setRequired({
val publishToMavenLocalTask = gradle.taskGraph.allTasks.find { it.name.contains("ToMavenLocal") }
val isPublishingToMavenLocal = publishToMavenLocalTask != null

onlyIf { !isPublishingToMavenLocal } // disable signing when publishing to MavenLocal
!isPublishingToMavenLocal // disable signing when publishing to MavenLocal
})
}
}
65 changes: 37 additions & 28 deletions buildSrc/src/main/kotlin/version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,51 +18,60 @@
*/

import org.eclipse.kuksa.version.SemanticVersion
import org.eclipse.kuksa.version.VERSION_FILE_DEFAULT_NAME

val file = File("$rootDir/version.txt")
val fileContent = file.readText()
val semanticVersion = SemanticVersion(fileContent)
private val versionPath = "$rootDir/$VERSION_FILE_DEFAULT_NAME"
private val semanticVersion = SemanticVersion(versionPath)

updateExtras()
/**
* Writes the given [suffix] into the given [inputFileProperty] while keeping the semantic version intact.
* E.g. 1.2.3 -> 1.2.3-SNAPSHOT (suffix = SNAPSHOT). Leave the suffix empty to restore the initial version.
*/
abstract class SetVersionSuffixTask : DefaultTask() {
@get:Input
abstract val suffix: Property<String>

@get:Incremental
@get:InputFile
abstract val inputFileProperty: RegularFileProperty

@TaskAction
fun addVersionSuffix() {
val inputFile = inputFileProperty.asFile.get()

val newSemanticVersion = SemanticVersion(inputFile.path)
newSemanticVersion.suffix = suffix.get()

println("Applying version suffix: ${suffix.get()}")

inputFile.writeText(newSemanticVersion.versionName)
}
}

// Do not chain this command because it writes into a file which needs to be re-read inside the next gradle command
tasks.register("setReleaseVersion") {
tasks.register<SetVersionSuffixTask>("setSnapshotVersion") {
group = "version"
doLast {
semanticVersion.suffix = ""

updateVersion()
}
inputFileProperty = semanticVersion.versionFile
suffix = "SNAPSHOT"
}

// Do not chain this command because it writes into a file which needs to be re-read inside the next gradle command
tasks.register("setSnapshotVersion") {
tasks.register<SetVersionSuffixTask>("setReleaseVersion") {
group = "version"
doLast {
semanticVersion.suffix = "SNAPSHOT"

updateVersion()
}
inputFileProperty = semanticVersion.versionFile
suffix = ""
}

tasks.register("printVersion") {
group = "version"
doLast {
val version = semanticVersion.versionString

println("VERSION=$version")
val versionFilePath = versionPath
doLast { // Prints the correct version if chained with SetVersionSuffix tasks
val currentSemanticVersion = SemanticVersion(versionFilePath)
println("Current version: ${currentSemanticVersion.versionName}")
}

mustRunAfter("setReleaseVersion", "setSnapshotVersion")
}

fun updateExtras() {
rootProject.extra["projectVersion"] = semanticVersion.versionString
rootProject.extra["projectVersionCode"] = semanticVersion.versionCode
}

fun updateVersion() {
updateExtras()

file.writeText(semanticVersion.versionString)
}
Loading
Loading