Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(maven-container): work around issue with concurrent builds in mvn #647

Merged
merged 1 commit into from
Mar 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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