tesla / m2eclipse-tycho

25 stars 26 forks source link

Support for Maven dependencies and test source directory #16

Closed tkleszczynski closed 10 years ago

tkleszczynski commented 10 years ago

Hi,

Is it possible to modify importing project by this plugin in such a way that Maven classpath container will be available in the eclipse project? If this would be supported maven test dependencies may be available (maybe only when pomDependencies=consider is set - I'm not sure here),

Second interesting option might be configuring test source directories based on configuration in pom.xml (project -> build -> testSourceDirectory). Then, unit test sources may be placed in the same project as source code.

project |- src - source code |- src-test - unit test code pom.xml

build.properties source.. = src/

As I see project source directory is configured from build.properties options. What about source directories settings in pom.xml, currently they seem to be ignored.

ifedorenko commented 10 years ago

No, this does not make much sense.

Assuming you are talking about eclipse-plugin projects, these projects do not have Maven dependencies. Even with pomDependencies=consider, Tycho only considers Maven dependencies when calculating project dependencies, so forcing Maven dependencies on compilation classpath will be incorrect. Proper representation of Tycho dependencies in Eclipse workspace projects will require more or less complete PDE rewrite and is outside of the scope of m2eclipse-tycho.

Similarly for test sources, Tycho projects (and PDE projects) do not have the notion of "test" sources, each project has just one classpath and there is no way to introduce test sources with test dependencies without polluting main classpath of the project.

tkleszczynski commented 10 years ago

Thanks for your answer. Can I then understand that m2eclipse-tycho and Tycho itself strictly follows the way, how PDE handles projects (source folders, dependency containers, etc.)? And there is no chance of making any derogations?

I was thinking about running unit test as part of eclipse-plugin build. From maven point of view there was no problem, I can configure maven-compiler-plugin and maven-surefire-plugin (see my simple example https://github.com/tkleszczynski/tycho-unit-tests) and have unit tests ran as a part of eclipse-plugin build. Importing project to Eclipse using m2eclipse-tycho was the last part of my puzzle. Answer on stackoverflow http://stackoverflow.com/a/22082266 about using m2e seemed promising.

What's your opinion about this way of running unit tests? Do you think would it be possible to run test like that using Tycho/PDE toolchain in the near future?

ifedorenko commented 10 years ago

No, most definitely not possible "in the near future" and most likely never possible. Tycho (and PDE) projects have single classpath controlled by OSGi bundle manifest. Even if you can trick java compiler to compile test classes, OSGi test runner will not be "see" the test classes and dependencies.

Of course, nothing stops you from changing how Tycho and PDE work. For example, one idea that was discussed in the past was to use plain maven compiler and unit test runner for OSGi project tests. Another idea was to introduce additional "test" bundle manifest to control compilation and dependencies of the test classes. You are welcome to try these or other ideas and I'd be interested to see the result... but honestly, my advice is to stick with the current project structure and use naming convention to group together bundles and their corresponding test bundles.

tkleszczynski commented 10 years ago

I'm not trying to make maven dependencies visible to tycho-surefire-plugin. Having separate test project (eclipse-test-plugin) and running tests using tycho-surefire-plugin is ok and it works very well for integration tests where part of system need to be up and running in order to perform tests. I'm looking for lightweight solution for unit tests which nowadays have to be run in the same way as integration tests. tycho-surefire needs more time to perform tests as it have to initialize OSGi framework - my goal is not having this initialization for tests which don't need OSGi environment.

Following project structure would be great: bundle (eclipse-plugin) - containing source and unit tests bundle.test (eclipse-test-plugin) - containing integration tests

Nevertheless, thank you for your time.