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

feature/lcaac version #36

Merged
merged 3 commits into from
Oct 11, 2024
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
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
Loading