File tree Expand file tree Collapse file tree 2 files changed +44
-1
lines changed
test/scala/scala/build/tests Expand file tree Collapse file tree 2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,16 @@ object CrossSources {
382382 crossSources -> finalInputs
383383 }
384384
385+ extension (uri : java.net.URI )
386+ def asString : String =
387+ java.net.URI (
388+ uri.getScheme,
389+ uri.getAuthority,
390+ uri.getPath,
391+ null ,
392+ uri.getFragment
393+ ).toString
394+
385395 /** @return
386396 * the resource directories that should be added to the classpath
387397 */
@@ -405,7 +415,7 @@ object CrossSources {
405415 download(pUri.value.toString).left.map(
406416 new UsingFileFromUriError (pUri.value, pUri.positions, _)
407417 ).map(content =>
408- Seq (Virtual (pUri.value.toString , content))
418+ Seq (Virtual (pUri.value.asString , content))
409419 )
410420
411421 type CodeFile = os.Path | java.net.URI
Original file line number Diff line number Diff line change @@ -125,6 +125,39 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite {
125125 }
126126 }
127127
128+ test(" dependencies in .scala - using URL with query parameters" ) {
129+ val testInputs = TestInputs (
130+ os.rel / " something.scala" ->
131+ """ | //> using file http://github.com/VirtusLab/scala-cli/blob/main/modules/dummy/amm/src/main/scala/AmmDummy.scala?version=3
132+ |
133+ |object Main {
134+ |}
135+ |""" .stripMargin
136+ )
137+ testInputs.withInputs { (root, inputs) =>
138+ val (crossSources, _) =
139+ CrossSources .forInputs(
140+ inputs,
141+ preprocessors,
142+ TestLogger (),
143+ SuppressWarningOptions (),
144+ download = _ => Right (Array .empty[Byte ])
145+ ).orThrow
146+ val scopedSources = crossSources.scopedSources(BuildOptions ()).orThrow
147+ val sources =
148+ scopedSources.sources(
149+ Scope .Main ,
150+ crossSources.sharedOptions(BuildOptions ()),
151+ root,
152+ TestLogger ()
153+ ).orThrow
154+
155+ expect(sources.paths.length == 1 )
156+ expect(sources.inMemory.length == 1 )
157+ expect(sources.inMemory(0 ).generatedRelPath.last == " AmmDummy.scala" )
158+ }
159+ }
160+
128161 test(" dependencies in .test.scala - using" ) {
129162 val testInputs = TestInputs (
130163 os.rel / " something.test.scala" ->
You can’t perform that action at this time.
0 commit comments