Skip to content

Commit fb1c8ab

Browse files
NicoPielmgaffigan
andcommitted
Add Gradle build that delegates to existing Ant build
Adds a top-level Gradle build that imports the existing Ant build to enable a gradual migration to Gradle while still using Ant for current tasks. Configures Ant to run JUnit (including ant-junit4) and exposes select Gradle properties to Ant; renames conflicting Ant targets to avoid collisions and makes the Gradle build task delegate to the Ant build target. Also adds placeholder Gradle files for subprojects and bumps the configured Gradle SDK version. Co-authored-by: Mitch Gaffigan <mitch.gaffigan@comcast.net> Signed-off-by: Nico Piel <nico.piel@hotmail.de>
1 parent ff41b5e commit fb1c8ab

File tree

8 files changed

+295
-225
lines changed

8 files changed

+295
-225
lines changed

.sdkmanrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Add key=value pairs of SDKs to use below
33
java=17.0.17.fx-zulu
44
ant=1.10.14
5-
gradle=9.2.0
5+
gradle=9.2.1

build.gradle.kts

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,71 @@
1-
ant.importBuild("server/mirth-build.xml")
1+
/*
2+
* Root build file
3+
*
4+
* For more detailed information on multi-project builds, please refer to
5+
* https://docs.gradle.org/8.14.3/userguide/multi_project_builds.html
6+
*/
7+
8+
// Configure Ant to have access to JUnit task
9+
10+
ant.lifecycleLogLevel = AntBuilder.AntMessagePriority.INFO
11+
12+
configurations {
13+
create("antJUnit")
14+
}
15+
16+
dependencies {
17+
// ant-junit4 is required for JUnit 4 annotation support (@Test, etc.)
18+
"antJUnit"("org.apache.ant:ant-junit:1.10.15") {
19+
exclude(group = "junit", module = "junit")
20+
}
21+
"antJUnit"("org.apache.ant:ant-junit4:1.10.15") {
22+
exclude(group = "junit", module = "junit")
23+
}
24+
}
25+
26+
repositories {
27+
mavenCentral()
28+
}
29+
30+
// Make JUnit available to Ant
31+
afterEvaluate {
32+
ant.withGroovyBuilder {
33+
"taskdef"(
34+
"name" to "junit",
35+
"classname" to "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask",
36+
"classpath" to configurations["antJUnit"].asPath
37+
)
38+
"taskdef"(
39+
"name" to "junitreport",
40+
"classname" to "org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator",
41+
"classpath" to configurations["antJUnit"].asPath
42+
)
43+
}
44+
}
45+
46+
// Pass Gradle properties to Ant
47+
project.findProperty("disableSigning")?.let {
48+
ant.properties["disableSigning"] = it.toString()
49+
}
50+
51+
project.findProperty("disableTests")?.let {
52+
ant.properties["disableTests"] = it.toString()
53+
}
54+
55+
// Import existing Ant build for gradual migration
56+
ant.importBuild("server/mirth-build.xml") { antTargetName ->
57+
// Rename conflicting Ant targets to avoid collision with Gradle built-in tasks
58+
when (antTargetName) {
59+
"init" -> "ant-init"
60+
"build" -> "ant-build"
61+
62+
else -> antTargetName
63+
}
64+
}
65+
66+
// Make the default Gradle build task delegate to Ant's build target
67+
tasks.register("build") {
68+
dependsOn("ant-build")
69+
group = "build"
70+
description = "Builds the project using Ant (delegated)"
71+
}

client/.classpath

Lines changed: 218 additions & 218 deletions
Large diffs are not rendered by default.

client/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ant.importBuild("ant-build.xml")
1+
// ant.importBuild("ant-build.xml")

command/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ant.importBuild("build.xml")
1+
// ant.importBuild("build.xml")

donkey/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ant.importBuild("build.xml")
1+
// ant.importBuild("build.xml")

generator/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ant.importBuild("build.xml")
1+
// ant.importBuild("build.xml")

server/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ant.importBuild("build.xml")
1+
// ant.importBuild("build.xml")

0 commit comments

Comments
 (0)