Skip to content

Commit cbe6871

Browse files
committed
Add docs for passing local JARs and source JARs as dependencies
1 parent 30ccc28 commit cbe6871

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

website/docs/guides/dependencies.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,7 @@ Repositories can also be resolved from the `COURSIER_REPOSITORIES` environment v
6565
| ivy2local | Ivy | Local ivy repository, used to publish things locally (e.g. by `publishLocal`). Localized in `<ivy-home>/local`, usually `<user-home>/.ivy/local`. |
6666
| m2Local | Maven | Local maven repository, localized in `<user-home>/.m2/repository` |
6767

68-
Scala CLI delegates parsing of predefined repositories to Coursier and full details can be obtains from Coursier source code ([here](https://github.com/coursier/coursier/blob/2444eebcc151e0f6927e269137e8737c1f31cbe2/modules/coursier/jvm/src/main/scala/coursier/LocalRepositories.scala) and [here](https://github.com/coursier/coursier/blob/2444eebcc151e0f6927e269137e8737c1f31cbe2/modules/coursier/shared/src/main/scala/coursier/internal/SharedRepositoryParser.scala))
69-
70-
71-
72-
73-
68+
Scala CLI delegates parsing of predefined repositories to Coursier and full details can be obtained from Coursier source code ([here](https://github.com/coursier/coursier/blob/2444eebcc151e0f6927e269137e8737c1f31cbe2/modules/coursier/jvm/src/main/scala/coursier/LocalRepositories.scala) and [here](https://github.com/coursier/coursier/blob/2444eebcc151e0f6927e269137e8737c1f31cbe2/modules/coursier/shared/src/main/scala/coursier/internal/SharedRepositoryParser.scala))
7469

7570
### Excluding Transitive Dependencies
7671

@@ -152,7 +147,7 @@ You can also add a URL fallback for a JAR dependency, if it can't be fetched oth
152147

153148
```bash ignore
154149
scala-cli compile Sample.sc \
155-
-- dependency "org::name::version,url=https://url-to-the-jar"
150+
--dependency "org::name::version,url=https://url-to-the-jar"
156151
```
157152

158153
Note that `--dependency` is only meant as a convenience. You should favor adding dependencies in the sources themselves
@@ -171,4 +166,29 @@ Lastly, you can also add simple JAR files as dependencies with `--jar`:
171166

172167
```bash ignore
173168
scala-cli compile Sample.sc --jar /path/to/library.jar
174-
```
169+
```
170+
171+
## Adding local JARs as dependencies
172+
You can pass local JARs from the command line with the `--extra-jar` option:
173+
174+
```bash ignore
175+
scala-cli compile Sample.sc \
176+
--extra-jar "./path/to/custom.jar"
177+
```
178+
179+
Local sources JARs can also be passed in a similar manner:
180+
```bash ignore
181+
scala-cli compile Sample.sc \
182+
--extra-source-jar "./path/to/custom-sources.jar"
183+
```
184+
185+
Both can be handled with the appropriate `using` directives, too:
186+
187+
```scala
188+
//> using jar "./path/to/custom.jar"
189+
//> using sourceJar "./path/to/custom-sources.jar"
190+
```
191+
192+
:::caution
193+
Local JARs with the `*-sources.jar` suffix are assumed to be sources JARs and are treated as such.
194+
:::

0 commit comments

Comments
 (0)