tuxji commented on code in PR #1022:
URL: https://github.com/apache/daffodil/pull/1022#discussion_r1214348628
##########
build.sbt:
##########
@@ -19,10 +19,11 @@ import scala.collection.immutable.ListSet
import sbtcc._
-lazy val genManaged = taskKey[Seq[File]]("Generate managed sources and
resources")
+lazy val genManaged = taskKey[Unit]("Generate managed sources and resources")
lazy val genProps = taskKey[Seq[File]]("Generate properties scala source")
lazy val genSchemas = taskKey[Seq[File]]("Generate DFDL schemas")
lazy val genCExamples = taskKey[Seq[File]]("Generate C example files")
+lazy val genVersion = taskKey[Seq[File]]("Generate a VERSION file")
Review Comment:
Picky, I know, but the sentence should not use an indefinite article ('a').
We use the indefinite article when not knowing which one of several VERSION
files we are referring to or showing that the file is one of a group of VERSION
files. There is only 'the' VERSION file, not 'a' VERSION file. However, none
of the other sentences use definite or indefinite articles, so let's drop the
'a'.
##########
daffodil-lib/src/main/scala/org/apache/daffodil/lib/util/Misc.scala:
##########
@@ -250,12 +251,9 @@ object Misc {
* Returns the primary version of daffodil from the jar
*/
def getDaffodilVersion: String = {
- val implVersion = this.getClass.getPackage.getImplementationVersion
- if (implVersion == null) {
- ""
- } else {
- implVersion
- }
+ val uri = getRequiredResource("org/apache/daffodil/lib/VERSION")
+ val version = Source.fromInputStream(uri.toURL.openStream,
"UTF-8").mkString
+ version
Review Comment:
In case it's not obvious to the next reviewer, the managed resource
`VERSION` is generated inside the `daffodil-lib/target/classes/org/apache/lib
directory` so it doesn't need to be put under source control or excluded from
source control.
##########
build.sbt:
##########
@@ -327,7 +328,8 @@ lazy val usesMacros = Seq(
lazy val libManagedSettings = Seq(
genManaged := {
- (Compile / genProps).value ++ (Compile / genSchemas).value
+ (Compile / managedSources).value
+ (Compile / managedResources).value
Review Comment:
I was confused by not seeing any definition of `managedSources
managedResources`, so I read the sbt documentation. I think here's what's
going on. Line 22 above declares `genManaged` is a sbt task which we can type
at the sbt prompt. I don't know the exact semantics of the `genManaged =` on
line 22 and `genManaged :=` on line 330, but line 330 tells sbt that in order
to evaluate `genManaged` (which has no value, but still needs to be evaluated),
sbt must also get (and subsequently discard) the values of `managedSources
managedResources` which are implicitly generated on the fly by calling the
`sourceGenerators resourceGenerators` which we do define on lines 388 and 391.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]