spring-attic / eclipse-integration-gradle

Gradle Tooling for Eclipse
Eclipse Public License 1.0
298 stars 108 forks source link

Error importing projects - Build Model: InconsistenProjectHierarchyException #59

Open i23098 opened 10 years ago

i23098 commented 10 years ago

I have a project with sub-projects (https://github.com/i23098/Collections) that compiles correctly on the command-line. When I try to import the project in Eclipse I get an error and tells me to check the log... Checking it, it has:

!ENTRY org.springsource.ide.eclipse.gradle.core 4 0 2014-11-09 17:03:13.404
!MESSAGE Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
!STACK 0
java.lang.reflect.InvocationTargetException
at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:113)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: org.springsource.ide.eclipse.gradle.core.InconsistenProjectHierarchyException: Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
at org.springsource.ide.eclipse.gradle.core.util.ExceptionUtil.inconsistentProjectHierachy(ExceptionUtil.java:82)
at org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.getCachedModel(GradleModelProvider.java:339)
at org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:634)
at org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:653)
at org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:105)
... 1 more
Root exception:
org.springsource.ide.eclipse.gradle.core.InconsistenProjectHierarchyException: Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
at org.springsource.ide.eclipse.gradle.core.util.ExceptionUtil.inconsistentProjectHierachy(ExceptionUtil.java:82)
at org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.getCachedModel(GradleModelProvider.java:339)
at org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:634)
at org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:653)
at org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:105)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)

Eclipse IDE for Java EE Developers 4.4.1.20140925-1820 Gradle IDE 3.6.2.201410090835-RELEASE (configured to use gradle wrapper at http://services.gradle.org/distributions/gradle-2.1-bin.zip)

BoykoAlex commented 10 years ago

Hmm... that worked just fine for me...

Check if the Gradle eclipse integration plugins in your Plug-in Registry view are these: org.springsource.ide.eclipse.gradle.core (3.6.2.201410090835-RELEASE) org.springsource.ide.eclipse.gradle.toolingapi (3.6.2.201410090835-RELEASE) org.springsource.ide.eclipse.gradle.ui (3.6.2.201410090835-RELEASE) org.springsource.ide.eclipse.gradle.ui.taskview (3.6.2.201410090835-RELEASE)

and also check if these are the ones that become active when you attempt to import your model.

Did you upgrade to Gradle 3.6.2 or installed STS 3.6.2 and then added Gradle to fresh installation of STS?

i23098 commented 10 years ago

I have version 3.6.2.201410090835-RELEASE of the plug-ins. Looking at the installation history, I started with regular eclipse Java EE 4.4 and installed Gradle IDE 3.5.1.201404300713-RELEASE. I got eclipse updated, and Gradle IDE 3.6.0.201407080553-RELEASE, and finally 3.6.2.201410090835-RELEASE.

BoykoAlex commented 10 years ago

When you import the Gradle project into Eclipse, I assume you follow the import wizard, select Gradle Project and then find the folder on your file system where the Collections projects hierarchy is located. Once that is done you click on the "Build Model" button and then the exception occurs? Is issue occurring all the time and blocking you completely? Looking at the code it's not yet clear why that issue is occurring... at least 100% of time.. perhaps there is a race condition, but it shouldn't be happening all the time it seems.

i23098 commented 10 years ago

Yes, import gradle project, when I press build model I got an error saying to look at the log. The exception was copy-pasted from the .log file. (Edit: Yes, it happens 100% of the time)

Since it worked for you, I just started with a clean install Eclipse Luna SR1, installed gradle plugin 3.62, new workspace with new git clone... And now it works. Maybe some problem in the upgrade process?

BoykoAlex commented 10 years ago

We do get some issues on Gradle that occurred after upgrading Eclipse and Gradle eclipse plugin, but couldn’t pinpoint what exactly is going wrong… Every time it’s something different and very weird that has been tested before the release…

On Nov 10, 2014, at 15:55, i23098 notifications@github.com wrote:

Yes, import gradle project, when I press build model I got an error saying to look at the log. The exception was copy-pasted from the .log file.

Since it worked for you, I just started with a clean install Eclipse Luna SR1, installed gradle plugin 3.62, new workspace with new git clone... And now it works. Maybe some problem in the upgrade process?

— Reply to this email directly or view it on GitHub https://github.com/spring-projects/eclipse-integration-gradle/issues/59#issuecomment-62453409.

i23098 commented 10 years ago

Got it again... For some reason Gradle -> Refresh All was not working. So, I decided to remove the projects from the workspace and import them again, to see if it helps. Now, it won't import it again...

!ENTRY org.springsource.ide.eclipse.gradle.core 4 0 2014-11-15 12:25:07.941
!MESSAGE Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
!STACK 0
java.lang.reflect.InvocationTargetException
    at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:113)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: org.springsource.ide.eclipse.gradle.core.InconsistenProjectHierarchyException: Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
    at org.springsource.ide.eclipse.gradle.core.util.ExceptionUtil.inconsistentProjectHierachy(ExceptionUtil.java:82)
    at org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.getCachedModel(GradleModelProvider.java:339)
    at org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:634)
    at org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:653)
    at org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
    at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:105)
    ... 1 more
Root exception:
org.springsource.ide.eclipse.gradle.core.InconsistenProjectHierarchyException: Gradle project hierarchy is inconsistent for '/home/ralmeida/workspace-collections/Collections'
    at org.springsource.ide.eclipse.gradle.core.util.ExceptionUtil.inconsistentProjectHierachy(ExceptionUtil.java:82)
    at org.springsource.ide.eclipse.gradle.core.GradleModelProvider$GroupedModelProvider.getCachedModel(GradleModelProvider.java:339)
    at org.springsource.ide.eclipse.gradle.core.GradleProject.getGradleModel(GradleProject.java:634)
    at org.springsource.ide.eclipse.gradle.core.GradleProject.getSkeletalGradleModel(GradleProject.java:653)
    at org.springsource.ide.eclipse.gradle.ui.wizards.GradleImportWizardPageOne$11.doit(GradleImportWizardPageOne.java:516)
    at org.springsource.ide.eclipse.gradle.core.util.GradleRunnable.run(GradleRunnable.java:105)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
kdvolder commented 10 years ago

The error means that gradle tooling is having problem creating a tooling api model for a project via its root project. This happens when some stored information in the project preference area links a given project to a root project, but when building a model for the root project then it can not find the project as a descendant of the root project.

Maybe the project hierarchy changed? Or maybe there is some problem in your settings.gradle defining sub-projects for your root project.

Before importing the project try maybe deleting the settings files in the .settings/gradle folder (this is where the information is stored). I suggest you try to delete all these .settings/gradle files in all your projects and then try importing them again.

guramritpal-singh commented 9 years ago

This problem comes when the local version and project which has version.is different.

Basically every project has on task in build.gradle file called wrapper. This wraaper defines which version of gradle had been used in this project which is in gradle.properties. When you have local version diifenernce and the version defined bye gradle wrapper is different then problms come.

Advice better to use same version by looking into gradle.properites file or use the project provided gradlew command which is going to download a gradle version required by project.