This is an automated email from the ASF dual-hosted git repository.

slawrence pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-sbt.git


The following commit(s) were added to refs/heads/main by this push:
     new 15e1f7a  Improve error/warning messages
15e1f7a is described below

commit 15e1f7a456982a2744494620e9a40c3f67757269
Author: Steve Lawrence <[email protected]>
AuthorDate: Mon Sep 30 11:44:56 2024 -0400

    Improve error/warning messages
    
    If either daffodilPackageBinInfos or daffodilPackageBinVersions are
    empty then the packageDaffodilBin task will silently not create any
    artifacts. This can be confusing for users if they forget to set one of
    the mentioned settings.
    
    This modifies the plugin so that if a user explicitly runs
    packageDaffodilBin and no saved parsers are created then we output a
    warning and mention the settings to check for correctness.
    
    Note that this moves the core logic of packageDaffodilBin into the
    "products" subtask which does not create a warning. All tasks that need
    the saved parsers (e.g. publishing artifacts, tests) now use this
    subtask and will not output a warning. Only the packageDaffodilBin task
    explicitly run by a user outputs a warning. This avoids potentially
    confusing warnings, for example when publishing a schema or running
    tests that you know do not use saved parsers.
    
    Also adds an error if a schema path does not start with '/' and improve
    the duplicate classifiers error message.
    
    Closes #56
---
 .../scala/org/apache/daffodil/DaffodilPlugin.scala | 31 ++++++++++++++++++----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/main/scala/org/apache/daffodil/DaffodilPlugin.scala 
b/src/main/scala/org/apache/daffodil/DaffodilPlugin.scala
index 76f1fd3..c694cdd 100644
--- a/src/main/scala/org/apache/daffodil/DaffodilPlugin.scala
+++ b/src/main/scala/org/apache/daffodil/DaffodilPlugin.scala
@@ -280,7 +280,7 @@ object DaffodilPlugin extends AutoPlugin {
     },
 
     /**
-     * define the artifacts and the packageDaffodilXyzBin task that creates 
the artifacts
+     * define the artifacts, products, and the packageDaffodilBin task that 
creates the artifacts/products
      */
     packageDaffodilBin / artifacts := {
       daffodilPackageBinVersions.value.flatMap { daffodilVersion =>
@@ -294,7 +294,7 @@ object DaffodilPlugin extends AutoPlugin {
         }
       }.toSeq
     },
-    packageDaffodilBin := {
+    packageDaffodilBin / products := {
       val logger = streams.value.log
 
       // options to provide to the forked JVM process used to save a processor
@@ -323,7 +323,7 @@ object DaffodilPlugin extends AutoPlugin {
       val duplicates = groupedClassifiers.filter { case (k, v) => v.length > 1 
}.keySet
       if (duplicates.size > 0) {
         val dupsStr = duplicates.mkString(", ")
-        val msg = s"daffodilPackageBinInfos defines duplicate classifiers: 
$dupsStr"
+        val msg = s"daffodilPackageBinInfos defines duplicate name parameters: 
$dupsStr"
         throw new MessageOnlyException(msg)
       }
 
@@ -355,6 +355,12 @@ object DaffodilPlugin extends AutoPlugin {
             val targetName = 
s"${name.value}-${version.value}-${classifier}.bin"
             val targetFile = target.value / targetName
 
+            if (!dbi.schema.startsWith("/")) {
+              throw new MessageOnlyException(
+                s"daffodilPackageBinInfos schema must be a resource path that 
starts with '/':  ${dbi.schema}",
+              )
+            }
+
             val args = jvmArgs ++ Seq(
               "-classpath",
               classpathFiles.mkString(File.pathSeparator),
@@ -382,6 +388,21 @@ object DaffodilPlugin extends AutoPlugin {
       val savedParsers = cachedFun(filesToWatch)
       savedParsers.toSeq
     },
+    packageDaffodilBin := {
+      val logger = streams.value.log
+
+      val prods = (packageDaffodilBin / products).value
+      if (prods.length == 0) {
+        // only warn if packageDaffodilBin is expliclty run and no artifacts 
are generated
+        // because one of the bin infos settings is empty. Any tasks that need 
this list of save
+        // parser files but do not want this warning should access
+        // (packageDaffodilBin / products).value instead of 
packageDaffodilBin.value
+        logger.warn(
+          "no saved parsers created--one or both of daffodilPackageBinInfos 
and daffodilPackageBinVersions are empty",
+        )
+      }
+      prods
+    },
 
     /**
      * These two settings tell sbt about the artifacts and the task that 
generates the artifacts
@@ -390,7 +411,7 @@ object DaffodilPlugin extends AutoPlugin {
     artifacts ++= (packageDaffodilBin / artifacts).value,
     packagedArtifacts := {
       val arts = (packageDaffodilBin / artifacts).value
-      val files = packageDaffodilBin.value
+      val files = (packageDaffodilBin / products).value
 
       // the artifacts and associated files are not necessarily in the same 
order. For each
       // artifact, we need to find the associated file (the one that ends with 
the same
@@ -420,7 +441,7 @@ object DaffodilPlugin extends AutoPlugin {
 
         // force creation of saved parsers, there isn't currently a way to 
build them for just
         // daffodilVersion
-        val allSavedParsers = packageDaffodilBin.value
+        val allSavedParsers = (packageDaffodilBin / products).value
 
         // copy the saved parsers for the current daffodilVersion to the root 
of the
         // resourceManaged directory, and consider those our generated 
resources

Reply via email to