Tips for settings to be added to build.grade when generating an eclipse project using gradle. For myself. These settings can be set from the IDE after creating an eclipse project file with gradle, but it is troublesome to do each time, so I wanted to put it in build.gradle.
If you create an eclipse project with a specific module (specifically DynamoDBLocal) set as a dependency of gradle, .so and .dll will be included in the classpath, so the eclipse project will fail. In this case, exclude the path from the file generated as follows.
eclipse.classpath.file {
whenMerged { classpath ->
classpath.entries.removeAll { entry -> (entry.path.endsWith('dll') || entry.path.endsWith('so') || entry.path.endsWith('dylib')) }
}
}
Certain packages (specifically javafx and javax.smartcardio) are hidden from eclipse by default and result in an error. In this case, add it to the JRE access rule as follows.
eclipse.classpath.file {
whenMerged {
def jre_container = entries.find { it.path.contains 'org.eclipse.jdt.launching.JRE_CONTAINER' }
jre_container.accessRules << new org.gradle.plugins.ide.eclipse.model.AccessRule("accessible", "javax/smartcardio/**")
}
}
Certain Project Nature (specifically gradle and STS Gradle plugins) is not set by default. In this case, add project nature as follows
eclipse.project {
buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
natures 'org.eclipse.buildship.core.gradleprojectnature'
}
Also, in the case of Buildship, an error will occur if there is no pref file under .settings, so create the file as follows.
tasks.eclipse.doFirst {
File prefs = file(".settings/org.eclipse.buildship.core.prefs")
if(!prefs.exists()){
prefs.append('''
connection.project.dir=
eclipse.preferences.version=1
'''.stripIndent())
}
}
Note that these settings seem to work well if you already have various configuration files.
gradle cleanEclipse eclipse
It seems better to clean the eclipse project file once.
Referenced entry:
Recommended Posts