Skip to content

Commit 0384ca2

Browse files
Fix for play gradle plugin on arm64
1 parent 7971586 commit 0384ca2

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

dd-smoke-tests/play-2.4/build.gradle

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
import datadog.gradle.plugin.HostPlatform
2+
import org.gradle.playframework.tasks.RoutesCompile
3+
import org.gradle.playframework.tasks.internal.RoutesCompileWorkAction
4+
import org.gradle.playframework.tools.internal.routes.DefaultRoutesCompileSpec
5+
import org.gradle.playframework.tools.internal.routes.RoutesCompilerFactory
6+
17
plugins {
28
id 'org.gradle.playframework'
39
}
@@ -93,6 +99,40 @@ tasks.withType(AbstractCopyTask).configureEach {
9399
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
94100
}
95101

102+
if (HostPlatform.isLinuxArm64()) {
103+
tasks.named("compilePlayRoutes", RoutesCompile) { RoutesCompile task ->
104+
// org.gradle.playframework.tasks.RoutesCompile does not expose worker fork options, but its
105+
// worker JVM needs CDS disabled on Linux arm64 like the other forked JVMs in this build.
106+
def workerExecutorField = RoutesCompile.getDeclaredField("workerExecutor")
107+
workerExecutorField.accessible = true
108+
109+
task.actions.clear()
110+
task.doLast {
111+
def spec = new DefaultRoutesCompileSpec(
112+
task.source.files,
113+
task.outputDirectory.get().asFile,
114+
task.javaProject,
115+
task.namespaceReverseRouter.get(),
116+
task.generateReverseRoutes.get(),
117+
task.injectedRoutesGenerator.get(),
118+
task.additionalImports.get(),
119+
projectDir
120+
)
121+
122+
def workerExecutor = workerExecutorField.get(task)
123+
workerExecutor.processIsolation { workerSpec ->
124+
workerSpec.forkOptions { options ->
125+
options.jvmArgs("-XX:MaxMetaspaceSize=256m", "-Xshare:off")
126+
}
127+
workerSpec.classpath.from(task.routesCompilerClasspath)
128+
}.submit(RoutesCompileWorkAction) { parameters ->
129+
parameters.compiler.set(RoutesCompilerFactory.create(task.platform.get()))
130+
parameters.spec.set(spec)
131+
}
132+
}
133+
}
134+
}
135+
96136
spotless {
97137
java {
98138
target "**/*.java"

0 commit comments

Comments
 (0)