File tree Expand file tree Collapse file tree 2 files changed +74
-1
lines changed
cli/src/main/scala/scala/cli/commands/publish
integration/src/test/scala/scala/cli/integration Expand file tree Collapse file tree 2 files changed +74
-1
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,10 @@ object RepoParams {
179
179
}
180
180
181
181
def ivy2Local (ivy2HomeOpt : Option [os.Path ]) = {
182
- val home = ivy2HomeOpt.getOrElse(os.home / " .ivy2" )
182
+ val home = ivy2HomeOpt
183
+ .orElse(sys.props.get(" ivy.home" ).map(prop => os.Path (prop)))
184
+ .orElse(sys.props.get(" user.home" ).map(prop => os.Path (prop) / " .ivy2" ))
185
+ .getOrElse(os.home / " .ivy2" )
183
186
val base = home / " local"
184
187
// not really a Maven repo…
185
188
RepoParams (
Original file line number Diff line number Diff line change @@ -145,4 +145,74 @@ abstract class PublishLocalTestDefinitions(val scalaVersionOpt: Option[String])
145
145
}
146
146
}
147
147
148
+ test(" publish local with ivy.home" ) {
149
+ PublishTestInputs .inputs().fromRoot { root =>
150
+ def publishLocal (): os.CommandResult =
151
+ os.proc(
152
+ TestUtil .cli,
153
+ " --power" ,
154
+ " publish" ,
155
+ " local" ,
156
+ " ." ,
157
+ " --working-dir" ,
158
+ os.rel / " work-dir" ,
159
+ extraOptions
160
+ )
161
+ .call(
162
+ cwd = root,
163
+ env = Map (
164
+ " JAVA_OPTS" -> s " -Divy.home= ${root / " ivyhome" } -Duser.home ${root / " userhome" }"
165
+ ) // ivy.home takes precedence
166
+ )
167
+
168
+ def output (): String =
169
+ os.proc(
170
+ TestUtil .cs,
171
+ s " -J-Divy.home= ${root / " ivyhome" }" ,
172
+ " launch" ,
173
+ s " ${PublishTestInputs .testOrg}: ${PublishTestInputs .testName}_ $testedPublishedScalaVersion: $testPublishVersion"
174
+ )
175
+ .call(cwd = root)
176
+ .out.trim()
177
+
178
+ publishLocal()
179
+ expect(output() == " Hello" )
180
+ }
181
+ }
182
+
183
+ test(" publish local with user.home" ) {
184
+ PublishTestInputs .inputs().fromRoot { root =>
185
+ def publishLocal (): os.CommandResult =
186
+ os.proc(
187
+ TestUtil .cli,
188
+ " --power" ,
189
+ " publish" ,
190
+ " local" ,
191
+ " ." ,
192
+ " --working-dir" ,
193
+ os.rel / " work-dir" ,
194
+ extraOptions
195
+ )
196
+ .call(
197
+ cwd = root,
198
+ env = Map (
199
+ " JAVA_OPTS" -> s " -Duser.home= ${root / " userhome" }"
200
+ )
201
+ )
202
+
203
+ def output (): String =
204
+ os.proc(
205
+ TestUtil .cs,
206
+ s " -J-Divy.home= ${root / " userhome" / " .ivy2" }" ,
207
+ " launch" ,
208
+ s " ${PublishTestInputs .testOrg}: ${PublishTestInputs .testName}_ $testedPublishedScalaVersion: $testPublishVersion"
209
+ )
210
+ .call(cwd = root)
211
+ .out.trim()
212
+
213
+ publishLocal()
214
+ expect(output() == " Hello" )
215
+ }
216
+ }
217
+
148
218
}
You can’t perform that action at this time.
0 commit comments