@@ -34,23 +34,31 @@ trait ScalaCliCompile extends ScalaModule {
34
34
new FallbackRefreshDisplay
35
35
)
36
36
val cache = FileCache ().withLogger(logger)
37
+ val artifact = Artifact (url).withChanging(compileScalaCliIsChanging)
37
38
val archiveCache = ArchiveCache ()
38
39
.withCache(cache)
39
- val artifact = Artifact (url).withChanging(compileScalaCliIsChanging)
40
- val file = archiveCache.get(artifact).unsafeRun()(cache.ec) match {
41
- case Left (e) => throw new Exception (e)
42
- case Right (f) =>
43
- if (Properties .isWin)
44
- os.list(os.Path (f, os.pwd)).filter(_.last.endsWith(" .exe" )).headOption match {
45
- case None => sys.error(s " No .exe found under $f" )
46
- case Some (exe) => exe
40
+ if (compileScalaCliIsCompressed)
41
+ archiveCache.get(artifact).unsafeRun()(cache.ec) match {
42
+ case Left (e) => throw new Exception (e)
43
+ case Right (f) =>
44
+ if (Properties .isWin)
45
+ os.list(os.Path (f, os.pwd)).filter(_.last.endsWith(" .exe" )).headOption match {
46
+ case None => sys.error(s " No .exe found under $f" )
47
+ case Some (exe) => exe
48
+ }
49
+ else {
50
+ f.setExecutable(true )
51
+ os.Path (f, os.pwd)
47
52
}
48
- else {
49
- f.setExecutable(true )
53
+ }
54
+ else
55
+ cache.file(artifact).run.unsafeRun()(cache.ec) match {
56
+ case Left (e) => throw new Exception (e)
57
+ case Right (f) =>
58
+ if (! Properties .isWin)
59
+ f.setExecutable(true )
50
60
os.Path (f, os.pwd)
51
- }
52
- }
53
- PathRef (file)
61
+ }
54
62
}
55
63
}
56
64
import ScalaCliInternal ._
@@ -74,8 +82,15 @@ trait ScalaCliCompile extends ScalaModule {
74
82
else None
75
83
}
76
84
def compileScalaCliIsChanging : Boolean = false
85
+ def compileScalaCliIsCompressed : Boolean =
86
+ compileScalaCliUrl.exists(url => url.endsWith(" .gz" ) || url.endsWith(" .zip" ))
77
87
78
- def compileScalaCli : Option [PathRef ] = compileScalaCliImpl
88
+ def compileScalaCli : Option [os.Path ] = compileScalaCliImpl
89
+
90
+ def extraScalaCliHeadOptions : T [List [String ]] =
91
+ T {
92
+ List .empty[String ]
93
+ }
79
94
80
95
def extraScalaCliOptions : T [List [String ]] =
81
96
T {
@@ -84,7 +99,7 @@ trait ScalaCliCompile extends ScalaModule {
84
99
85
100
override def compile : T [CompilationResult ] =
86
101
if (enableScalaCli)
87
- compileScalaCli.map(_.path) match {
102
+ compileScalaCli match {
88
103
case None => super .compile
89
104
case Some (cli) =>
90
105
T .persistent {
@@ -103,6 +118,7 @@ trait ScalaCliCompile extends ScalaModule {
103
118
104
119
val proc = os.proc(
105
120
cli,
121
+ extraScalaCliHeadOptions(),
106
122
Seq (" compile" , " --classpath" ),
107
123
Seq (" -S" , scalaVersion()),
108
124
asOpt(" -O" , scalacOptions()),
0 commit comments