Reputation: 75
After migrating a minecraft plugin project of mine to a new workstation, the project builds (with buildship in Eclipse) but the IDE is telling me nearly every import in my projects source files can't be resolved. How do I get my project to recognize the imports?
Not sure if its relevant, but the original workstation/IDE was Eclipse Oxygen.3a release (4.7.3a) running on OSX 10.13.6. My new workstation is on Windows 10 and uses the Eclipse 2018-12 (4.10.0) IDE. I have checked several stackoverflow posts for a solution to no avail, although I suspect it has something to do with the gradle configuration for my project?
Two possible complications are: - I import a shadowjar as a dependency which presumably exists in the same directory - I import some external dependencies including junit-jupyter and the spongepowered.org api
Here's my build.gradle file
apply plugin: 'java'
apply plugin: 'maven'
group = 'net.kevinmendoza.sedimentarysequences'
version = '0.0.1-SNAPSHOT'
description = 'Sedimentary Sequences'
sourceCompatibility = 1.8
targetCompatibility = 1.8
test {
useJUnitPlatform()
}
repositories {
mavenCentral()
maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
}
dependencies {
compile 'org.spongepowered:spongeapi:5.0.0'
compile project(':GeoWorldLibrary')
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
}
and the settings.gradle file
rootProject.name = 'SedimentarySequences'
include ':GeoWorldLibrary'
project(':GeoWorldLibrary').projectDir = new
File(settingsDir,'../GeoWorldLibrary')
When I right click my project and click gradle>refresh dependencies, the console reports a "CONFIGURE SUCCESSFUL in 0s", however the opened project in the IDE is still riddled with import errors which should be accessible from the above imports.
So, how do I go about fixing this stackoverflow?
Edit: the two types of imports not resolved errors:
the import net.<myname>.<myownprojecwhichisadependency>.mypackage.classfile cannot be resolved
the import org.spongepowered could not be resolved
Upvotes: 1
Views: 1690
Reputation: 21
This problem seems to be recurrent with Eclipse and I am one struggling with it. I am not experienced in the internals of eclipse/gradle/maven but the answer to 1 seems to be right because I had imported my gradle project by using the specific gradle importing option and got the problem everytime I added dependencies to build.gradle. This time I deleted the project and imported it as a generic eclipse project by using "File -> Open Project from file system" and the importing resolution problems seem to have subsided.
I hope I am helping and not just adding to the confusion.
Upvotes: 0
Reputation: 124
I'm not sure if this fixes your problem, but this often works for me:
Add apply plugin: 'eclipse'
to your build.gradle file and then execute command gradlew cleanEclipse eclipse
in cmd.
Upvotes: 0