Skip to content

Commit 6369b2b

Browse files
committed
Improve Gradle settings for Eclipse
1 parent ec971d5 commit 6369b2b

File tree

2 files changed

+14
-44
lines changed

2 files changed

+14
-44
lines changed

README.md

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,4 @@ Import the project as a Gradle project.
4040

4141
### Eclipse
4242

43-
To import this project into Eclipse, adhere to the instructions outlined below.
44-
45-
**1. Run the Gradle command:**
46-
47-
```sh
48-
$ ./gradlew cleanEclipse eclipse
49-
```
50-
51-
**2. Navigate through the Eclipse menu and select:**
52-
53-
```
54-
File > Import > General > Existing Projects into Workspace
55-
```
56-
57-
It is important not to choose `File > Import > Gradle > Existing Gradle Project`.
43+
Import the project as a Gradle project.

build.gradle.kts

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
plugins {
2-
id("com.diffplug.eclipse.apt") version "3.44.0" apply false
3-
id("com.diffplug.spotless") version "6.25.0" apply false
4-
id("org.domaframework.doma.compile") version "2.0.0" apply false
5-
kotlin("jvm") version "1.9.23" apply false
6-
kotlin("kapt") version "1.9.23" apply false
2+
id("com.diffplug.eclipse.apt") version "3.44.0"
3+
id("com.diffplug.spotless") version "6.25.0"
4+
id("org.domaframework.doma.compile") version "2.0.0"
75
}
86

97
subprojects {
@@ -20,18 +18,6 @@ subprojects {
2018
withType<Test> {
2119
useJUnitPlatform()
2220
}
23-
24-
named("eclipse") {
25-
doFirst {
26-
val prefs = file(".settings/org.eclipse.buildship.core.prefs")
27-
if(!prefs.exists()){
28-
prefs.appendText("""
29-
connection.project.dir=
30-
eclipse.preferences.version=1
31-
""".trimIndent())
32-
}
33-
}
34-
}
3521
}
3622

3723
repositories {
@@ -50,32 +36,30 @@ subprojects {
5036
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.10.2")
5137
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.10.2")
5238
}
53-
54-
configure<org.gradle.plugins.ide.eclipse.model.EclipseModel> {
39+
40+
eclipse {
5541
classpath {
5642
file {
5743
whenMerged {
5844
val classpath = this as org.gradle.plugins.ide.eclipse.model.Classpath
59-
classpath.entries.removeAll {
60-
when (it) {
61-
is org.gradle.plugins.ide.eclipse.model.Output -> it.path == ".apt_generated"
62-
else -> false
63-
}
45+
val folder = org.gradle.plugins.ide.eclipse.model.SourceFolder(".apt_generated", "bin/main")
46+
classpath.entries.add(folder)
47+
val dir = file(folder.path)
48+
if (!dir.exists()) {
49+
dir.mkdir()
6450
}
6551
}
66-
withXml {
67-
val node = asNode()
68-
node.appendNode("classpathentry", mapOf("kind" to "src", "output" to "bin/main", "path" to ".apt_generated"))
69-
}
7052
}
7153
}
7254
project {
7355
buildCommand("org.eclipse.buildship.core.gradleprojectbuilder")
7456
natures("org.eclipse.buildship.core.gradleprojectnature")
7557
}
58+
// Reset all Eclipse settings when "Refresh Gradle Project" is executed
59+
synchronizationTasks("cleanEclipse", "eclipse")
7660
}
7761

78-
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
62+
spotless {
7963
java {
8064
googleJavaFormat("1.12.0")
8165
}

0 commit comments

Comments
 (0)