Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345681 - Import OSGi bundle results in wrong compiler compliance level
Summary: Import OSGi bundle results in wrong compiler compliance level
Status: RESOLVED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: m2e (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-12 23:41 EDT by honnix CLA
Modified: 2021-04-19 13:24 EDT (History)
1 user (show)

See Also:


Attachments
the standalone project to reproduce the problem (3.64 KB, application/octet-stream)
2011-05-12 23:48 EDT, honnix CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description honnix CLA 2011-05-12 23:41:38 EDT
Use maven-pax-plugin to generate OSGi project as well as OSGi bundle.

When importing an OSGi bundle using m2eclipse, following line is always generated in .classpath:

<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>

event I've configured maven-compiler-plugin as following:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>

Guess the reason is that packaing is "bundle" not normal "jar".

Please check attachment project.

Reproduce steps:

1. Follow http://www.sonatype.com/books/mcookbook/reference/index.html 1.2 and 1.5 to create an OSGi project and a bundle.
2. Add configuration for maven-compiler-plugin in parent pom.xml
3. Load all maven modules using m2eclipse
4. Check .classpath file of project org.sonatype.mcookbook

Following output could be observed in Eclipse console:

Could not determine source level, using default 1.4
Could not determine target level, using default 1.4

If I change packaging to "jar" instead of "bundle", everything is fine, JDK-1.6 will be used.
Comment 1 Igor Fedorenko CLA 2011-05-12 23:44:53 EDT
Please attach complete standalone project we can use to reproduce the problem.
Comment 2 honnix CLA 2011-05-12 23:48:05 EDT
Created attachment 195557 [details]
the standalone project to reproduce the problem
Comment 3 honnix CLA 2011-05-12 23:48:53 EDT
(In reply to comment #1)
> Please attach complete standalone project we can use to reproduce the problem.

Sorry, I forgot to attach it.
Comment 4 Igor Fedorenko CLA 2011-05-13 00:09:40 EDT
Attached project does not use maven-compiler-plugin, so changing maven-compiler-plugin has no effect on project configuration. Please see osgi-project/poms/pom.xml for information how to configure the project to use maven-compiler-plugin.

As a side note, I am surprised you were able to import the project in recent m2e 0.13.0 without obvious error markers to explain the problem. In my case the project did not have java configuration after import and there were two error markers on pom.xml file saying that org.ops4j:maven-pax-plugin:1.5:compile and org.ops4j:maven-pax-plugin:1.5:testCompile goals are not "covered". Are you sure you use m2e 0.13.0?
Comment 5 honnix CLA 2011-05-13 00:58:12 EDT
(In reply to comment #4)
> Attached project does not use maven-compiler-plugin, so changing
> maven-compiler-plugin has no effect on project configuration. Please see
> osgi-project/poms/pom.xml for information how to configure the project to use
> maven-compiler-plugin.
> 
> As a side note, I am surprised you were able to import the project in recent
> m2e 0.13.0 without obvious error markers to explain the problem. In my case the
> project did not have java configuration after import and there were two error
> markers on pom.xml file saying that org.ops4j:maven-pax-plugin:1.5:compile and
> org.ops4j:maven-pax-plugin:1.5:testCompile goals are not "covered". Are you
> sure you use m2e 0.13.0?

Yes, you're right about the error markers. I didn't meeting this problem when using 0.13.0, but it is strange that the first time I imported projects there was no this error, but second time, I met this error marker.

I'm not quite clear what "does not use maven-compiler-plugin" means as this plugin will be used when running "mvn compile", and projects does not depend on it of course. And if I change "bundle" to "jar", it just works.
Comment 6 honnix CLA 2011-05-13 01:02:21 EDT
(In reply to comment #5)
> (In reply to comment #4)
> > Attached project does not use maven-compiler-plugin, so changing
> > maven-compiler-plugin has no effect on project configuration. Please see
> > osgi-project/poms/pom.xml for information how to configure the project to use
> > maven-compiler-plugin.
> > 
> > As a side note, I am surprised you were able to import the project in recent
> > m2e 0.13.0 without obvious error markers to explain the problem. In my case the
> > project did not have java configuration after import and there were two error
> > markers on pom.xml file saying that org.ops4j:maven-pax-plugin:1.5:compile and
> > org.ops4j:maven-pax-plugin:1.5:testCompile goals are not "covered". Are you
> > sure you use m2e 0.13.0?
> 
> Yes, you're right about the error markers. I didn't meeting this problem when
> using 0.13.0, but it is strange that the first time I imported projects there
> was no this error, but second time, I met this error marker.
> 
> I'm not quite clear what "does not use maven-compiler-plugin" means as this
> plugin will be used when running "mvn compile", and projects does not depend on
> it of course. And if I change "bundle" to "jar", it just works.

Sorry, a few typos.

I mean I did meet error marker problem, but first time no error, second time, got the problem.
Comment 7 honnix CLA 2011-05-17 19:46:27 EDT
Sorry but this is really annoying. Do you think this is still an invalid bug? If so, how can I tell m2 to load bundle module correctly?
Comment 8 Igor Fedorenko CLA 2011-05-17 22:04:02 EDT
There are two separate issues here.

First, the attached project does NOT use maven-compiler-plugin, so changing maven-compiler-plugin configuration has no effect neither inside m2e nor during command line build.

Second, the compiler the project does use, i.e. maven-pax-plugin, is not supported by m2e core and there is no thirdparty m2e extension that provides such support.

The easiest short-term solution is to modify osgi-project/poms/pom.xml file and move <extensions> from maven-pax-plugin to maven-bundle-plugin as explained in the comment in the pom.xml file.

Longer term solution requires developing m2e support for maven-pax-plugin. m2e team does not have immediate plans to do this, but we will be happy to review and apply a quality patch. If anyone is interested, please raise your hand on m2e-dev list and we'll help with pointers to get started.
Comment 9 honnix CLA 2011-05-18 02:08:26 EDT
(In reply to comment #8)
> There are two separate issues here.
> 
> First, the attached project does NOT use maven-compiler-plugin, so changing
> maven-compiler-plugin configuration has no effect neither inside m2e nor during
> command line build.
> 
> Second, the compiler the project does use, i.e. maven-pax-plugin, is not
> supported by m2e core and there is no thirdparty m2e extension that provides
> such support.
> 
> The easiest short-term solution is to modify osgi-project/poms/pom.xml file and
> move <extensions> from maven-pax-plugin to maven-bundle-plugin as explained in
> the comment in the pom.xml file.
> 
> Longer term solution requires developing m2e support for maven-pax-plugin. m2e
> team does not have immediate plans to do this, but we will be happy to review
> and apply a quality patch. If anyone is interested, please raise your hand on
> m2e-dev list and we'll help with pointers to get started.

Thank you very much explaining the whole details to me, and moving "extensions" to maven-bundle-plugin did solve the problem although I'm not sure what "extension" is. Sorry I'm a beginner of Maven.

And finally marking this bug as invalid.
Comment 10 Denis Roy CLA 2021-04-19 13:24:51 EDT
Moved to https://github.com/eclipse-m2e/m2e-core/issues/