apache / daffodil-sbt

Apache Daffodil SBT Plugin
https://daffodil.apache.org/
Apache License 2.0
1 stars 3 forks source link

packageDaffodilBin needs warning if ignored because packageDaffodilBinInfos is not defined #56

Open mbeckerle opened 1 week ago

mbeckerle commented 1 week ago

My build.sbt:

name := "dfdl-mySchema"

organization := "com.owlcyberdefense"

version := "1.0.0-SNAPSHOT"

// for details about DaffodilPlugin settings, see https://github.com/apache/daffodil-sbt
enablePlugins(DaffodilPlugin)

daffodilFlatLayout := true

daffodilVersion := daffodilPackageBinVersions.value.head

daffodilPackageBinVersions := Seq("3.5.0", "3.8.0", "3.7.0")

When I issue sbt clean test packageDaffodilBin test runs, but nothing is created in target directory.

stevedlawrence commented 1 week ago

You need to tell the plugin what schema to compile using daffodilPackageBinInfos.

Also, if your tdml tests use the saved parser file you need to set daffodilTdmlUsesPackageBin := true.

Maybe we should output a warning if the packageDaffodilBin task is run but either daffodilPackageBinVersions or daffodilPackageBinInfos is empty? One or both of those being empty means packageDaffodilBin won't do anything.

mbeckerle commented 1 week ago

A warning that it is being ignored would be a good fix. I'll change title of this issue.

mbeckerle commented 1 week ago

Actually, I'm unable to get this to work, and at least one issue is not finding schemas in "src" for flattened schema style.

See this PR: https://github.com/DFDLSchemas/faketdl/pull/1

stevedlawrence commented 1 week ago

I think the schema path might require a leading / since it's a resource path. Maybe we should also warn if it's that's missing?

stevedlawrence commented 1 week ago

As part of this, we should improve our warnings/errors related to daffodilPackageBin. We should error if a resource path does not start with a /. We should also improve our error related to "duplicate classifiers" to make it more human friendly. It's not clear what "duplicate classifiers" even means. We should make change this error message so it's more obvious what the problem is and how to fix it.

mbeckerle commented 1 week ago

I would add that the DaffodilBinInfo object takes an arg named root and an arg named name, as if these concepts were orthogonal.

I don't think they should be orthogonal. Users don't need that much control.

Consider fakeTDL (on DFDLSchemas github)

Two bin files are created for each version of daffodil.

dfdl-fakeTDL-1.0.0-fakeTDL-daffodil350.bin

dfdl-fakeTDL-1.0.0-fakeTDLFile-daffodil350.bin

I don't see why the root element name isn't just always used as the classifier in the name.

I don't know why users need to be able to give alternate names like just "file" instead of putting the root element name into the file name always. But at least the default should use the root element name in the file name.

stevedlawrence commented 1 week ago

That's fair. I think we could make it so that if root is defined but name is None then we just default to using root as the name, maybe with QName prefixes stripped off or something. One downside is you couldn't specify a root without making the resulting name more verbose, but maybe that's not a big deal, since if you really wanted that you could just specify the root element first in the schema and you wouldn't have to provide a root parameter.