Skip to content

Commit 393dcdd

Browse files
authored
Merge pull request #115 from Duhemm/specify-input
Add arg to specify input configuration in `export`
2 parents d1d0f0d + f13aefa commit 393dcdd

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

multiversion/src/main/scala/multiversion/commands/ExportCommand.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import multiversion.resolvers.Sha256
5656
@CommandName("export")
5757
case class ExportCommand(
5858
lint: Boolean = true,
59+
inputPath: Path = Paths.get("3rdparty.yaml"),
5960
outputPath: Path = Paths.get("/tmp", "jvm_deps.bzl"),
6061
cache: Option[Path] = None,
6162
@Inline
@@ -165,13 +166,15 @@ case class ExportCommand(
165166

166167
private def parseThirdpartyConfig(): Result[ThirdpartyConfig] = {
167168
val configPath =
168-
app.env.workingDirectory.resolve("3rdparty.yaml")
169+
app.env.workingDirectory.resolve(inputPath)
169170
if (!Files.isRegularFile(configPath)) {
170171
ErrorResult(
171172
Diagnostic.error(
172173
s"no such file: $configPath\n\tTo fix this problem, change your working directory or create this file"
173174
)
174175
)
176+
} else if (configPath.getFileName.toString.endsWith(".json")) {
177+
ThirdpartyConfig.parseJson(Input.path(configPath))
175178
} else {
176179
ThirdpartyConfig.parseYaml(Input.path(configPath))
177180
}

readme.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ load("@maven//:jvm_deps.bzl", "load_jvm_deps")
120120
load_jvm_deps()
121121
```
122122

123-
### YAML
123+
### YAML or JSON
124124

125125
If you prefer to configure the dependencies in one file, create `3rdparty.yaml`
126126
at the root of monorepo instead
@@ -131,6 +131,13 @@ runt the following inside the `multiversion-example/` directory:
131131
$ multiversion export --output-path=3rdparty/jvm_deps.bzl
132132
```
133133

134+
You can also specify a different path or format for the input configuration using
135+
`--input-path`:
136+
137+
```sh
138+
$ multiversion export --input-path=config/3rdparty.json --output-path=3rdparty/jvm_deps.bzl
139+
```
140+
134141
### Pants
135142

136143
```sh

0 commit comments

Comments
 (0)