Skip to content

Commit

Permalink
Merge pull request #36 from kleis-technology/feature/lcaac-version
Browse files Browse the repository at this point in the history
feature/lcaac version
  • Loading branch information
pevab authored Oct 11, 2024
2 parents 64e1c18 + f023fde commit dcf7172
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
14 changes: 14 additions & 0 deletions cli/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.util.*

fun properties(key: String) = project.findProperty(key).toString()

plugins {
Expand Down Expand Up @@ -51,6 +53,18 @@ tasks.test {
useJUnitPlatform()
}

tasks.build {
val props = Properties()
val propsFile = File("${project.projectDir}/src/main/resources/META-INF/lcaac.properties")
propsFile.inputStream().use { props.load(it) }
props.setProperty("author", "Kleis Technology")
props.setProperty("description", "LCA as Code CLI")
props.setProperty("version", artifactVersion)
propsFile.outputStream().use {
props.store(it, null)
}
}

publishing {
repositories {
maven {
Expand Down
6 changes: 2 additions & 4 deletions cli/src/main/kotlin/ch/kleis/lcaac/cli/Main.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package ch.kleis.lcaac.cli

import ch.kleis.lcaac.cli.cmd.AssessCommand
import ch.kleis.lcaac.cli.cmd.LcaacCommand
import ch.kleis.lcaac.cli.cmd.TestCommand
import ch.kleis.lcaac.cli.cmd.TraceCommand
import ch.kleis.lcaac.cli.cmd.*
import com.github.ajalt.clikt.core.subcommands

fun main(args: Array<String>) = LcaacCommand()
.subcommands(
AssessCommand(),
TestCommand(),
TraceCommand(),
VersionCommand(),
)
.main(args)
19 changes: 19 additions & 0 deletions cli/src/main/kotlin/ch/kleis/lcaac/cli/cmd/VersionCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ch.kleis.lcaac.cli.cmd

import com.github.ajalt.clikt.core.CliktCommand
import java.util.Properties

class VersionCommand : CliktCommand(name = "version", help = "Get version") {
override fun run() {
val propsFile = {}.javaClass.classLoader.getResourceAsStream("META-INF/lcaac.properties")
val props = propsFile.use {
Properties().apply { load(it) }
}
val author = props.getProperty("author")
val description = props.getProperty("description")
val version = props.getProperty("version")
echo(description)
echo("v${version}")
echo(author)
}
}
3 changes: 3 additions & 0 deletions cli/src/main/resources/META-INF/lcaac.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
author=Kleis Technology
description=LCA as Code CLI
version=1.7.6
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ javaVersion=17
gradleVersion=7.6
org.gradle.jvmargs=-Xmx4096m
lcaacGroup=ch.kleis.lcaac
lcaacVersion=1.7.6
lcaacVersion=1.7.7

0 comments on commit dcf7172

Please sign in to comment.