stevedlawrence commented on code in PR #1057:
URL: https://github.com/apache/daffodil/pull/1057#discussion_r1483348540
##########
project/plugins.sbt:
##########
@@ -26,3 +26,5 @@ addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
+
+addSbtPlugin("org.scalaxb" % "sbt-scalaxb" % "1.12.0")
Review Comment:
Does anyone know about licenses for generated code?
It looks like this plugin doesn't add any new dependencies (except for build
dependencies, which ASF requires be compatible but do not need to be mentioned
in any license/notice files).
But scalaxb does generate code in `daffodil-tdml-lib/src_managed/`. I can't
find anything that ASF says about generated code licenses, and scalaxb doesn't
mention the license of the code it generates that I can find.
I imagine scalaxb cannot make license claims about the code it generates,
since it relies on input which may be licensed differently, so it's probably
fine for us to can claim the generated code is ALv2? Maybe one edge case is
that the `src_managed/scalaxb.scala` file looks it is "generated" from this
file:
https://github.com/eed3si9n/scalaxb/blob/develop/cli/src/main/resources/scalaxb.scala.template
That file isn't really generated at all--it is pretty much a straight copy
out of the scalaxb jar, with one minor template variable. I'm not sure you
could make the same argument, and maybe this file has the same license as
scalaxb, which is MIT. Which is still ASF compatible, but would need a mention
in the daffodil-tdml-lib META-INF/LICENSE.
Or can we claim everything it outputs is generated code, regardless of how
much changes are made from the templates, and that we can assign whatever
license we want? Or should we get clarification from scalaxb about the license
of their generated code?
##########
daffodil-tdml-lib/src/test/scala/org/apache/daffodil/tdml/ScalaxbTests.scala:
##########
@@ -0,0 +1,23 @@
+package org.apache.daffodil.tdml
+
+import org.apache.daffodil.tdml.scalaxb.TestSuite
+
+import org.junit.Assert._
+import org.junit.Test
+
+class ScalaxbTests {
+
+ @Test def testReading(): Unit = {
+ val testSuite =
+ _root_.scalaxb.fromXML[TestSuite](
+ scala.xml.XML.load(
+ getClass
+ .getClassLoader()
+ .getResourceAsStream("test-suite/ibm-contributed/dpaext1-2.tdml"),
+ ),
+ )
+
+ assertNotNull(testSuite)
+ assertEquals(Some("dpaext"), testSuite.suiteName)
+ }
+}
Review Comment:
It might be useful to have some more extensive tests that show how to access
certain pieces of information (e.g test names, infosets, data, etc.). It would
confirm that they can be accessed in reasonable way, and also act as examples
on how to use the classes it generates. This would be especially useful to
confirm that it has the capabilities that the VSCode plugin will need, since I
think that is the use case for this?
For example, you said the `dfdlinfoset` is translated into this:
```scala
case class DfdlInfosetType(var mixed: Seq[scalaxb.DataRecord[Any]] = Nil,
var attributes: Map[String, scalaxb.DataRecord[Any]] = Map.empty) {
def typeValue = attributes("@type").as[Type]
def typeValue_=(_value: Type)(implicit evidence:
scalaxb.CanWriteXML[Type]) = attributes += "@type" -> scalaxb.DataRecord(_value)
}
```
That doesn't seem like it has a way to actually access the infoset. Maybe
the `Any` record needs to be type cast into something. Showing how that works
seems useful and makes sure if we ever change the tdml file in some way that
causes changes to the scalaxb code we'll know about it.
--
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]