Eclipse Buildship Plugin: nesting source folders - eclipse

I'm using Gradle Buildship plugin in order to build my Eclipse projects.
Gradle itselft is well configured. So, I'm able to build anything from shell.
The gradle project has a root folder and other subprojects.
When I click on Gradle -> Refresh Project it tells me:
Synchronize Gradle builds with workspace failed due to an unexpected error.
Cannot nest 'living_webapi/src/main/java/com/living/persistence/entities' inside 'living_webapi/src/main/java'. To enable the nesting exclude 'com/' from 'living_webapi/src/main/java'
Java Model Exception: Java Model Status [Cannot nest 'living_webapi/src/main/java/com/living/persistence/entities' inside 'living_webapi/src/main/java'. To enable the nesting exclude 'com/' from 'living_webapi/src/main/java']
at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:786)
at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3097)
at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3059)
at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3112)
at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.updateClasspath(SourceFolderUpdater.java:234)
at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.updateClasspath(SourceFolderUpdater.java:82)
at org.eclipse.buildship.core.workspace.internal.SourceFolderUpdater.update(SourceFolderUpdater.java:261)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeOpenJavaProject(SynchronizeGradleBuildOperation.java:223)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeOpenWorkspaceProject(SynchronizeGradleBuildOperation.java:213)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeWorkspaceProject(SynchronizeGradleBuildOperation.java:186)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:176)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleBuildWithWorkspace(SynchronizeGradleBuildOperation.java:141)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access$000(SynchronizeGradleBuildOperation.java:106)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.run(SynchronizeGradleBuildOperation.java:123)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:724)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5521)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5478)
at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:120)
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:62)
at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:70)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

The only thing that worked for me was un-checking the "Allow output folders for source folders" option.
Steps:
Right click on project -> Properties
Click on Java Build Path in the left side of Properties popup
Click on Source tab
Un-check the "Allow output folders for source folders" checkbox
Click Apply and Close
Right click on project -> Gradle -> Refresh Gradle Project

I got this problem too.
My solution is setting project properties.
In Java build Path -> Source,set output folder to default.
For more detail,the image below.
Project Properties -> Java build path -> Source
Source folder output location

Related

Gradle Eclipse getting compile issues

In my build.gradle file I have a dependency that is wrong
compile('org.springframework.boot:spring-boot-starter234')
When I do
gradle build
I get:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter234:.
Required by:
project :
However in Eclipse when I run the task, I don't get a clear message. I just get:
Note: I have Refresh the Gradle Project and get the same message
I assume you use mavenCentral or jcenter as a repository. Neither of them has an artifact with groupId org.springframework.boot and artifactId spring-boot-starter234 in your build script with the following line:
compile('org.springframework.boot:spring-boot-starter234')
Therefore, gradle does not find it. One possible correct dependency for spring-boot-starter could be:
compile('org.springframework.boot:spring-boot-starter:2.0.2.RELEASE')
or pick another version that matches your project better from the Maven Repository.
You can right-click on the failed task (or ctrl-click on the Mac) and choose "Show Failures".
Or you can click on the little console icon (in the upper right corner of your screenshot) with the tooltip "Navigate to Console for this Execution"

Eclipse Maven errors when I'm only using Gradle

I began to get errors after downloading Nodeclipse and creating a Gradle project with New Gradle Project -- sample project "Java Quickstart". Whenever I re-open Eclipse, I get this error:
"Updating Maven Dependencies" has encountered a problem. An internal
error occurred during: "Updating Maven Dependencies".
org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob$1
I have never used Maven, but I tried to investigate the error. When I try to open Preferences > Maven, or most (but not all) of its subfolders, I get:
Unable to create the selected preference page. An error occurred while
automatically activating bundle org.eclipse.m2e.core.ui (545).
I looked on Maven Central and there is no m2e folder in org/eclipse. I also looked in Eclipse/features for pom.xml files and I have folders starting with org.eclipse.m2e, but no org.eclipse.m2e.core.ui.
Edit:
I created a new workspace and got the same error message as soon as I created a New Gradle Project based on Java Quickstart sample project. I did this twice and the second time Eclipse logged an error. Some relevant lines from the stack trace:
Exception:org.osgi.framework.BundleException: Exception in org.eclipse.m2e.core.internal.MavenPluginActivator.start() of bundle org.eclipse.m2e.core
Exception:java.lang.NoClassDefFoundError: org/eclipse/m2e/core/internal/project/registry/ProjectRegistryRefreshJob$1
at org.springsource.ide.eclipse.gradle.core.wizards.NewGradleProjectOperation.createProjectContents(NewGradleProjectOperation.java:106)
First try to build your project from command line.
Enide 2015 by Nodeclipse has built-in Terminal Ctrl+Alt+T
run gradle build
or right-click build.gradle Run as -> gradle build
Then see and think
You are building with Gradle, so don't look at Maven preferences, but Gradle one.
Possibly you confused Gradle and Maven and made wrong preferences, you can try again in new workspace.

Update my gradle dependencies in eclipse

I have a simple gradle project in my eclipse. I update the build.gradle to include a few apache http jars...
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile 'org.apache.httpcomponents:httpclient:4.2.3'
compile "org.apache.httpcomponents:httpmime:4.2.3"
testCompile group: 'junit', name: 'junit', version: '4.+'
}
However in my code, where I reference some Apache HTTP stuff I get:
The import org.apache.http cannot be resolved
Any tips on what I need to do to make Eclipse see the new dependencies in my build.gradle?
I tried doing a clean but that does not work. My gradle plugin is:
Gradle IDE 3.3.0.201307040643-RELEASE org.springsource.ide.eclipse.gradle.feature.feature.group GoPivotal, Inc.
You have to select "Refresh Dependencies" in the "Gradle" context menu that appears when you right-click the project in the Package Explorer.
Follow those steps to update Gradle project in Eclipse:
First, please check you have include eclipse gradle plugin. apply plugin : 'eclipse'
Then go to your project directory in Terminal. Type gradle clean and then gradle eclipse.
Then go to project in eclipse and refresh the project (Go to Project Explorer, select root of the project and hit F5 to refresh, or right click and select refresh in context menu).
Looking at the Eclipse plugin docs I found some useful tasks that rebuilt my classpath and updated the required dependencies.
First try gradle cleanEclipse to clean the Eclipse configuration completely. If this doesn;t work you may try more specific tasks:
gradle cleanEclipseProject to remove the .project file
gradle cleanEclipseClasspath to empty the project's classpath
Finally gradle eclipse to rebuild the Eclipse configuration
You have to make sure that "Dependency Management" is enabled. To do so, right click on the project name, go to the "Gradle" sub-menu and click on "Enable Dependency Management". Once you do that, Gradle should load all the dependencies for you.
I tried all above options but was still getting error, in my case issue was I have not setup gradle installation directory in eclipse, following worked:
eclipse -> Window -> Preferences -> Gradle -> "Select Local
Installation Directory"
Click on Browse button and provide path.
Even though question is answered, thought to share in case somebody else is facing similar issue.
Cheers !
In my case, I solved weird issues in Spring Tools Suite (essentially Eclipse) after I tried to upgrade Spring Boot and the changes didn't seem to be taking effect.
Right click on your project -> Gradle -> Refresh Gradle Project

Access configuration resources in Scala IDE

Some of my colleagues use Eclipse 3.7.2 and Scala IDE 2.1 for development. I want to use typesafe's config module for applicaton configuration. I want to use the convention based default configuration location. According to the examples and documentation, the default config can be found at the following path relative to project root
/src/main/resources/application.conf
But when I run my project using Scala IDE's Scala Application loader, the SimpleConfig type is unable to load any configuration values set in this file. An alternative is to pass in a config-file system property via sbt, but I don't want to have to explicitly set this path somewhere. Can anyone point out what I'm doing wrong?
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.foo.dataservices.MyServer.main(MyServer.scala)
Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'bar'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:115)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:138)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:150)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:155)
at com.typesafe.config.impl.SimpleConfig.getConfigNumber(SimpleConfig.java:170)
at com.typesafe.config.impl.SimpleConfig.getInt(SimpleConfig.java:181)
You need to add your resources folder to your java build path:
Right Click on your project in the Project Explorer
properties -> click Java Build Path -> select "Source" tab
click "Add Folder..." and add your src/main/resources folder
update: if you are using the sbt eclipse plugin you can configure it to automatically add the resources folder to the classpath :
(from: sbteclipse docs)
EclipseKeys.createSrc := EclipseCreateSrc.Default + EclipseCreateSrc.Resource

GWT: Eclipse giving "Unable to find module" error when I try and run web app

I'm using Eclipse Indigo, Maven 3.0.3, and GWT 2.4. I have imported my Maven project into Eclipse and enabled GWT support. However, bafflingly, when I right click on my projecdt and select "Run As" -> "Web Application", I get the error in the Console pane ...
Loading modules com.myco.clearing.commons.xml.ProductPlusJUnit
[ERROR] Unable to find 'com/myco/clearing/commons/xml/ProductPlusJUnit.gwt.xml' on your
classpath; could be a typo, or maybe you forgot to include a classpath
entry for source?
[ERROR] shell failed in doStartup method
The bizarre thing is, I have no file com/myco/clearing/commons/xml/ProductPlusJUnit.gwt.xml. The closest thing I have is a file at src/main/java/com/myco/clearing/product/ProductPlusJUnit.gwt.xml. Where is Eclipse getting this and how I can I tell it to launch the correct entry point module (which is src/main/java/com/clearing/product/ProductPlus.gwt.xml)?
Right click on 'java' folder in 'src/main/java' and select 'Build Path' --> 'Use as source folder'. Eclipse should then detect module and build project automatically.