generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bundle fixes and Morphir Mill Build extensions (#660)
* Refine how we can lookup and index on many Distributions * Add additional methods around making Distributions and getting Libs * Add ErrorReason type * Upgrade to mill 0.11.10 * Setting up MorphirModule mill task to help use mill to support dependencies * Fix typo * Improve mill support for MorphirElmModules * produce artifacts with dist * Refining how we define MorphirModules in mill * Change package name for morphir plugin from starting with millbuild * Formatted build files * Adding additional projects for build * Adding additional projects for morphir-elm style build * Trigger make in other modules as a result of making a dependent module * Get dependencies working for morphir example projects * Working to make runtime tests auto build morphir models * Ensure MorphirElmModules are built before test is run * Install morphir-elm * Use setup-node
- Loading branch information
1 parent
9af9508
commit 44b8b95
Showing
24 changed files
with
859 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.11.11 | ||
0.11.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.10.0 | ||
lts/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package millbuild.jsruntime | ||
|
||
import mill._ | ||
import mill.define.Segment | ||
import mill.scalalib._ | ||
|
||
trait JsModule extends Module { | ||
def artifactName: Target[String] = T(millSourcePath.last) | ||
def segments = T(millModuleSegments.value.collect { case Segment.Label(s) => s }) | ||
def jsRunnerExecutable = T(PathRef(os.Path(JsRuntime.NodeJs.executable))) | ||
def jsPackageManagerRunner: Target[String] = T("npx") | ||
def jsPackageManagerCmd: Target[String] = T("npm") | ||
|
||
/** | ||
* The folders containing all source files fed into the compiler | ||
*/ | ||
def allSources: T[Seq[PathRef]] = T(sources() ++ generatedSources()) | ||
|
||
/** | ||
* Folders containing source files that are generated rather than hand-written; these files can be generated in this | ||
* target itself, or can refer to files generated from other targets | ||
*/ | ||
def generatedSources: T[Seq[PathRef]] = T(Seq.empty[PathRef]) | ||
def sources = T.sources(millSourcePath / "src") | ||
|
||
/** | ||
* All individual source files fed into the compiler/tooling. | ||
*/ | ||
def allSourceFiles: T[Seq[PathRef]] = T { | ||
Lib.findSourceFiles(allSources(), Seq("js", "ts")).map(PathRef(_)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package millbuild.jsruntime | ||
import scala.util.Properties.isWin | ||
import mill.api._ | ||
import mill.util.Jvm | ||
|
||
import os.SubProcess | ||
|
||
trait JsRuntime { | ||
import JsRuntime._ | ||
def toolName: String | ||
|
||
def findTool(name: String): String = | ||
whereIs(name) | ||
|
||
def executable: String = | ||
findTool(toolName) | ||
|
||
def runSubprocess(entryPoint: String, args: Seq[String], envArgs: Map[String, String], workingDir: os.Path)(implicit | ||
ctx: Ctx | ||
): Unit = { | ||
val commandArgs = Vector(executable) ++ args | ||
println(s"CommandArgs: $commandArgs") | ||
val process: SubProcess = Jvm.spawnSubprocessWithBackgroundOutputs( | ||
commandArgs, | ||
envArgs, | ||
workingDir, | ||
backgroundOutputs = None | ||
) | ||
println(s"Createds process: ${process}") | ||
|
||
val shutdownHook = new Thread("subprocess-shutdown") { | ||
override def run(): Unit = { | ||
System.err.println(s"Host executable for $toolName shutdown. Forcefully destroying subprocess ...") | ||
process.destroy() | ||
} | ||
} | ||
Runtime.getRuntime().addShutdownHook(shutdownHook) | ||
try | ||
process.waitFor() | ||
catch { | ||
case e: InterruptedException => | ||
System.err.println("Interrupted. Forcefully destroying subprocess ...") | ||
process.destroy() | ||
// rethrow | ||
throw e | ||
} finally | ||
Runtime.getRuntime().removeShutdownHook(shutdownHook) | ||
if (process.exitCode() == 0) () | ||
else throw new Exception("Interactive Subprocess Failed (exit code " + process.exitCode() + ")") | ||
|
||
} | ||
} | ||
|
||
object JsRuntime { | ||
case object NodeJs extends JsRuntime { | ||
def toolName: String = "node" | ||
} | ||
|
||
def whereIs(name: String) = { | ||
val commandArgs = | ||
if (isWin) { | ||
Vector("where", name) | ||
} else { | ||
Vector("whereis", name) | ||
} | ||
|
||
val result = os.proc(commandArgs).call() | ||
|
||
val location = | ||
if (isWin) { | ||
result.out.lines().headOption.flatMap(_.trim().split(" ").headOption) | ||
} else { | ||
|
||
result.out.lines().headOption.flatMap { line => | ||
val parts = line.trim().split(" ") | ||
parts match { | ||
case Array(_, loc, _*) => Some(loc) | ||
case _ => None | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
location match { | ||
case None => throw new Exception(s"Failed to locate tool: $name") | ||
case Some(loc) => loc | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package millbuild.util | ||
import scala.util.Properties.isWin | ||
|
||
object ProcessHelper { | ||
def whereIs(name: String) = { | ||
val commandArgs = | ||
if (isWin) { | ||
Vector("where", name) | ||
} else { | ||
Vector("whereis", name) | ||
} | ||
|
||
val result = os.proc(commandArgs).call() | ||
|
||
val location = | ||
if (isWin) { | ||
result.out.lines().headOption.flatMap(_.trim().split(" ").headOption) | ||
} else { | ||
|
||
result.out.lines().headOption.flatMap { line => | ||
val parts = line.trim().split(" ") | ||
parts match { | ||
case Array(_, loc, _*) => Some(loc) | ||
case _ => None | ||
} | ||
} | ||
} | ||
|
||
location match { | ||
case None => throw new Exception(s"Failed to locate tool: $name") | ||
case Some(loc) => loc | ||
} | ||
} | ||
} | ||
|
||
object Collections { | ||
implicit class SeqOps[+A](private val self: Seq[A]) extends AnyVal { | ||
def appendIf[A1 >: A](cond: Boolean)(items: A1*) = if (cond) self ++ items else self | ||
def appendWhen[A1 >: A](cond: => Boolean)(items: A1*) = if (cond) self ++ items else self | ||
|
||
def when[A1 >: A](cond: Boolean)(items: A1*) = if (cond) items else Seq.empty[A1] | ||
} | ||
} |
Oops, something went wrong.