stevedlawrence commented on a change in pull request #681:
URL: https://github.com/apache/daffodil/pull/681#discussion_r756345435
##########
File path: build.sbt
##########
@@ -343,14 +343,38 @@ lazy val unidocSettings = Seq(
lazy val genExamplesSettings = Seq(
Compile / genExamples := {
- val cp = (runtime2 / Runtime / dependencyClasspath).value
- val forkOpts = ForkOptions().withBootJars(cp.files.toVector)
- val mainClass = "org.apache.daffodil.runtime2.CodeGenerator"
- val args = Seq(mainClass)
- val ret = Fork.java(forkOpts, args)
- val stream = streams.value
- if (ret != 0) {
- stream.log.error(s"Failed to generate examples")
+ val cp = (runtime2 / Test / dependencyClasspath).value
+ val inSrc = (runtime2 / Compile / sources).value
+ val inRSrc = (runtime2 / Compile / resources).value
+ val inTSrc = (runtime2 / Test / resources).value
+ val stream = (runtime2 / streams).value
+ val filesToWatch = (inSrc ++ inRSrc ++ inTSrc).toSet
+ val cachedFun = FileFunction.cached(stream.cacheDirectory / "genExamples")
{ _ =>
+ val out = new java.io.ByteArrayOutputStream()
+ val forkOpts = ForkOptions()
+ .withOutputStrategy(Some(CustomOutput(out)))
+ .withBootJars(cp.files.toVector)
+ val mainClass = "org.apache.daffodil.runtime2.CodeGenerator"
+ val args = Seq(mainClass)
+ val ret = Fork.java(forkOpts, args)
+ if (ret != 0) {
+ stream.log.error(s"failed to generate example files")
+ }
+ val bis = new java.io.ByteArrayInputStream(out.toByteArray)
+ val isr = new java.io.InputStreamReader(bis)
+ val br = new java.io.BufferedReader(isr)
+ val iterator = Iterator.continually(br.readLine()).takeWhile(_ !=
null).filterNot(_.startsWith("WARN"))
+ val files = iterator.map { f =>
+ new File(f)
+ }.toSet
+ stream.log.info(s"generated ${files.size} runtime2 example files")
Review comment:
I think this should get you the right path:
```scala
val outDir = (runtime2 / Test / sourceDirectory).value / "c" / "examples"
```
That gets the value of the `sourceDirectory` setting in the `Test` config
(i.e. `src/test`) in the `runtime2` subproject, and then adds the "c" and
"examples" sub dirs to that.
If it causes problems with IDE's then it's not a big deal.
--
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]