mike-mcgann commented on code in PR #919:
URL: https://github.com/apache/daffodil/pull/919#discussion_r1092259489


##########
project/OsgiCheck.scala:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+import sbt._
+import sbt.Keys._
+import sbt.KeyRanks._
+
+object OsgiCheckPlugin extends AutoPlugin {
+
+  class OsgiCheckException()
+    extends RuntimeException("OSGI check failed")
+      with FeedbackProvidedException
+
+  object autoImport {
+    val osgiOwnedPackages = taskKey[Set[String]]("Get all packages owned by 
this project").withRank(BTask)
+    val osgiOwnedPackagesWithOwner = taskKey[(Set[String], String)]("Get a 
tuple of the osgiOwnedPackages and the project name that owns 
them").withRank(Invisible)
+    val osgiCheck = taskKey[Unit]("Check all subpackages for osgi 
conflicts").withRank(ATask)
+  }
+
+  import autoImport._
+
+  private val packageMatcher = """^\s*package (\S+);?.*$""".r
+
+  override def trigger = allRequirements
+
+  val allSubprojectsFilter = ScopeFilter(inAggregates(ThisProject, 
includeRoot=false))
+
+  override def projectSettings: Seq[Def.Setting[_]] = {Seq(
+    osgiOwnedPackages := {
+      (Compile / sources).value.flatMap { file =>
+        var source = scala.io.Source.fromFile(file)
+        val optPackage = source.getLines.collectFirst {
+          case packageMatcher(packageName) => packageName
+        }
+        optPackage

Review Comment:
   I've made it a warning for now. We can always change it to an exception 
later if we feel that is better. 
   
   I don't think the script should be looking at commented-out lines and it 
should be kept simple. There are many reasons that a package-ish looking 
statement could appear in comments and not be actual code.  



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