Main Tutorials

Gradle : Add Eclipse project nature

Eclipse project natures are configured in the .project file. For example :

.project

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>hello</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.springsource.ide.eclipse.gradle.core.nature</nature>
		<nature>org.eclipse.jdt.core.javanature</nature>
	</natures>
</projectDescription>

To add a nature, just modify the nature tag, and add whatever nature you want.

In Gradle, you can add the Eclipse project nature like this :

build.gradle

apply plugin: 'java'
apply plugin: 'eclipse'

version = '1.0'
sourceCompatibility = 1.7
targetCompatibility = 1.7

//Make this project as a Gradle project
eclipse.project {
  	natures 'org.springsource.ide.eclipse.gradle.core.nature'
}

References

  1. Gradle – EclipseProject – DSL Reference

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Tchegito
7 years ago

Thanks for this tip !

Just a remark : if you’re using Buildship instead of Gradle STS, you should replace by this nature in your .project:
org.eclipse.buildship.core.gradleprojectnature

Tchegito