diff --git a/codegen/src/main/scala/overflowdb/codegen/CodeGen.scala b/codegen/src/main/scala/overflowdb/codegen/CodeGen.scala index 2e1bf266..f69e3e38 100644 --- a/codegen/src/main/scala/overflowdb/codegen/CodeGen.scala +++ b/codegen/src/main/scala/overflowdb/codegen/CodeGen.scala @@ -1259,6 +1259,28 @@ class CodeGen(schema: Schema) { val srcFile = nodeType.className + ".scala" results.append(baseDir.createChild(srcFile).write(src)) } + + + val packageObject = { + val lastSeparatorIdx = basePackage.lastIndexOf('.') + val packageParent = basePackage.take(lastSeparatorIdx) + val packageSimpleName = basePackage.drop(lastSeparatorIdx + 1) + + s"""package $packageParent + | + |package object $packageSimpleName { + | // some type aliases so that the domain-specific code can avoid referencing the `overflowdb` namespace + | + | object help { + | type Doc = _root_.overflowdb.traversal.help.Doc + | type Traversal = _root_.overflowdb.traversal.help.Traversal + | type TraversalSource = _root_.overflowdb.traversal.help.TraversalSource + | } + |} + |""".stripMargin + } + results.append(baseDir.createChild("package.scala").write(packageObject)) + results.toSeq } diff --git a/integration-tests/schemas/build.sbt b/integration-tests/schemas/build.sbt index ad453939..1ba2b84f 100644 --- a/integration-tests/schemas/build.sbt +++ b/integration-tests/schemas/build.sbt @@ -19,7 +19,7 @@ generateDomainClasses := Def.taskDyn { } } else { Def.task { - val invoked = (Compile/runMain).toTask(s" CodegenForAllSchemas").value + val invoked = (Compile/runMain).toTask(s" overflowdb.integrationtests.CodegenForAllSchemas").value lastSchemaMd5(currentSchemaMd5) FileUtils.listFilesRecursively(outputRoot) } diff --git a/integration-tests/schemas/src/main/scala/CodegenForAllSchemas.scala b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/CodegenForAllSchemas.scala similarity index 97% rename from integration-tests/schemas/src/main/scala/CodegenForAllSchemas.scala rename to integration-tests/schemas/src/main/scala/overflowdb/integrationtests/CodegenForAllSchemas.scala index 23b6ee73..0250f186 100644 --- a/integration-tests/schemas/src/main/scala/CodegenForAllSchemas.scala +++ b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/CodegenForAllSchemas.scala @@ -1,3 +1,5 @@ +package overflowdb.integrationtests + import overflowdb.codegen.CodeGen import java.io.File diff --git a/integration-tests/schemas/src/main/scala/TestSchema.scala b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema.scala similarity index 85% rename from integration-tests/schemas/src/main/scala/TestSchema.scala rename to integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema.scala index 616b80a2..965b0eb4 100644 --- a/integration-tests/schemas/src/main/scala/TestSchema.scala +++ b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema.scala @@ -1,3 +1,5 @@ +package overflowdb.integrationtests + import overflowdb.schema.SchemaBuilder trait TestSchema { diff --git a/integration-tests/schemas/src/main/scala/TestSchema01.scala b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema01.scala similarity index 97% rename from integration-tests/schemas/src/main/scala/TestSchema01.scala rename to integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema01.scala index f4f8411a..17cd9f64 100644 --- a/integration-tests/schemas/src/main/scala/TestSchema01.scala +++ b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema01.scala @@ -1,3 +1,5 @@ +package overflowdb.integrationtests + import overflowdb.schema.Property.ValueType import overflowdb.schema._ diff --git a/integration-tests/schemas/src/main/scala/TestSchema02.scala b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema02.scala similarity index 97% rename from integration-tests/schemas/src/main/scala/TestSchema02.scala rename to integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema02.scala index 8236aea1..83efa1e7 100644 --- a/integration-tests/schemas/src/main/scala/TestSchema02.scala +++ b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema02.scala @@ -1,3 +1,5 @@ +package overflowdb.integrationtests + import overflowdb.schema.Property.ValueType import overflowdb.schema._ diff --git a/integration-tests/schemas/src/main/scala/TestSchema03.scala b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema03.scala similarity index 97% rename from integration-tests/schemas/src/main/scala/TestSchema03.scala rename to integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema03.scala index b6633d14..d0fdeffd 100644 --- a/integration-tests/schemas/src/main/scala/TestSchema03.scala +++ b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema03.scala @@ -1,3 +1,5 @@ +package overflowdb.integrationtests + /** complex scenario with multiple layers of base nodes * similar to what we use in docker-ext schema extension */ diff --git a/integration-tests/schemas/src/main/scala/TestSchema04.scala b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema04.scala similarity index 97% rename from integration-tests/schemas/src/main/scala/TestSchema04.scala rename to integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema04.scala index 2b3155ce..cdd997b1 100644 --- a/integration-tests/schemas/src/main/scala/TestSchema04.scala +++ b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema04.scala @@ -1,3 +1,5 @@ +package overflowdb.integrationtests + import overflowdb.schema.Property._ /** For testing default values on properties with Cardinality.One: we have type-dependent defaults, diff --git a/integration-tests/schemas/src/main/scala/TestSchema05.scala b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema05.scala similarity index 96% rename from integration-tests/schemas/src/main/scala/TestSchema05.scala rename to integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema05.scala index 22920bab..aad38df2 100644 --- a/integration-tests/schemas/src/main/scala/TestSchema05.scala +++ b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema05.scala @@ -1,3 +1,5 @@ +package overflowdb.integrationtests + import overflowdb.schema.Property._ /** testing all property types with Cardinality.ZeroOrOne */ diff --git a/integration-tests/schemas/src/main/scala/TestSchema06.scala b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema06.scala similarity index 95% rename from integration-tests/schemas/src/main/scala/TestSchema06.scala rename to integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema06.scala index 66f99fcd..dcccce56 100644 --- a/integration-tests/schemas/src/main/scala/TestSchema06.scala +++ b/integration-tests/schemas/src/main/scala/overflowdb/integrationtests/TestSchema06.scala @@ -1,3 +1,5 @@ +package overflowdb.integrationtests + import overflowdb.schema.Property.ValueType import overflowdb.schema._ diff --git a/integration-tests/tests/src/test/scala/Schema01Test.scala b/integration-tests/tests/src/test/scala/Schema01Test.scala index 983b442c..c1a99b52 100644 --- a/integration-tests/tests/src/test/scala/Schema01Test.scala +++ b/integration-tests/tests/src/test/scala/Schema01Test.scala @@ -1,6 +1,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec import overflowdb.{BatchedUpdate, Config, Graph} +import overflowdb.integrationtests.testschema01 import testschema01._ import testschema01.nodes._ import testschema01.edges._ @@ -8,7 +9,7 @@ import testschema01.traversal._ import scala.jdk.CollectionConverters.IteratorHasAsScala class Schema01Test extends AnyWordSpec with Matchers { - import testschema01.traversal._ + import overflowdb.integrationtests.testschema01.traversal._ "constants" in { PropertyNames.NAME shouldBe "NAME" Properties.Order.name shouldBe "ORDER" @@ -109,7 +110,7 @@ class Schema01Test extends AnyWordSpec with Matchers { } } "work around scala bug 4762, ie generate no extraneous fields" in { - Class.forName("testschema01.nodes.Node1").getDeclaredFields.length shouldBe 0 + Class.forName("overflowdb.integrationtests.testschema01.nodes.Node1").getDeclaredFields.length shouldBe 0 } } diff --git a/integration-tests/tests/src/test/scala/Schema02Test.scala b/integration-tests/tests/src/test/scala/Schema02Test.scala index 2534fecd..262d4fa9 100644 --- a/integration-tests/tests/src/test/scala/Schema02Test.scala +++ b/integration-tests/tests/src/test/scala/Schema02Test.scala @@ -1,6 +1,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec import overflowdb.SchemaViolationException +import overflowdb.integrationtests.testschema02 import testschema02._ import testschema02.edges._ import testschema02.nodes._ diff --git a/integration-tests/tests/src/test/scala/Schema03Test.scala b/integration-tests/tests/src/test/scala/Schema03Test.scala index 27e9bf75..8c540d66 100644 --- a/integration-tests/tests/src/test/scala/Schema03Test.scala +++ b/integration-tests/tests/src/test/scala/Schema03Test.scala @@ -1,4 +1,7 @@ import overflowdb.traversal._ +import overflowdb.integrationtests.testschema03a +import overflowdb.integrationtests.testschema03b +import overflowdb.integrationtests.testschema03c class Schema03aTest { import testschema03a._ diff --git a/integration-tests/tests/src/test/scala/Schema04Test.scala b/integration-tests/tests/src/test/scala/Schema04Test.scala index 19d87273..19860abf 100644 --- a/integration-tests/tests/src/test/scala/Schema04Test.scala +++ b/integration-tests/tests/src/test/scala/Schema04Test.scala @@ -1,6 +1,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec import overflowdb.Graph +import overflowdb.integrationtests.testschema04 import testschema04._ import testschema04.edges._ import testschema04.nodes._ diff --git a/integration-tests/tests/src/test/scala/Schema05Test.scala b/integration-tests/tests/src/test/scala/Schema05Test.scala index 48dbf7ba..458b4bf1 100644 --- a/integration-tests/tests/src/test/scala/Schema05Test.scala +++ b/integration-tests/tests/src/test/scala/Schema05Test.scala @@ -1,6 +1,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec import overflowdb.{Config, Graph} +import overflowdb.integrationtests.testschema05 import testschema05._ import testschema05.edges._ import testschema05.nodes._ diff --git a/integration-tests/tests/src/test/scala/Schema06Test.scala b/integration-tests/tests/src/test/scala/Schema06Test.scala index 33790972..c65eaca3 100644 --- a/integration-tests/tests/src/test/scala/Schema06Test.scala +++ b/integration-tests/tests/src/test/scala/Schema06Test.scala @@ -1,6 +1,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec import overflowdb.{BatchedUpdate, Config, Graph} +import overflowdb.integrationtests.testschema06 import testschema06._ import testschema06.nodes._ import testschema06.edges._