@@ -18,49 +18,41 @@ import org.polystat.cli.util.InputUtils.*
1818import sys .process .*
1919import PolystatConfig .*
2020import org .polystat .cli .util .FileTypes .*
21+ import coursier .`package` .{Organization , Module , ModuleName }
22+ import coursier .{Fetch , Dependency }
23+ import coursier .cache .FileCache
2124
2225object Java :
23-
2426 private def j2eoPath (using j2eoVersion : String ) = Path (
25- s " j2eo-v $ j2eoVersion.jar "
27+ s " https/repo1.maven.org/maven2/org/polystat/ j2eo/ ${j2eoVersion} /j2eo- ${ j2eoVersion} .jar "
2628 )
2729 val DEFAULT_J2EO_VERSION = BuildInfo .j2eoVersion
28- private def j2eoUrl (using j2eoVesion : String ) =
29- s " https://search.maven.org/remotecontent?filepath=org/polystat/j2eo/ $j2eoVesion /j2eo- $j2eoVesion .jar "
30+ private def j2eoUrl (using j2eoVersion : String ) =
31+ s " https://search.maven.org/remotecontent?filepath=org/polystat/j2eo/ $j2eoVersion /j2eo- $j2eoVersion .jar "
3032
31- private def defaultJ2EO (using j2eoVesion : String ): IO [Path ] =
33+ private def defaultJ2EO (using j2eoVersion : String ): IO [Path ] =
3234 Files [IO ]
3335 .exists(j2eoPath)
3436 .ifM(
3537 ifTrue = IO .pure(j2eoPath),
3638 ifFalse = downloadJ2EO,
3739 )
3840
39- private def downloadJ2EO (using j2eoVesion : String ): IO [Path ] =
40- EmberClientBuilder
41- .default[IO ]
42- .build
43- .map(client => FollowRedirect (2 , _ => true )(client))
44- .use[Unit ] { client =>
45- client
46- .run(
47- Request [IO ](
48- GET ,
49- uri = Uri .unsafeFromString(j2eoUrl),
50- )
51- )
52- .use(resp =>
53- IO .println(
54- s " $j2eoPath was not found in the current working directory. Downloading... "
55- ) *>
56- resp.body
57- .through(Files [IO ].writeAll(j2eoPath))
58- .compile
59- .drain
41+ private def downloadJ2EO (using j2eoVersion : String ): IO [Path ] =
42+ val localCache = FileCache ().withLocation(java.io.File (" ." ))
43+ IO .delay(
44+ Fetch (localCache)
45+ .addDependencies(
46+ Dependency (
47+ Module (
48+ organization = Organization (" org.polystat" ),
49+ name = ModuleName (" j2eo" ),
50+ ),
51+ version = j2eoVersion,
6052 )
61- }
62- .as(j2eoPath )
63- end downloadJ2EO
53+ )
54+ .run( )
55+ ).as(j2eoPath)
6456
6557 private def runJ2EO (
6658 j2eoVersion : Option [String ],
0 commit comments