1

I've done this many times. But for some reason now, no matter what I try, running maven install with Eclipse refuses to find an imported project.

/C:/Users/Tarrant/Desktop/Attributes/src/main/java/me/warren1001/attributes/Attributes.java:[10,31] package me.warren1001.configapi does not exist

This is up until line 22 of the mentioned Attributes.java file.

package me.warren1001.attributes;

import java.util.Arrays;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import me.warren1001.configapi.Config;

public class Attributes {

    private Main plugin;

    private Config config;

    public Attributes(Main plugin) {
        this.plugin = plugin;
        config = new Config(plugin, "attributes.yml");
    }
    ...
}

Obviously, it is unable to initialize the Config variable, which is the plugin I'm importing through Build Path -> Import Jar (using workspace).

You can clearly see it is imported in my project.

and here's the package for the ConfigAPI project...

package me.warren1001.configapi;

And here's an image of Eclipse's Project Explorer... showing everything is right with the world (apparently not)

Seems like I'm missing something insanely obvious and when someone points it out I'm going to feel stupid, but I've been trying to fix this for the past 3 hours now with no avail. Any assistance?

Balwinder Singh
  • 2,196
  • 5
  • 20
  • 32

1 Answers1

1

Don't add jars through Eclipse's "Build Path > Import Jar" for a Maven project. This will add the jar to the .classpath file that Eclipse uses, but Maven does not.

The correct way is to install your Maven project containing Config and add it as a dependency in the POM. Alternately, upload your ConfigAPI library to a centralized repository if you have one.

Make sure your dependent project has the "Resolve dependencies from Workspace projects" enabled in your project's properties.

If your dependency's POM coordinates (<groupId>, <artifactId> and <version>) match up with your POM's, the M2Eclipse-plugin will automatically link the dependency for you, without having to install the dependency. However, you will eventually need to do this anyway if you have separate release cycles.

If everything is ok, you should see ConfigAPI-1.2.0.jar being listed under the "Maven Dependencies" instead of under your project in your Project Explorer at it was shown in your screenshot.

Daniel
  • 3,572
  • 4
  • 24
  • 31