add support for publish doc jar, add dockerBuild task

This commit is contained in:
A.C.Sukazyo Eyre 2024-08-09 00:30:06 +08:00
parent 7cf06a539c
commit 7e668bd974
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
4 changed files with 35 additions and 4 deletions

View File

@ -8,7 +8,7 @@ ARG DOCKER_BUILD=yes
RUN cd ./source \ RUN cd ./source \
&& sbt assembly \ && sbt assembly \
&& cd .. \ && cd .. \
&& cp ./source/target/morny-coeur-docker-build.jar ./morny-coeur.jar && cp ./source/morny-coeur/target/morny-coeur-docker-build.jar ./morny-coeur.jar
#&& rm -r ./source \ #&& rm -r ./source \
#&& rm -r /root/.gradle \ #&& rm -r /root/.gradle \

View File

@ -13,7 +13,10 @@ ThisBuild / resolvers ++= Seq(
ThisBuild / crossPaths := false ThisBuild / crossPaths := false
ThisBuild / Compile / packageDoc / publishArtifact := false if (!MornyProject.publishWithDocJar) {
(ThisBuild / packageDoc / publishArtifact := false) :: Nil
} else Nil
artifactName := {(sv: ScalaVersion, module: ModuleID, artifact: Artifact) => artifactName := {(sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
val classifier = artifact.classifier match { val classifier = artifact.classifier match {
case Some(value) => s"-$value" case Some(value) => s"-$value"
@ -50,6 +53,7 @@ ThisBuild / apiMappings ++= {
ThisBuild / publishTo := MornyProject.publishTo ThisBuild / publishTo := MornyProject.publishTo
ThisBuild / credentials ++= MornyProject.publishCredentials ThisBuild / credentials ++= MornyProject.publishCredentials
lazy val morny_system_lib = (project in file (MornyProject.morny_system_lib.id)) lazy val morny_system_lib = (project in file (MornyProject.morny_system_lib.id))
.settings( .settings(
@ -110,6 +114,10 @@ lazy val morny_coeur = (project in file(MornyProject.morny_coeur.id))
) )
lazy val dockerImageName: SettingKey[String] = settingKey[String]("Docker image name that want to built")
lazy val dockerImageTag: SettingKey[String] = settingKey[String]("Docker image tag or aka image version of the built image")
lazy val dockerBuild: TaskKey[Unit] = taskKey("Build using system docker with current version as the container tag")
lazy val root = (project in file (".")) lazy val root = (project in file ("."))
.aggregate(morny_system_lib, morny_coeur) .aggregate(morny_system_lib, morny_coeur)
.settings( .settings(
@ -126,6 +134,24 @@ lazy val root = (project in file ("."))
run / aggregate := false, run / aggregate := false,
run := { run := {
(morny_coeur / Compile / run).evaluated (morny_coeur / Compile / run).evaluated
},
dockerImageName := MornyProject.docker_image_name,
dockerImageTag := version.value,
dockerBuild := {
val builtImageName = dockerImageName.value
val builtImageTag = (ThisProject / dockerImageTag).value
sLog.value info s"Building docker image with name $builtImageName:$builtImageTag"
import scala.language.postfixOps
import scala.sys.process.*
s"docker build -t $builtImageName:$builtImageTag ."!
sLog.value info s"Built docker image $builtImageName:$builtImageTag"
} }
) )

View File

@ -6,15 +6,17 @@ object MornyConfiguration {
val MORNY_CODE_STORE = "https://github.com/Eyre-S/Coeur-Morny-Cono" val MORNY_CODE_STORE = "https://github.com/Eyre-S/Coeur-Morny-Cono"
val MORNY_COMMIT_PATH = "https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s" val MORNY_COMMIT_PATH = "https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s"
val VERSION = "2.0.0-alpha20" val VERSION = "2.0.0-alpha21"
val VERSION_DELTA: Option[String] = None val VERSION_DELTA: Option[String] = None
val CODENAME = "xinzheng" val CODENAME = "xinzheng"
val SNAPSHOT = false val SNAPSHOT = true
val GROUP = "cc.sukazyo" val GROUP = "cc.sukazyo"
val GROUP_NAME = "A.C. Sukazyo Eyre" val GROUP_NAME = "A.C. Sukazyo Eyre"
val DOCKER_IMAGE_NAME = "coeur-morny-cono"
trait ProjectMetadata { trait ProjectMetadata {
val name: String val name: String

View File

@ -44,7 +44,10 @@ object MornyProject {
val group = MornyConfiguration.GROUP val group = MornyConfiguration.GROUP
val group_name = MornyConfiguration.GROUP_NAME val group_name = MornyConfiguration.GROUP_NAME
val docker_image_name = MornyConfiguration.DOCKER_IMAGE_NAME
val publishWithFatJar = !version_is_snapshot val publishWithFatJar = !version_is_snapshot
val publishWithDocJar = !version_is_snapshot
def publishTo = MornyConfiguration.publishTo def publishTo = MornyConfiguration.publishTo
val publishCredentials = MornyConfiguration.publishCredentials val publishCredentials = MornyConfiguration.publishCredentials