Skip to content

Commit

Permalink
fix(maven-container): work around issue with concurrent builds in mvn
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald authored and eysi09 committed Mar 18, 2019
1 parent 871a138 commit 4bd9b8b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions garden-service/src/plugins/maven-container/maven-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ import { providerConfigBaseSchema } from "../../config/project"
import { openJdks } from "./openjdk"
import { maven } from "./maven"
import { LogEntry } from "../../logger/log-entry"
import AsyncLock = require("async-lock")

const defaultDockerfilePath = resolve(STATIC_DIR, "maven-container", "Dockerfile")
const buildLock = new AsyncLock()

interface MavenContainerModuleSpec extends ContainerModuleSpec {
jarPath: string
Expand Down Expand Up @@ -152,13 +154,17 @@ async function build(params: BuildModuleParams<MavenContainerModule>) {
]
const mvnCmdStr = "mvn " + mvnArgs.join(" ")

await maven.exec({
args: mvnArgs,
cwd: ctx.projectRoot,
log,
env: {
JAVA_HOME: openJdkPath,
},
// Maven has issues when running concurrent processes, so we're working around that with a lock.
// TODO: http://takari.io/book/30-team-maven.html would be a more robust solution.
await buildLock.acquire("mvn", async () => {
await maven.exec({
args: mvnArgs,
cwd: ctx.projectRoot,
log,
env: {
JAVA_HOME: openJdkPath,
},
})
})

// Copy the artifact to the module build directory
Expand Down

0 comments on commit 4bd9b8b

Please sign in to comment.