From 40f387966d2fe91af856a80e564c2816db1c3eda Mon Sep 17 00:00:00 2001 From: Jason Pickens Date: Sun, 7 Mar 2021 22:02:49 +1300 Subject: [PATCH] Add example project --- .github/workflows/ci.yml | 2 +- README.md | 6 ------ build.sbt | 20 +++++++++++++------ .../co/bottech/scala2plantuml/example/A.scala | 5 +++++ .../co/bottech/scala2plantuml/example/B.scala | 11 ++++++++++ .../co/bottech/scala2plantuml/example/C.scala | 3 +++ .../bottech/scala2plantuml/example/Main.scala | 8 ++++++++ 7 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 example/src/main/scala/nz/co/bottech/scala2plantuml/example/A.scala create mode 100644 example/src/main/scala/nz/co/bottech/scala2plantuml/example/B.scala create mode 100644 example/src/main/scala/nz/co/bottech/scala2plantuml/example/C.scala create mode 100644 example/src/main/scala/nz/co/bottech/scala2plantuml/example/Main.scala diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d91298..910e39d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: run: sbt ++${{ matrix.scala }} scripted - name: Compress target directories - run: tar cf targets.tar sbt/target target doc-templates/target cli/target core/target project/target + run: tar cf targets.tar sbt/target target doc-templates/target cli/target core/target example/target project/target - name: Upload target directories uses: actions/upload-artifact@v2 diff --git a/README.md b/README.md index 064cc76..35bf404 100644 --- a/README.md +++ b/README.md @@ -11,12 +11,6 @@ It comes as a standalone library, a CLI tool and an sbt plugin. Scala2PlantUML consumes [SemanticDB] files so you will need to know how to create those or simply follow the sbt setup instructions below. -Example: - -```shell mdoc -scala2PlantUML -``` - ## sbt ### Enable SemanticDB diff --git a/build.sbt b/build.sbt index 3c31232..359d3a0 100644 --- a/build.sbt +++ b/build.sbt @@ -5,6 +5,7 @@ val supportedScalaVersions = List(scala212, scala213) val logbackVersion = "1.2.3" val scalaCollectionCompatibilityVersion = "2.3.2" val scoptVersion = "4.0.0" +val sdbVersion = "4.4.10" val slf4jVersion = "1.7.30" val utestVersion = "0.7.7" @@ -107,10 +108,8 @@ val metaProjectSettings = List( publish / skip := true ) -val libraryProjectSettings = commonProjectSettings - lazy val root = (project in file(".")) - .aggregate(cli, core, docs, sbtProject) + .aggregate(cli, core, docs, example, sbtProject) .settings(metaProjectSettings) .settings( crossScalaVersions := supportedScalaVersions, @@ -122,7 +121,7 @@ lazy val root = (project in file(".")) ) lazy val core = project - .settings(libraryProjectSettings) + .settings(commonProjectSettings) .settings( libraryDependencies ++= collectionsCompatibilityDependency.value, libraryDependencies ++= List( @@ -135,7 +134,7 @@ lazy val core = project ), name := s"${(LocalRootProject / name).value}", semanticdbEnabled := true, - semanticdbVersion := "4.4.10", + semanticdbVersion := sdbVersion, testFrameworks += new TestFramework("utest.runner.Framework"), Test / managedSourceDirectories += (Test / semanticdbTargetRoot).value, Test / fullClasspath += (Test / semanticdbTargetRoot).value @@ -144,7 +143,7 @@ lazy val core = project lazy val cli = project .dependsOn(core) .enablePlugins(BuildInfoPlugin) - .settings(libraryProjectSettings) + .settings(commonProjectSettings) .settings( buildInfoKeys := Seq[BuildInfoKey](version), buildInfoPackage := s"${organization.value}.${(LocalRootProject / name).value}", @@ -211,6 +210,15 @@ lazy val docs = (project in file("doc-templates")) unusedCompileDependenciesFilter -= moduleFilter("org.scalameta", "mdoc*") ) +lazy val example = project + .settings(commonProjectSettings) + .settings( + semanticdbEnabled := true, + semanticdbIncludeInJar := true, + semanticdbVersion := sdbVersion, + versionPolicyFirstVersion := Some("0.1.13"), + ) + def isScala213Setting: Def.Initialize[Boolean] = Def.setting { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, n)) if n == 13 => true diff --git a/example/src/main/scala/nz/co/bottech/scala2plantuml/example/A.scala b/example/src/main/scala/nz/co/bottech/scala2plantuml/example/A.scala new file mode 100644 index 0000000..957e8ee --- /dev/null +++ b/example/src/main/scala/nz/co/bottech/scala2plantuml/example/A.scala @@ -0,0 +1,5 @@ +package nz.co.bottech.scala2plantuml.example + +class A extends B { + override def b: C = C(this) +} diff --git a/example/src/main/scala/nz/co/bottech/scala2plantuml/example/B.scala b/example/src/main/scala/nz/co/bottech/scala2plantuml/example/B.scala new file mode 100644 index 0000000..3c003f8 --- /dev/null +++ b/example/src/main/scala/nz/co/bottech/scala2plantuml/example/B.scala @@ -0,0 +1,11 @@ +package nz.co.bottech.scala2plantuml.example + +trait B { + + def b: C +} + +object B { + + val Const: String = "X" +} diff --git a/example/src/main/scala/nz/co/bottech/scala2plantuml/example/C.scala b/example/src/main/scala/nz/co/bottech/scala2plantuml/example/C.scala new file mode 100644 index 0000000..753689f --- /dev/null +++ b/example/src/main/scala/nz/co/bottech/scala2plantuml/example/C.scala @@ -0,0 +1,3 @@ +package nz.co.bottech.scala2plantuml.example + +final case class C(value: A) diff --git a/example/src/main/scala/nz/co/bottech/scala2plantuml/example/Main.scala b/example/src/main/scala/nz/co/bottech/scala2plantuml/example/Main.scala new file mode 100644 index 0000000..49fbc47 --- /dev/null +++ b/example/src/main/scala/nz/co/bottech/scala2plantuml/example/Main.scala @@ -0,0 +1,8 @@ +package nz.co.bottech.scala2plantuml.example + +object Main extends App { + + { + val _ = new A + } +}