Skip to content

Commit ccdde4f

Browse files
authored
Merge branch 'main' into update/scala-collection-compat-2.4.2
2 parents f1ef45b + 99462f3 commit ccdde4f

File tree

5 files changed

+50
-125
lines changed

5 files changed

+50
-125
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: sbt ++${{ matrix.scala }} scripted
6161

6262
- name: Compress target directories
63-
run: tar cf targets.tar sbt/target target meta/docs/target cli/target core/target example/target project/target
63+
run: tar cf targets.tar sbt/target meta/integration-tests/target target meta/docs/target cli/target core/target example/target project/target
6464

6565
- name: Upload target directories
6666
uses: actions/upload-artifact@v2

README.md

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -98,123 +98,6 @@ The pattern supports two wildcards:
9898
The --dir, --jar, and --url options specify the directories and JAR files that are used when locating SemanticDB files.
9999
Each of these can be provided multiple times.
100100
101-
By default, the classpath that was used when executing Scala2PlantUML is also used.
102-
103-
-d, --dir <dir> Directories of the SemanticDB target roots containing META-INF/semanticdb/**/*.semanticdb files.
104-
105-
Example:
106-
--dir 'my-project/target/scala-2.13/meta'
107-
108-
-j, --jar <jar> JAR containing META-INF/semanticdb/**/*.semanticdb files.
109-
110-
Example:
111-
--jar 'foo.jar'
112-
113-
-u, --url <url> A URL to a JAR containing META-INF/semanticdb/**/*.semanticdb files.
114-
115-
Example:
116-
--url 'https://repo1.maven.org/maven2/com/example/foo/foo_2.13/1.0.0/foo_2.13-1.0.0-semanticdb.jar'
117-
118-
The --project and --source options specify where within the search locations the SemanticDB files can be found.
119-
Each of these can be provided multiple times. The result will be all combinations of projects and source roots.
120-
121-
-p, --project <project> The name of the projects that have SemanticDB files.
122-
123-
The project name will be used when looking for SemanticDB files such as:
124-
META-INF/semanticdb/<project>/<source>/*.semanticdb
125-
126-
An empty project name will search in:
127-
META-INF/semanticdb/<source>/*.semanticdb
128-
129-
Default: ''
130-
131-
Example:
132-
--project my-project
133-
134-
-s, --source <source> The directory relative to the project where the source files were located.
135-
136-
The source will be used when looking for SemanticDB files such as
137-
META-INF/semanticdb/<project>/<source>/*.semanticdb.
138-
139-
Default: src/main/scala
140-
141-
Example:
142-
--source 'source/scala'
143-
144-
-l, --max-level <level> The maximum number of levels that will be traversed when following symbol references.
145-
146-
This means that parent symbols that would be beyond the max level will not be shown.
147-
148-
A diagram with a max-level of 1 will only contain the initial symbol.
149-
150-
Default: Unlimited
151-
152-
Example:
153-
--max-level 3
154-
155-
-o, --output <file> Write the output to the given file.
156-
157-
Example:
158-
--output docs/diagrams/my-project.puml
159-
160-
-c, --colour <value> Enables coloured output.
161-
162-
Default: true
163-
164-
Example:
165-
--colour false
166-
167-
-v, --verbose Increases the log level.
168-
169-
This can be provided twice for the most verbose logging.
170-
171-
Example:
172-
-vv
173-
174-
-h, --help
175-
--version
176-
Error: Missing argument symbol
177-
Scala2PlantUML version 0.2.0
178-
Usage: scala2plantuml [options] symbol
179-
180-
Scala2PlantUML generates PlantUML Class Diagrams from Scala SemanticDB files.
181-
182-
symbol The symbol to use as the starting point for generating the diagram.
183-
184-
To get a symbol from a class name, convert the package name separate '.' to '/' and add a '#'
185-
suffix. For an object use a suffix of '.'.
186-
187-
See https://scalameta.org/docs/semanticdb/specification.html#symbol-1 for the full syntax.
188-
189-
Examples:
190-
'com/example/Foo#' (class com.example.Foo)
191-
'com/example/Foo.' (object com.example.Foo)
192-
'com/example/Foo.bar.' (value/variable bar on object com.example.Foo)
193-
'com/example/Foo#baz().' (function baz on class com.example.Foo)
194-
195-
The --include and --exclude options control which symbols will be processed. Each of these can be provided multiple times.
196-
197-
The pattern supports two wildcards:
198-
1) ** (matches any character)
199-
2) * (matches all characters except for '/')
200-
201-
-i, --include <pattern> Only include symbols that match the pattern.
202-
203-
Default: '**'
204-
205-
Example:
206-
--include 'com/example/**/model/*'
207-
208-
-e, --exclude <pattern> Excludes all symbols that match the pattern.
209-
210-
Default: 'scala/**', 'java/**'
211-
212-
Example:
213-
--exclude 'com/example/**/data/*'
214-
215-
The --dir, --jar, and --url options specify the directories and JAR files that are used when locating SemanticDB files.
216-
Each of these can be provided multiple times.
217-
218101
By default, the classpath that was used when executing Scala2PlantUML is also used.
219102
220103
-d, --dir <dir> Directories of the SemanticDB target roots containing META-INF/semanticdb/**/*.semanticdb files.

build.sbt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import com.typesafe.tools.mima.core._
2+
13
val scala212 = "2.12.13"
24
val scala213 = "2.13.4"
35
val supportedScalaVersions = List(scala212, scala213)
46

57
val logbackVersion = "1.2.3"
68
val scalaCollectionCompatibilityVersion = "2.4.2"
7-
val scoptVersion = "4.0.0"
9+
val scoptVersion = "4.0.1"
810
val sdbVersion = "4.4.10"
911
val slf4jVersion = "1.7.30"
1012
val utestVersion = "0.7.7"
@@ -75,7 +77,7 @@ inThisBuild(
7577
)
7678
),
7779
githubWorkflowPublishTargetBranches := List(RefPredicate.StartsWith(Ref.Tag("v"))),
78-
githubWorkflowTargetTags ++= Seq("v*"),
80+
githubWorkflowTargetTags ++= List("v*"),
7981
pgpSigningKey := Some("0x8DB7DFA142551359!"),
8082
// This needs to be set otherwise the GitHub workflow plugin gets confused about which
8183
// version to use for the publish job.
@@ -87,6 +89,9 @@ inThisBuild(
8789

8890
val commonProjectSettings = List(
8991
isScala213 := isScala213Setting.value,
92+
// Who cares about these. Forwards binary compatibility is used as an approximation for source
93+
// backwards compatibility and missing classes isn't a problem.
94+
mimaForwardIssueFilters += "0.2.0" -> List(ProblemFilters.exclude[MissingClassProblem]("nz.co.bottech.scala2plantuml.*")),
9095
name := s"${(LocalRootProject / name).value}-${name.value}",
9196
scalastyleFailOnError := true,
9297
scalastyleFailOnWarning := true,
@@ -109,7 +114,7 @@ val metaProjectSettings = List(
109114
)
110115

111116
lazy val root = (project in file("."))
112-
.aggregate(cli, core, docs, example, sbtProject)
117+
.aggregate(cli, core, docs, example, integrationTests, sbtProject)
113118
.settings(metaProjectSettings)
114119
.settings(
115120
crossScalaVersions := supportedScalaVersions,
@@ -156,6 +161,18 @@ lazy val cli = project
156161
)
157162
)
158163

164+
// Use a separate project rather than a configuration to get IntelliJ support.
165+
lazy val integrationTests = (project in (file("meta") / "integration-tests"))
166+
.settings(metaProjectSettings)
167+
.settings(
168+
libraryDependencies ++= List(
169+
"com.lihaoyi" %% "utest" % utestVersion % Test
170+
),
171+
testFrameworks += new TestFramework("utest.runner.Framework"),
172+
Test / fork := true,
173+
Test / javaOptions += s"-Dit.classpath=${(cli / Compile / fullClasspathAsJars).value.map(_.data).mkString(":")}"
174+
)
175+
159176
lazy val sbtProject = (project in file("sbt"))
160177
.dependsOn(core)
161178
.enablePlugins(SbtPlugin)
@@ -191,7 +208,7 @@ lazy val sbtProject = (project in file("sbt"))
191208
scriptedLaunchOpts += s"-Dplugin.version=${version.value}"
192209
)
193210

194-
lazy val docs = (project in file("meta/docs"))
211+
lazy val docs = (project in (file("meta") / "docs"))
195212
// Include build info here so that we can override the version.
196213
.enablePlugins(BuildInfoPlugin, MdocPlugin)
197214
.dependsOn(cli)

cli/src/main/scala/nz/co/bottech/scala2plantuml/ConfigParser.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
package nz.co.bottech.scala2plantuml
22

3-
import scopt.{DefaultOEffectSetup, DefaultOParserSetup, OEffectSetup, OParser, OParserSetup}
3+
import scopt._
44

55
import java.io.File
66

77
object ConfigParser {
88

9+
final private object Terminated extends RuntimeException
10+
911
private val parserSetup: OParserSetup = new DefaultOParserSetup {
1012
override def showUsageOnError: Option[Boolean] = Some(true)
1113
}
1214

1315
private val effectSetup: OEffectSetup = new DefaultOEffectSetup {
16+
1417
// Don't exit otherwise sbt traps this and there are confusing errors.
1518
// This is especially troublesome when running this from mdoc.
16-
override def terminate(exitState: Either[String, Unit]): Unit = ()
19+
@SuppressWarnings(Array("org.wartremover.warts.Throw"))
20+
override def terminate(exitState: Either[String, Unit]): Unit =
21+
throw Terminated
1722
}
1823

1924
// scalastyle:off method.length
@@ -218,7 +223,10 @@ object ConfigParser {
218223
// scalastyle:on method.length
219224

220225
def parse(args: Array[String]): Option[Config] =
221-
OParser.parse(parser, args, Config(), parserSetup, effectSetup)
226+
try OParser.parse(parser, args, Config(), parserSetup, effectSetup)
227+
catch {
228+
case Terminated => None
229+
}
222230

223231
private def validateConfig(config: Config): Either[String, Unit] =
224232
if (config.ignore(config.symbol)) Left("Symbol must match include patterns and not match exclude patterns.")
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package nz.co.bottech.scala2plantuml.cli
2+
3+
import utest._
4+
5+
import scala.sys.process._
6+
7+
object CLIItTests extends TestSuite {
8+
9+
private val classpath = Option(System.getProperty("it.classpath")).get
10+
11+
val tests: Tests = Tests {
12+
test("show help") {
13+
val exitCode = List("java", "-classpath", classpath, "nz.co.bottech.scala2plantuml.Scala2PlantUML").!
14+
assert(exitCode == 0)
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)