Skip to content

Commit

Permalink
Improve Gradle settings for Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
nakamura-to committed May 18, 2024
1 parent 0549f25 commit 3d71770
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,20 @@ See [Getting started](https://doma.readthedocs.io/en/latest/getting-started/).

[![Java CI with Gradle](https://github.com/domaframework/getting-started/workflows/Java%20CI%20with%20Gradle/badge.svg)](https://github.com/domaframework/getting-started/actions?query=workflow%3A%22Java+CI+with+Gradle%22)

Notice
------
Import into your IDE
---------------------

For Eclipse users, to import this project into Eclipse, adhere to the instructions outlined below.
Import this project into your IDE as a Gradle Project.
This project has been confirmed to work on the following IDEs.

**1. Run the Gradle command:**
- Eclipse 2023-09 (4.29.0)
- IntelliJ IDEA 2023.3.4 (Community Edition)

```sh
$ ./gradlew cleanEclipse eclipse
```

**2. Navigate through the Eclipse menu and select:**
Build
-----

```
File > Import > General > Existing Projects into Workspace
```
You can build this project with Gradle.

It is important not to choose `File > Import > Gradle > Existing Gradle Project`.
```sh
$ ./gradlew build
```
30 changes: 9 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import com.diffplug.gradle.eclipse.apt.Factorypath

plugins {
java
id("com.diffplug.eclipse.apt") version "3.44.0"
Expand Down Expand Up @@ -30,18 +32,6 @@ subprojects {
named("build") {
dependsOn("spotlessApply")
}

named("eclipse") {
doFirst {
val prefs = file(".settings/org.eclipse.buildship.core.prefs")
if(!prefs.exists()){
prefs.appendText("""
connection.project.dir=
eclipse.preferences.version=1
""".trimIndent())
}
}
}
}

dependencies {
Expand All @@ -60,23 +50,21 @@ subprojects {
file {
whenMerged {
val classpath = this as org.gradle.plugins.ide.eclipse.model.Classpath
classpath.entries.removeAll {
when (it) {
is org.gradle.plugins.ide.eclipse.model.Output -> it.path == ".apt_generated"
else -> false
}
val folder = org.gradle.plugins.ide.eclipse.model.SourceFolder(".apt_generated", "bin/main")
classpath.entries.add(folder)
val dir = file(folder.path)
if (!dir.exists()) {
dir.mkdir()
}
}
withXml {
val node = asNode()
node.appendNode("classpathentry", mapOf("kind" to "src", "output" to "bin/main", "path" to ".apt_generated"))
}
}
}
project {
buildCommand("org.eclipse.buildship.core.gradleprojectbuilder")
natures("org.eclipse.buildship.core.gradleprojectnature")
}
// Reset all Eclipse settings when "Refresh Gradle Project" is executed
synchronizationTasks("cleanEclipse", "eclipse")
}

spotless {
Expand Down

0 comments on commit 3d71770

Please sign in to comment.