From c7370a3f5f8b6143e9ca9e99af2b26c5747eb519 Mon Sep 17 00:00:00 2001 From: Ostrzyciel Date: Tue, 26 Aug 2025 21:04:02 +0200 Subject: [PATCH] --version: add copyright information Add info about creator, license, and add a link to the repo. --- build.sbt | 3 +++ .../eu/neverblink/jelly/cli/command/Version.scala | 13 +++++++++++++ .../neverblink/jelly/cli/command/VersionSpec.scala | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/build.sbt b/build.sbt index 303c9f0..20584a8 100644 --- a/build.sbt +++ b/build.sbt @@ -72,6 +72,9 @@ lazy val root = (project in file(".")) version, scalaVersion, libraryDependencies, + BuildInfoKey.action("buildTime") { + System.currentTimeMillis + }, ), buildInfoPackage := "eu.neverblink.jelly.cli", assembly / assemblyMergeStrategy := { diff --git a/src/main/scala/eu/neverblink/jelly/cli/command/Version.scala b/src/main/scala/eu/neverblink/jelly/cli/command/Version.scala index 0ba3549..4c4f5d4 100644 --- a/src/main/scala/eu/neverblink/jelly/cli/command/Version.scala +++ b/src/main/scala/eu/neverblink/jelly/cli/command/Version.scala @@ -4,6 +4,8 @@ import caseapp.* import eu.neverblink.jelly.cli.* import eu.neverblink.jelly.cli.util.jena.JenaSystemOptions +import java.text.SimpleDateFormat +import java.util.Date import scala.util.{Failure, Success} @HelpMessage( @@ -22,6 +24,7 @@ object Version extends JellyCommand[VersionOptions]: ) override def doRun(options: VersionOptions, remainingArgs: RemainingArgs): Unit = + // Print version info val jenaV = BuildInfo.libraryDependencies .find(_.startsWith("org.apache.jena:jena-core:")).get.split(":")(2) val jellyV = BuildInfo.libraryDependencies @@ -35,6 +38,7 @@ object Version extends JellyCommand[VersionOptions]: |JVM ${System.getProperty("java.vm.name")} ${System.getProperty("java.vm.version")} |---------------------------------------------- |""".stripMargin.trim) + // Print feature support info reflectionSupported match { case Failure(ex) => printLine("[ ] JVM reflection: not supported. Parsing will be slower.") @@ -44,3 +48,12 @@ object Version extends JellyCommand[VersionOptions]: else printLine(" Run with --debug for details.") case Success(_) => printLine("[X] JVM reflection: supported. Parsing optimizations enabled.") } + // Print copyright info + val buildYear = new SimpleDateFormat("yyyy").format(Date(BuildInfo.buildTime)) + printLine(f""" + |Copyright (C) $buildYear NeverBlink and contributors. + |Licensed under the Apache License, Version 2.0. + |For details, see https://www.apache.org/licenses/LICENSE-2.0 + |This software comes with no warranties and is provided 'as-is'. + |Documentation and author list: https://github.com/Jelly-RDF/cli + """.stripMargin) diff --git a/src/test/scala/eu/neverblink/jelly/cli/command/VersionSpec.scala b/src/test/scala/eu/neverblink/jelly/cli/command/VersionSpec.scala index 584f2da..7446fc2 100644 --- a/src/test/scala/eu/neverblink/jelly/cli/command/VersionSpec.scala +++ b/src/test/scala/eu/neverblink/jelly/cli/command/VersionSpec.scala @@ -17,4 +17,15 @@ class VersionSpec extends AnyWordSpec, Matchers: val (out, err) = Version.runTestCommand(List(alias)) out should include("[X] JVM reflection: supported.") } + + "include the copyright year" in { + val (out, err) = Version.runTestCommand(List(alias)) + val currentYear = java.time.Year.now.getValue.toString + out should include(s"Copyright (C) $currentYear NeverBlink and contributors") + } + + "include a link to the license" in { + val (out, err) = Version.runTestCommand(List(alias)) + out should include("https://www.apache.org/licenses/LICENSE-2.0") + } }