@@ -36,6 +36,58 @@ For example:
36
36
org.postgresql:postgresql:42.2.8
37
37
```
38
38
39
+ ### Excluding Transitive Dependencies
40
+
41
+ To exclude a transitive dependency from a Scala CLI project use the ` exclude ` parameter:
42
+
43
+ - ` exclude=org%%name ` - for Scala modules
44
+ - ` exclude=org%name ` - for Java modules
45
+
46
+ It requires passing the organization and module name of the dependency to be excluded. For example, let's say you have
47
+ the following Scala code:
48
+
49
+ ``` scala title=Main.scala
50
+ //> using dep " com.lihaoyi::pprint:0.8.1"
51
+ object Main extends App {
52
+ println(" Hello" )
53
+ }
54
+ ```
55
+
56
+ If you want to compile it with the ` pprint ` library but exclude its ` sourcecode ` dependency, you can use
57
+ the ` exclude ` parameter as follows:
58
+
59
+ ``` scala title=Main.scala
60
+ //> using dep " com.lihaoyi::pprint:0.8.1,exclude=com.lihaoyi%%sourcecode"
61
+ object Main extends App {
62
+ println(" Hello" )
63
+ }
64
+ ```
65
+
66
+ To exclude Scala modules, you can also use a single ` % ` but with the full name of the module name, like this:
67
+
68
+ ``` scala title=Main.scala
69
+ //> using dep " com.lihaoyi::pprint:0.8.1,exclude=com.lihaoyi%sourcecode_3"
70
+ object Main extends App {
71
+ println(" Hello" )
72
+ }
73
+ ```
74
+
75
+
76
+ ### Dependency classifiers
77
+
78
+ To specify a classifier of a dependency in a Scala CLI project, use the ` classifier ` parameter:
79
+
80
+ - ` classifier={classifier_name} `
81
+
82
+ If you want to use the ` pytorch ` dependency with the classifier ` linux-x86_64 ` , use the ` classifier ` parameter as follows:
83
+
84
+ ``` scala title=Main.scala
85
+ //> using dep " org.bytedeco:pytorch:1.12.1-1.5.8,classifier=linux-x86_64"
86
+ object Main extends App {
87
+ println(" Hello" )
88
+ }
89
+ ```
90
+
39
91
## Specifying dependencies from the command line
40
92
41
93
You can add dependencies on the command line, with the ` --dependency ` option:
@@ -72,49 +124,4 @@ Lastly, you can also add simple JAR files as dependencies with `--jar`:
72
124
73
125
``` bash ignore
74
126
scala-cli compile Sample.sc --jar /path/to/library.jar
75
- ```
76
-
77
- ## Updating dependencies
78
-
79
- To check if dependencies in using directives are up-to-date, use ` dependency-update ` command:
80
-
81
- ``` scala title=Hello.scala
82
- //> using dep " com.lihaoyi::os-lib:0.7.8"
83
- //> using dep " com.lihaoyi::utest:0.7.10"
84
-
85
- object Hello extends App {
86
- println(" Hello World" )
87
- }
88
- ```
89
-
90
- <ChainedSnippets >
91
-
92
- ``` bash
93
- scala-cli --power dependency-update Hello.scala
94
- ```
95
-
96
- ``` text
97
- Updates
98
- * com.lihaoyi::os-lib:0.7.8 -> 0.8.1
99
- * com.lihaoyi::utest:0.7.10 -> 0.8.0
100
- To update all dependencies run:
101
- scala-cli dependency-update --all
102
- ```
103
-
104
- </ChainedSnippets >
105
-
106
- Passing ` --all ` to the ` dependency-update ` sub-command updates all dependencies in your sources.
107
-
108
- <ChainedSnippets >
109
-
110
- ``` bash
111
- scala-cli --power dependency-update Hello.scala --all
112
- ```
113
-
114
- ``` text
115
- Updated dependency to: com.lihaoyi::os-lib:0.8.1
116
- Updated dependency to: com.lihaoyi::utest:0.8.0
117
- ```
118
-
119
- </ChainedSnippets >
120
-
127
+ ```
0 commit comments