Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2e-users] Configuring build path access restrictions in POM

Hello m2e-users,

I have a standard Maven project in Eclipse.

The project uses the "" class
in test cases to provide a mocked service to test against.

This causes a warning in Eclipse:

Access restriction: The type 'HttpServer' is not API 
(restriction on required library '/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/lib/rt.jar')

This class is not in the usual JDK "java.*" or "javax.*" packages,
but neither is it in the generally-discouraged "sun.*" or other internal
namespaces.  And since it is only in tests, I would like to just suppress
the warning and use the class.

This is relatively easy to do from the Eclipse UI -- you go to your Build Path
and add an access rule saying that "com/sun/**" should be accessible.

Unfortunately, the next time M2E updates its configuration due to POM changes,
this fix is lost.

There's some people on StackOverflow with a workaround:
but the workaround is to use an Ant task to run find/replace on the generated files.
As you can imagine I'm not really thrilled with that.

Is there a better way?  If not, would this be easy to add?

Thanks for your thoughts,
Steven Schlansker

Back to the top