Skip to content

Commit 909ecaa

Browse files
committed
j2eo jar naming is more descriptive
1 parent bcf632b commit 909ecaa

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ project/project/
77
.metals/
88
tmp/
99
polystat_out/
10-
j2eo.jar
10+
j2eo*.jar
1111
sarif/**
1212
polystat-x86_64-pc-linux
1313
out/
1414
**.json
15-
hadoop_tmp
15+
hadoop_tmp

src/main/scala/org/polystat/cli/Java.scala

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,26 @@ import org.http4s.implicits.*
1616
import sys.process.*
1717
import PolystatConfig.*
1818
import InputUtils.*
19+
import org.polystat.cli.BuildInfo
1920

2021
object Java:
2122

22-
private val DEFAULT_J2EO_PATH = Path("j2eo.jar")
23-
val DEFAULT_J2EO_VERSION = "0.5.0"
24-
private def j2eoUrl(j2eoVesion: String) =
23+
private def j2eoPath(using j2eoVersion: String) = Path(
24+
s"j2eo-v$j2eoVersion.jar"
25+
)
26+
val DEFAULT_J2EO_VERSION = BuildInfo.j2eoVersion
27+
private def j2eoUrl(using j2eoVesion: String) =
2528
s"https://search.maven.org/remotecontent?filepath=org/polystat/j2eo/$j2eoVesion/j2eo-$j2eoVesion.jar"
2629

27-
private def defaultJ2EO(j2eoVesion: String): IO[Path] =
30+
private def defaultJ2EO(using j2eoVesion: String): IO[Path] =
2831
Files[IO]
29-
.exists(DEFAULT_J2EO_PATH)
32+
.exists(j2eoPath)
3033
.ifM(
31-
ifTrue = IO.pure(DEFAULT_J2EO_PATH),
32-
ifFalse = downloadJ2EO(j2eoVesion),
34+
ifTrue = IO.pure(j2eoPath),
35+
ifFalse = downloadJ2EO,
3336
)
3437

35-
private def downloadJ2EO(j2eoVesion: String): IO[Path] =
38+
private def downloadJ2EO(using j2eoVesion: String): IO[Path] =
3639
EmberClientBuilder
3740
.default[IO]
3841
.build
@@ -42,20 +45,20 @@ object Java:
4245
.run(
4346
Request[IO](
4447
GET,
45-
uri = Uri.unsafeFromString(j2eoUrl(j2eoVesion)),
48+
uri = Uri.unsafeFromString(j2eoUrl),
4649
)
4750
)
4851
.use(resp =>
4952
IO.println(
50-
"j2eo.jar was not found in the current working directory. Downloading..."
53+
s"$j2eoPath was not found in the current working directory. Downloading..."
5154
) *>
5255
resp.body
53-
.through(Files[IO].writeAll(DEFAULT_J2EO_PATH))
56+
.through(Files[IO].writeAll(j2eoPath))
5457
.compile
5558
.drain
5659
)
5760
}
58-
.as(DEFAULT_J2EO_PATH)
61+
.as(j2eoPath)
5962
end downloadJ2EO
6063

6164
private def runJ2EO(
@@ -64,12 +67,15 @@ object Java:
6467
inputDir: Path,
6568
outputDir: Path,
6669
): IO[Unit] =
70+
given inferredJ2eoVersion: String =
71+
j2eoVersion.getOrElse(DEFAULT_J2EO_VERSION)
72+
val inferredJ2eoPath = j2eo.getOrElse(j2eoPath)
6773
val command =
68-
s"java -jar ${j2eo.getOrElse(DEFAULT_J2EO_PATH)} -o $outputDir $inputDir"
74+
s"java -jar ${inferredJ2eoPath} -o $outputDir $inputDir"
6975
for
7076
j2eo <- j2eo
7177
.map(IO.pure)
72-
.getOrElse(defaultJ2EO(j2eoVersion.getOrElse(DEFAULT_J2EO_VERSION)))
78+
.getOrElse(defaultJ2EO)
7379
_ <- Files[IO]
7480
.exists(j2eo)
7581
.ifM(

0 commit comments

Comments
 (0)