我有一个包含4个模块和一个公共模块的项目,应该将其添加到每个jar文件中。但是,它是在父模块的build.sbt中配置的
lazy val root = (project in file("."))
.aggregate(P1, Commons, P2, P3, P4)
lazy val Commons = (project in file("commons"))
lazy val P1 = (project in file("p1"))
.dependsOn(Commons)
DOCKERFILE:
FROM amazonlinux:2018.03 as build
ARG SCALA_VERSION
ARG SBT_VERSION
ARG JAVA_VERSION
RUN yum install -y java-${JAVA_VERSION}-openjdk-devel
RUN yum install -y https://downloads.lightbend.com/scala/${SCALA_VERSION}/scala-${SCALA_VERSION}.rpm
RUN yum install -y https://dl.bintray.com/sbt/rpm/sbt-${SBT_VERSION}.rpm
WORKDIR root/P1
ADD ./project/plugins.sbt project/
ADD ./project/build.properties project/
ADD build.sbt .
RUN sbt update
COPY . .
RUN sbt clean assembly
RUN cp target/scala-2.12/P1-assembly-1.0-SNAPSHOT.jar P1.jar
FROM openjdk:8-jre-alpine
COPY --from=build \
root/P1/P1.jar .
ENTRYPOINT ["java", "-jar", "/P1.jar"]
但是,当我为P1,P2,P3,P4中的每一个创建dockerfile时,它不包括添加的Commons。我应该怎么做?我应该在每个项目的build.sbt文件中更改任何内容吗?
答案 0 :(得分:1)
您可以尝试将“ aggregate”替换为“ dependsOn”吗? 聚合意味着您正在运行的任务也将在聚合项目上运行,这不是您期望的。
edit:“聚合”对于在每个子模块上运行测试很有用,例如在根项目上运行“ sbt干净测试”