1
1
package build .project .publish
2
- import $ivy .`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
3
- import $ivy .`org.eclipse.jgit:org.eclipse.jgit:6.8.0.202311291450-r`
2
+
4
3
import build .project .settings
5
4
import com .lumidion .sonatype .central .client .core .{PublishingType , SonatypeCredentials }
6
5
import settings .{PublishLocalNoFluff , workspaceDirName }
7
- import de .tobiasroeser .mill .vcs .version ._
8
- import mill ._
6
+ import mill .*
9
7
import mill .javalib .publish .Artifact
10
- import scalalib ._
8
+ import mill .util .{Tasks , VcsVersion }
9
+ import scalalib .*
11
10
import org .eclipse .jgit .api .Git
11
+ import mill .api .{BuildCtx , ModuleCtx , Task }
12
12
13
13
import java .nio .charset .Charset
14
- import scala .concurrent .duration ._
15
- import scala .jdk .CollectionConverters ._
14
+ import scala .concurrent .duration .*
15
+ import scala .jdk .CollectionConverters .*
16
16
17
- lazy val (ghOrg : String , ghName : String ) = {
17
+ def gh : (ghOrg : String , ghName : String ) = {
18
18
def default = (" VirtusLab" , " scala-cli" )
19
19
val isCI = System .getenv(" CI" ) != null
20
20
if (isCI) {
@@ -62,7 +62,9 @@ lazy val (ghOrg: String, ghName: String) = {
62
62
default
63
63
}
64
64
65
- private def computePublishVersion (state : VcsState , simple : Boolean ): String =
65
+ lazy val (ghOrg : String , ghName : String ) = gh
66
+
67
+ private def computePublishVersion (state : VcsVersion .State , simple : Boolean ): String =
66
68
if (state.commitsSinceLastTag > 0 )
67
69
if (simple) {
68
70
val versionOrEmpty = state.lastTag
@@ -141,15 +143,18 @@ trait ScalaCliPublishModule extends SonatypeCentralPublishModule with PublishLoc
141
143
)
142
144
override def publishVersion : T [String ] = finalPublishVersion()
143
145
override def sourceJar : T [PathRef ] = Task {
144
- import mill .util .Jvm .createJar
145
- val allSources0 = allSources().map(_.path).filter(os.exists).toSet
146
- createJar(
147
- allSources0 ++ resources().map(_.path).filter(os.exists),
148
- manifest(),
149
- (input, relPath) =>
150
- ! allSources0(input) ||
151
- (! relPath.segments.contains(" .scala" ) && ! relPath.segments.contains(workspaceDirName))
152
- )
146
+ PathRef {
147
+ import mill .util .Jvm .createJar
148
+ val allSources0 = allSources().map(_.path).filter(os.exists)
149
+ createJar(
150
+ jar = Task .dest / " out.jar" ,
151
+ inputPaths = allSources0 ++ resources().map(_.path).filter(os.exists),
152
+ manifest = manifest(),
153
+ fileFilter = (input, relPath) =>
154
+ ! allSources0.toSet(input) ||
155
+ (! relPath.segments.contains(" .scala" ) && ! relPath.segments.contains(workspaceDirName))
156
+ )
157
+ }
153
158
}
154
159
}
155
160
@@ -211,7 +216,7 @@ def publishSonatype(
211
216
publisher.publishAll(
212
217
publishingType = publishingType,
213
218
singleBundleName = finalBundleName,
214
- artifacts = artifacts : _ *
219
+ artifacts = artifacts*
215
220
)
216
221
}
217
222
@@ -235,7 +240,7 @@ def setShouldPublish() = Task.Command {
235
240
val charSet = Charset .defaultCharset()
236
241
val nl = System .lineSeparator()
237
242
os.write.append(
238
- os.Path (envFile, Task .workspace ),
243
+ os.Path (envFile, BuildCtx .workspaceRoot ),
239
244
s " SHOULD_PUBLISH= ${shouldPublish()}$nl" .getBytes(charSet)
240
245
)
241
246
}
0 commit comments