The import x.x.x cannot be resolved with Maven

Viewed 168

I have a project that exports a package for another project to import and utilize. Within Eclipse, it seems to resolve correctly. But when building with Maven, I get the following errors: The import x.x.x cannot be resolved. I've fiddled around with the manifest/ pom.xml and restarted Eclipse several times and the results are the same.

The general structure is:

com.my.company.plugin
- com.my.company.pkg 

And within that manifest.mf, I have Export-Package: com.my.company.pkg

For the other plugin's manifest, I have Require-Bundle: com.my.company.pkg;resolution:=optional (I've tried taking the option portion out, but that didn't seem to matter)

And within the source for the second plugin, I have:

import com.my.company.pkg.MyClass

public class MyOtherClass implements MyClass {

Locally in Eclipse it all works fine. But when I try to build with Maven, I get the following error:

[ERROR]     import com.my.company.pkg.MyClass;
[ERROR]            ^^^^^^^^^^^^^^^^^^
[ERROR] The import com.my.company.pkg cannot be resolved

[ERROR]     public class MyOtherClass implements MyClass {
[ERROR]                                          ^^^^^^^
[ERROR] MyClass cannot be resolved to a type

The strange thing is that I have other imports within MyOtherClass that reference other plugins and added in the Required-Bundles. I'm guessing it's how I'm exporting the first plugin. What exactly am I missing?

---EDIT---

It seems like adding this block in the parent pom is causing it to fail. Which is odd because I thought it by setting it to ignore it will completely ignore the optional dependencies instead of trying to resolve it? While taking it out causes other areas that uses optional dependencies to fail...

<dependency-resolution>
    <optionalDependencies>ignore</optionalDependencies>
    <extraRequirements>
        <requirement>
            <type>eclipse-plugin</type>
            <id>org.eclipse.ui</id>
            <versionRange>0.0.0</versionRange>
        </requirement>
        <requirement>
            <type>eclipse-plugin</type>
            <id>org.eclipse.ui.views</id>
            <versionRange>0.0.0</versionRange>
        </requirement>
    </extraRequirements>
</dependency-resolution>
0 Answers
Related