-
Notifications
You must be signed in to change notification settings - Fork 613
/
Copy pathrelease.mill
157 lines (129 loc) · 5.27 KB
/
release.mill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
package build
import mill._
import mill.scalalib._
import mill.scalalib.scalafmt._
import mill.scalalib.publish._
import mill.api.Result
import mill.scalalib.api.ZincWorkerUtil.matchingVersions
import mill.util.Jvm.createJar
import $ivy.`io.chris-kipp::mill-ci-release_mill0.12:0.2.1` // https://github.com/ckipp01/mill-ci-release/pull/143
import io.kipp.mill.ci.release.{CiReleaseModule, SonatypeHost}
import de.tobiasroeser.mill.vcs.version.VcsVersion // pulled in by mill-ci-release
import build._
trait ChiselPublishModule extends CiReleaseModule {
// Publish information
def pomSettings = PomSettings(
description = artifactName(),
organization = "org.chipsalliance",
url = "https://www.chisel-lang.org",
licenses = Seq(License.`Apache-2.0`),
versionControl = VersionControl.github("chipsalliance", "chisel"),
developers = Seq(
Developer("jackkoenig", "Jack Koenig", "https://github.com/jackkoenig"),
Developer("azidar", "Adam Izraelevitz", "https://github.com/azidar"),
Developer("seldridge", "Schuyler Eldridge", "https://github.com/seldridge")
)
)
override def sonatypeHost = Some(SonatypeHost.s01)
override def publishVersion = VcsVersion
.vcsState()
.format(
countSep = "+",
revHashDigits = 8,
untaggedSuffix = "-SNAPSHOT"
)
}
/** Aggregate project for publishing Chisel as a single artifact
*/
trait Unipublish extends ScalaModule with ChiselPublishModule {
def scalaVersion = v.scalaVersion
// This is published as chisel
override def artifactName = "chisel"
/** Publish both this project and the plugin (for the default Scala version) */
override def publishLocal(localIvyRepo: String = null) = Task.Command {
// TODO consider making this parallel and publishing all cross-versions for plugin
plugin.cross(v.scalaVersion).publishLocal(localIvyRepo)()
super.publishLocal(localIvyRepo)()
}
// Explicitly not using moduleDeps because that influences so many things
def components = Seq(firrtl.cross, svsim.cross, macros.cross, core.cross, chisel).map(_(v.scalaVersion))
/** Aggregated ivy deps to include as dependencies in POM */
def ivyDeps = Task { Task.traverse(components)(_.ivyDeps)().flatten }
/** Aggregated local classpath to include in jar */
override def localClasspath = Task { Task.traverse(components)(_.localClasspath)().flatten }
/** Aggreagted sources from all component modules */
def aggregatedSources = Task { Task.traverse(components)(_.allSources)().flatten }
/** Aggreagted resources from all component modules */
def aggregatedResources = Task { Task.traverse(components)(_.resources)().flatten }
/** Aggreagted compile resources from all component modules */
def aggregatedCompileResources = Task { Task.traverse(components)(_.compileResources)().flatten }
/** Aggregated sourceJar from all component modules
*/
override def sourceJar: T[PathRef] = Task {
// This is based on the implementation of sourceJar in PublishModule, may need to be kept in sync.
val allDirs = aggregatedSources() ++ aggregatedResources() ++ aggregatedCompileResources()
createJar(allDirs.map(_.path).filter(os.exists), manifest())
}
// Needed for ScalaDoc
override def scalacOptions = v.scala2CommonOptions
def scalaDocRootDoc = Task.Source { Task.workspace / "root-doc.txt" }
def unidocOptions = Task {
scalacOptions() ++ Seq[String](
"-classpath",
unidocCompileClasspath().map(_.path).mkString(sys.props("path.separator")),
"-diagrams",
"-groups",
"-skip-packages",
"chisel3.internal",
"-diagrams-max-classes",
"25",
"-doc-version",
publishVersion(),
"-doc-title",
"chisel",
"-doc-root-content",
scalaDocRootDoc().path.toString,
"-sourcepath",
Task.workspace.toString,
"-doc-source-url",
unidocSourceUrl(),
"-language:implicitConversions",
"-implicits"
)
}
// Built-in UnidocModule is insufficient so we need to implement it ourselves
// We could factor this out into a utility
def unidocSourceUrl: T[String] = Task {
val base = "https://github.com/chipsalliance/chisel/tree"
val branch = if (publishVersion().endsWith("-SNAPSHOT")) "main" else s"v${publishVersion()}"
s"$base/$branch/€{FILE_PATH_EXT}#L€{FILE_LINE}"
}
def unidocVersion: T[Option[String]] = None
def unidocCompileClasspath = Task {
Seq(compile().classes) ++ Task.traverse(components)(_.compileClasspath)().flatten
}
def unidocSourceFiles = Task {
allSourceFiles() ++ Task.traverse(components)(_.allSourceFiles)().flatten
}
// Based on UnidocModule and docJar in Mill, may need to be kept in sync.
override def docJar = Task {
Task.log.info(s"Building unidoc for ${unidocSourceFiles().length} files")
val javadocDir = Task.dest / "javadoc"
os.makeDir(javadocDir)
val fullOptions = unidocOptions() ++
Seq("-d", javadocDir.toString) ++
unidocSourceFiles().map(_.path.toString)
zincWorker()
.worker()
.docJar(
scalaVersion(),
scalaOrganization(),
scalaDocClasspath(),
scalacPluginClasspath(),
fullOptions
) match {
case true => Result.Success(createJar(Agg(javadocDir))(Task.dest))
case false => Result.Failure("docJar generation failed")
}
}
}