|
| 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 | + |
1 | 7 | plugins { |
2 | 8 | id 'org.gradle.playframework' |
3 | 9 | } |
@@ -93,6 +99,40 @@ tasks.withType(AbstractCopyTask).configureEach { |
93 | 99 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE |
94 | 100 | } |
95 | 101 |
|
| 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 | + |
96 | 136 | spotless { |
97 | 137 | java { |
98 | 138 | target "**/*.java" |
|
0 commit comments