Skip to content

Commit 9fd388b

Browse files
authored
Refactor the build.gradle.kts file (#1041)
* Remove `apply false` * Remove eclipse related settings * Remove deprecated Gradle features
1 parent 26642f4 commit 9fd388b

File tree

1 file changed

+15
-55
lines changed

1 file changed

+15
-55
lines changed

build.gradle.kts

Lines changed: 15 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import org.gradle.plugins.ide.eclipse.model.EclipseModel
2-
31
plugins {
4-
eclipse
52
`java-library`
63
`maven-publish`
74
signing
8-
id("com.diffplug.eclipse.apt") apply false
95
id("com.diffplug.spotless")
106
id("io.github.gradle-nexus.publish-plugin")
117
id("net.researchgate.release")
12-
id("org.domaframework.doma.compile") apply false
13-
kotlin("jvm") apply false
14-
kotlin("kapt") apply false
8+
id("org.domaframework.doma.compile")
9+
kotlin("jvm")
10+
kotlin("kapt")
1511
}
1612

1713
val Project.javaModuleName: String
@@ -66,32 +62,6 @@ fun replaceVersionInDocs(ver: String) {
6662
}
6763
}
6864

69-
fun EclipseModel.configureWithJavaRuntimeName(javaRuntimeName: String) {
70-
classpath {
71-
file {
72-
whenMerged {
73-
val classpath = this as org.gradle.plugins.ide.eclipse.model.Classpath
74-
classpath.entries.removeAll {
75-
when (it) {
76-
is org.gradle.plugins.ide.eclipse.model.Output -> it.path == ".apt_generated"
77-
else -> false
78-
}
79-
}
80-
}
81-
withXml {
82-
val node = asNode()
83-
node.appendNode(
84-
"classpathentry",
85-
mapOf("kind" to "src", "output" to "bin/main", "path" to ".apt_generated")
86-
)
87-
}
88-
}
89-
}
90-
jdt {
91-
this.javaRuntimeName = javaRuntimeName
92-
}
93-
}
94-
9565
allprojects {
9666
apply(plugin = "base")
9767
apply(plugin = "com.diffplug.spotless")
@@ -131,7 +101,6 @@ configure(modularProjects) {
131101
apply(plugin = "java-library")
132102
apply(plugin = "maven-publish")
133103
apply(plugin = "signing")
134-
apply(plugin = "com.diffplug.eclipse.apt")
135104

136105
java {
137106
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
@@ -181,10 +150,6 @@ configure(modularProjects) {
181150
isRequired = isReleaseVersion
182151
}
183152

184-
eclipse {
185-
configureWithJavaRuntimeName("JavaSE-1.8")
186-
}
187-
188153
class ModulePathArgumentProvider(it: Project) : CommandLineArgumentProvider, Named {
189154
@get:CompileClasspath
190155
val modulePath: Configuration = it.configurations["compileClasspath"]
@@ -223,7 +188,7 @@ configure(modularProjects) {
223188

224189
val javaModuleName = project.javaModuleName
225190
val moduleSourceDir = file("src/module/$javaModuleName")
226-
val moduleOutputDir = file("$buildDir/classes/java/module")
191+
val moduleOutputDir = layout.buildDirectory.dir("classes/java/module")
227192

228193
val compileModule by tasks.registering(JavaCompile::class) {
229194
dependsOn("classes")
@@ -261,7 +226,7 @@ configure(modularProjects) {
261226
manifest {
262227
attributes(mapOf("Implementation-Title" to project.name, "Implementation-Version" to archiveVersion))
263228
}
264-
from("$moduleOutputDir/$javaModuleName") {
229+
from("${moduleOutputDir.get().asFile}/$javaModuleName") {
265230
include("module-info.class")
266231
}
267232
}
@@ -304,25 +269,20 @@ configure(modularProjects) {
304269

305270
configure(integrationTestProjects) {
306271
apply(plugin = "java")
307-
apply(plugin = "com.diffplug.eclipse.apt")
308272
apply(plugin = "com.diffplug.spotless")
309273
apply(plugin ="org.domaframework.doma.compile")
310274

311275
dependencies {
312-
"testImplementation"(platform("org.testcontainers:testcontainers-bom:1.19.3"))
313-
"testRuntimeOnly"("com.h2database:h2:1.4.200")
314-
"testRuntimeOnly"("mysql:mysql-connector-java:8.0.33")
315-
"testRuntimeOnly"("com.oracle.database.jdbc:ojdbc8-production:18.15.0.0")
316-
"testRuntimeOnly"("org.postgresql:postgresql:42.7.1")
317-
"testRuntimeOnly"("com.microsoft.sqlserver:mssql-jdbc:8.4.1.jre8")
318-
"testRuntimeOnly"("org.testcontainers:mysql")
319-
"testRuntimeOnly"("org.testcontainers:oracle-xe")
320-
"testRuntimeOnly"("org.testcontainers:postgresql")
321-
"testRuntimeOnly"("org.testcontainers:mssqlserver")
322-
}
323-
324-
eclipse {
325-
configureWithJavaRuntimeName("JavaSE-17")
276+
testImplementation(platform("org.testcontainers:testcontainers-bom:1.19.3"))
277+
testRuntimeOnly("com.h2database:h2:1.4.200")
278+
testRuntimeOnly("mysql:mysql-connector-java:8.0.33")
279+
testRuntimeOnly("com.oracle.database.jdbc:ojdbc8-production:18.15.0.0")
280+
testRuntimeOnly("org.postgresql:postgresql:42.7.1")
281+
testRuntimeOnly("com.microsoft.sqlserver:mssql-jdbc:8.4.1.jre8")
282+
testRuntimeOnly("org.testcontainers:mysql")
283+
testRuntimeOnly("org.testcontainers:oracle-xe")
284+
testRuntimeOnly("org.testcontainers:postgresql")
285+
testRuntimeOnly("org.testcontainers:mssqlserver")
326286
}
327287

328288
tasks {

0 commit comments

Comments
 (0)