diff options
author | Stewart Stewart <stewinsalot@gmail.com> | 2017-02-21 22:41:54 -0500 |
---|---|---|
committer | Stewart Stewart <stewinsalot@gmail.com> | 2017-02-21 22:41:54 -0500 |
commit | ee5142f4e3c889429c00fddf3d045506f10acf94 (patch) | |
tree | 337ac51ed0d12340caa0bae3d56ed22cd111f429 /src/main/scala | |
parent | 9e82e7b3e27daab015da0b21411041eedb859698 (diff) | |
download | slick-codegen-plugin-ee5142f4e3c889429c00fddf3d045506f10acf94.tar.gz slick-codegen-plugin-ee5142f4e3c889429c00fddf3d045506f10acf94.tar.bz2 slick-codegen-plugin-ee5142f4e3c889429c00fddf3d045506f10acf94.zip |
add codegen header
Diffstat (limited to 'src/main/scala')
-rw-r--r-- | src/main/scala/CodegenPlugin.scala | 6 | ||||
-rw-r--r-- | src/main/scala/NamespacedCodegen.scala | 3 | ||||
-rw-r--r-- | src/main/scala/OutputHelpers.scala | 6 |
3 files changed, 12 insertions, 3 deletions
diff --git a/src/main/scala/CodegenPlugin.scala b/src/main/scala/CodegenPlugin.scala index 0c8020f..c90fe66 100644 --- a/src/main/scala/CodegenPlugin.scala +++ b/src/main/scala/CodegenPlugin.scala @@ -46,6 +46,10 @@ object CodegenPlugin extends AutoPlugin { "codegen-type-replacements", "A map of types to find and replace" ) + lazy val codegenHeader = SettingKey[String]( + "codegen-header", + "Comments that go at the top of generated files; notices and tooling directives." + ) lazy val slickCodeGenTask = TaskKey[Unit]("gen-tables", "generate the table definitions") @@ -58,6 +62,7 @@ object CodegenPlugin extends AutoPlugin { codegenIdType := Option.empty, codegenSchemaImports := List.empty, codegenTypeReplacements := Map.empty, + codegenHeader := "AUTO-GENERATED Slick data model", slickCodeGenTask := Def.taskDyn { Def.task { codegenDatabaseConfigs.value.foreach { @@ -77,6 +82,7 @@ object CodegenPlugin extends AutoPlugin { Some(parts).filter(_.nonEmpty).map(_.mkString(" with ")) }, codegenIdType.value, + codegenHeader.value, codegenSchemaImports.value, codegenTypeReplacements.value ) diff --git a/src/main/scala/NamespacedCodegen.scala b/src/main/scala/NamespacedCodegen.scala index affd36c..c545b80 100644 --- a/src/main/scala/NamespacedCodegen.scala +++ b/src/main/scala/NamespacedCodegen.scala @@ -24,6 +24,7 @@ object Generator { manualForeignKeys: Map[(String, String), (String, String)], parentType: Option[String], idType: Option[String], + header: String, schemaImports: List[String], typeReplacements: Map[String, String]) = { val dc: DatabaseConfig[JdbcProfile] = @@ -54,6 +55,7 @@ object Generator { manualForeignKeys, parentType, idType, + header, schemaImports, typeReplacements) generator.writeToFile(profile = profile, @@ -75,6 +77,7 @@ class Generator(pkg: String, manualForeignKeys: Map[(String, String), (String, String)], override val parentType: Option[String], idType: Option[String], + override val headerComment: String, schemaImports: List[String], typeReplacements: Map[String, String]) extends SourceCodeGenerator(schemaOnlyModel) diff --git a/src/main/scala/OutputHelpers.scala b/src/main/scala/OutputHelpers.scala index f982124..ce22f2a 100644 --- a/src/main/scala/OutputHelpers.scala +++ b/src/main/scala/OutputHelpers.scala @@ -9,10 +9,10 @@ trait OutputHelpers extends slick.codegen.OutputHelpers { container: String, parentType: Option[String]): String = { val traitName = container.capitalize + "SchemaDef" - s"""|package $pkg - |$imports + s"""|${headerComment.trim().lines.map("// " + _).mkString("\n")} + |package $pkg | - |// AUTO-GENERATED Slick data model + |$imports | |/** Stand-alone Slick data model for immediate use */ |object $container extends { |