Import multi-project into eclipse fails

java.lang.IllegalArgumentException: Path for project must have only one segment.
	at org.eclipse.core.runtime.Assert.isLegal(Assert.java:63)
	at org.eclipse.core.internal.resources.WorkspaceRoot.getProject(WorkspaceRoot.java:147)
	at org.eclipse.buildship.core.workspace.internal.DefaultWorkspaceOperations.createProject(DefaultWorkspaceOperations.java:124)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.addNewEclipseProjectToWorkspace(SynchronizeGradleBuildOperation.java:264)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeNonWorkspaceProject(SynchronizeGradleBuildOperation.java:242)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:179)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleBuildWithWorkspace(SynchronizeGradleBuildOperation.java:142)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(SynchronizeGradleBuildOperation.java:107)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:124)
	at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
	at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:729)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2241)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5409)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5366)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:121)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.synchronizeBuild(SynchronizeGradleBuildsJob.java:78)
	at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.runToolingApiJob(SynchronizeGradleBuildsJob.java:69)
	at org.eclipse.buildship.core.util.progress.ToolingApiJob$1.run(ToolingApiJob.java:73)
	at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:63)
	at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:70)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Gradle Version: 2.14
Operating System: Windows 10
Eclipse Version: Mars.2
Buildship Version: 1.0.16

In the past I was able to move the folders temporarily to the root folder, import the project to get working .project files, then move them back to their subfolders and reimport the project. But that’s not possible anymore. The error message above appears.

Using gradle eclipse to generate eclipse files for main and for subprojects does help nothing

Here you can find my project I have problems with:

thanks for your help. Very nice project!

I think you should replace slashes with colon’s in settings.gradle. Eg:

include "microservices:authserver",
    "microservices:frontend",
    "microservices:discovery",
    "microservices:edge",
    "microservices:hystrixdashboard",
    "microservices:turbine"
1 Like

So easy… thank you!

Hm, I was too fast… Now I have another problem with the mainClassName. This was working when using slashes in the settings.gradle, but now I get:
`…\microservices4vaadin>gradlew clean build
:microservices:clean
:microservices:authserver:clean
:microservices:discovery:clean
:microservices:edge:clean
:microservices:frontend:clean
:microservices:hystrixdashboard:clean UP-TO-DATE
:microservices:turbine:clean UP-TO-DATE
:microservices:compileJava UP-TO-DATE
:microservices:processResources UP-TO-DATE
:microservices:classes UP-TO-DATE
:microservices:jar
:microservices:findMainClass
:microservices:startScripts FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem was found with the configuration of task ‘:microservices:startScripts’.

No value has been specified for property ‘mainClassName’.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED`

It seems that I have to add ‘mainClassName’ to the root project, but there is no class available.

Appreciate your help!
Karsten

You are using

subprojects {
  apply plugin: 'application'
}

even though some of your projects are not applications. For instance the microservices project is just a container project that doesn’t have any code. You need to be a little more selective. If everything below the microservices project are application, then this would work:

project(':microservices') {
  subprojects {
    apply plugin: 'application'
  }
}

Cheers,
Stefan

Okay, I understand. Thank you, this works!