Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle project in eclipse builds fine but java files show compilation error

This is my first gradle project. I am using Buildship eclipse plugin for gradle. In my build.gradle file, I have below plugins applied -

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'

All the relevant dependencies are defined as compile as below -

.
.
compile ("org.hibernate:hibernate-entitymanager:${hibernateVer}")
compile ("org.hibernate:hibernate-core:${hibernateVer}")
compile ("org.hibernate:hibernate-validator:${hibernateValVer}")

compile ("org.slf4j:slf4j-api:${slf4jVer}")
compile ("org.slf4j:slf4j-log4j12:${slf4jVer}")
.
.

The project builds and runs successfully using tomcatRun command as well. But the eclipse is showing compilation errors on my imports in java files, saying that the dependencies can not be resolved.

I tried Project->Clean and then refresh, but still stuck. What can i do to remove these compilation errors? Thanks in advance.

like image 223
Deepesh verma Avatar asked Mar 10 '16 05:03

Deepesh verma


People also ask

Does Eclipse work with Gradle?

Buildship is an Eclipse plugin that allows you to build applications and libraries using Gradle through your IDE.

Is Gradle compatible with Java 11?

The minimum version of Gradle that supports Java 11 is 5.0 . You would need to upgrade to version 7.0 or above for Android.

Does Gradle compile Java?

This chapter explains how to build a java project using Gradle build file. First of all, we have to add java plugin to the build script, because, it provides the tasks to compile Java source code, to run the unit tests, to create a Javadoc and to create a JAR file.


1 Answers

Right click on your Project-> Goto Gradle-> Refresh Gradle Project. Eclipse would pick the jars downloaded by gradle now.

like image 128
Shanu Gupta Avatar answered Sep 29 '22 13:09

Shanu Gupta