stevedlawrence commented on code in PR #136:
URL: https://github.com/apache/daffodil-sbt/pull/136#discussion_r2518700698


##########
utils/src/main/scala/org/apache/daffodil/DaffodilSaver.scala:
##########
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License") you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil
+
+import java.nio.channels.FileChannel
+import java.nio.file.Paths
+import java.nio.file.StandardOpenOption
+import scala.jdk.CollectionConverters._
+
+// When creating saved parsers using packageDaffodilBin, we need to create a 
saved parser for a
+// different version of Daffodil than is added to libraryDependencies. For 
this reason, we have
+// this DaffodilSaver class, which can be forked with a Different versionof 
Daffodil on the
+// classpath. Note that we use sbt-projectmatrix to compile this class into 
three separate jars
+// for each version of Scala/Daffodil (Scala 2.12 is used for Daffodil 3.10.0 
and older, Scala
+// 2.13 is used for Daffodil 3.11.0, and Scala 3.x is used for Daffodil 4.0.0 
and newer. WWe
+// expect the sbt plugin to set up the classpath to include the correct jar 
for the version of
+// Daffodil being used when forking this class.
+object DaffodilSaver {
+
+  /**
+   * Usage: daffodilSaver <apiVersion> <schemaResource> <outputFile> <root> 
<config>
+   *
+   * If <root> or <config> is unknown/not-provided, they must be the empty 
string
+   */
+  def main(args: Array[String]): Unit = {
+    try {
+      run(args)
+    } catch {
+      case e: Exception => {

Review Comment:
   Actually, I think this is unnecessary. All this catch does is print the 
exception stack trace and exit with an exit code of 1. But the JVM already does 
that if main throws an exception.
   
   I think this was maybe an artifact of this originally being written in Java, 
and it was probably just so we didn't have to list a bunch of checked 
exceptions. Scala doesn't care about checked not catching exceptions, so I 
think this can all just be removed.



-- 
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]

Reply via email to