danieldietrich / xtext-protected-regions

Xtext Protected Regions
danieldietrich.net
12 stars 6 forks source link

Revise project dependencies and .pom files #13

Closed danieldietrich closed 13 years ago

danieldietrich commented 13 years ago

What are the best practices?

  1. how to deal with eclipse dependencies? does the version of jar dependencies matter regarding the case that the current eclipse workspace may have a different versions or does osgi the whole job?
  2. how to deal with dependencies between different projects in one repo? has each project to be bundled as .jar and stored in a maven repo? what, if ongoing development makes it nescessary, that projects depend while development on each other without bundling them for each line which changes. example: net.danieldietrich.protectedregions and net.danieldietrich.protectedregions.xtext
  3. how to deal with .jar dependencies currently nowhere available in a public maven repo. should we provide the .jars in a public repo or has a developer to download all nescessary dependencies and store them in his local maven repo?

Many questions...

ceefour commented 13 years ago

For some questions, the Maven-PDE integration is "Tycho":http://www.eclipse.org/tycho/ ("wiki":http://wiki.eclipse.org/Category:Tycho).

  1. In Tycho, create a target definition, put p2 update sites there. Artifact resolution will use OSGi, i.e. specify the dependecies using Import-Package/Require-Bundle, Tycho/p2 will determine the artifact to use.
  2. This uses m2e's "Enable Workspace Resolution" feature. Simply open the projects in Eclipse, and m2e should detect that they're referring to each other. No need to repackage, just save a .java file and it's already "in effect". When this feature works (it should!), it's a time saver.
  3. In Tycho, no traditional Maven repos anymore, we work exclusively with p2 update sites, and they can be remote and local. If you need an additional artifact, several choices:
    • create additional .target definition file that includes the needed artifacts. The reason is that Tycho only supports p2 update sites, however PDE's resolver supports Eclipse installation, folders containing bundles, etc. so it's more flexible. But you may need to put in README where the .target definition file looks for these files. Project won't build in Maven command line, but should load fine in Eclipse PDE...
    • the "right" way is the PDE traditional: create a p2 update site, put the dependencies there. The p2 site should be hosted somewhere. Then add the update site URL to .target definition file, usable by Tycho. As a not so good alternative: it can be "hosted" on GitHub where it becomes a local p2 repo upon git clone.
ceefour commented 13 years ago

Hmm... the GitHub Flavored Markdown formatter is also funny ;-)

danieldietrich commented 13 years ago

Had also fun with the GitHub Flavored Markdown :-) Especially I like the unpredictable ordered / unordered list behavior.

Great idea that we will put the dependencies on a p2 update site. Perhaps we can put there a release, too, when making progress with the dsl's and all the generator magic :-) Regarding the other dependencies: The Eclipse and the Xtext dependencies should be available on existing p2 update sites - we can reference these, if possible. For the moment there are not much more dependencies. Guice and Junit should be part of Xtext. We need apache common-io - that's it, right?

I have created the folder danieldietrich.net/eclipse on my webspace. You will receive the user/pass in a minute...

ceefour commented 13 years ago

Tycho 0.13.0 not yet working with m2e. had to use 0.12.0.

danieldietrich commented 13 years ago

0.12.0 is fine there seems to be a workaround (https://bugs.eclipse.org/bugs/show_bug.cgi?id=351842) but I'm a friend of clean and stable versions :-)

ceefour commented 13 years ago

I guess it's not that bug, but I've found my own workaround that makes 0.13.0 usable. :-)

Working with p2 update sites is killing me (at least with the typical lousy connection here in Indonesia). I just wish p2's resolver is more greedy in caching repository metadatas, I think it's downloading the same thing over and over again anytime I try to do something. :-(

danieldietrich commented 13 years ago

yes, that's what i am experiencing, too. working with eclipse update sites is sloooow, although the internet connection is ok here. can't imagine how slow it might be for you - but you take advantage of the coffee connection at java ;-)

ceefour commented 13 years ago

The target definition is at net.danieldietrich.protectedregions.target/indigo.target Use it as "Set as Target Platform". You can add more required plugins.

as of 4 Oct 2011, if you have trouble "Unresolveable build extension" with Tycho and m2e/PDE, here's a workaround:

    1. Change the tycho-version to 0.12.0
    2. Let m2e install the Tycho Configurator and restart Eclipse
    3. Change tycho-version back to 0.13.0

PS: GitHub's auto-linking of commits to issue numbers is quite neat. :)

ceefour commented 13 years ago

Why half-done? Right now my laptop is still downloading a 6,3 MB ICU jar which has been doing so for the past 15 minutes or so, and I still have a bunch more artifacts to go (Resolving Target Definition at 54%... :( ).

It's downloading something I already have in my hard drive! p2 really needs to get a bit smarter, my Eclipse IDE and the .target definition use pretty much the exact same update sites, why is it re-downloading? why not at least reuse the IDE files themselves as "cache"? ................ I guess Eclipse devs are all on blazing fast internets #sigh

danieldietrich commented 13 years ago

currently reading about tycho+m2e. i am curious to see how it all fits together!!

have to use that fancy github auto-linking stuff, too ;-)

danieldietrich commented 13 years ago

just read the files you committed - you are an eclipse virtuoso!

danieldietrich commented 13 years ago

You've done an amazing job with the project setup!! Thank you, I am learning so much. The commons-io jar is currently not found which will be placed in our p2 repo I guess (UPDATE: I saw it in the eclipse orbit p2 update site) and the source folder in net.dd.protectedregions.xtext is not recognized (UPDATE: just pushed fix). I'm knitting around a little bit with that, it's a good finger exercise for me regarding tycho.

Btw: The installation with tycho 0.13.0 was flawless! Needed no workaround. I am running Eclipse Indigo SR1 for JEE Devs with the following plugins: EGit, m2e, JBoss Tools 3.3, Google Plugin and Xtext (all installed via Marketplace).

New to all this m2e-tycho voodoo magic I went the following way. Does this sound ok for you, Hendy?

Prequisites

Install EGit - Git Team Provider and Maven Integration for Eclipse (m2e) (via Marketplace).

Get a local copy of xtext-protectedregions from GitHub

git clone git@github.com:danieldietrich/xtext-protectedregions.git

Setup Eclipse Workspace

danieldietrich commented 13 years ago

some thoughts...

ceefour commented 13 years ago

Apache Commons IO and a bunch of other open source libraries is available here: http://download.eclipse.org/tools/orbit/downloads/

I put the latest "stable" version repo in the .target, so it should be found. (where "stable" is less than "release", but more recent)

ceefour commented 13 years ago
  1. Child modules: I think groupId are optional in child, regardless of Tycho... ;-)
  2. Picking dependencies: You can actually just add a whole p2 repo (uncheck "include required dependencies"). You set the target for a "whole" project environment, which means all projects you're currently working on, not per-project dependencies. So each project will use only the dependencies in p2 that they explicitly require via Import-Package and Require-Bundle's. It's not "dangerous" to overspecify dependencies in .target file, other than it may waste some download time and it confuses what "target" / purpose of the .target file. (pardon the pun, but .target files should be targeted for specific kind of RCP deployment, even if not doing RCP)
  3. Distro: I mainly use Eclipse Modeling, it gives me a base that I need (EMF, Ecore Tools, etc.) add Xtext and I'm usually done. I don't think Eclipse RCP distro is useful, since Eclipse Modeling also supports RCP development anyway. For RAP development I think will just add RAP to my Eclipse Modeling instance. For Java EE development I still use a separate Eclipse Java EE then add Xtext to it, just for avoiding conflicts. My workflow is increasingly dealing with EMF+Xtext wherever I go (even PHP).
  4. Indigo/Juno etc. The dependencies are actually controlled by Import-Package/Require-Bundle. To specify different set of artifacts you can create additional .target files, and Eclipse PDE supports switching targets just by opening the target file and Set As Target Platform. Assuming both the projects's MANIFEST.MF are properly specified and the target files contain the needed artifacts, it's easy to test with different Eclipse release versions, though I myself don't really do that. (the maximum for me is targeting a current release i.e. 3.7.1 and the next release i.e. 4.2 but even that I would do early tests then pick one version and get on with it). As for Tycho, I'm not sure it explicitly supports several target files at once but switching is possible using Maven profiles or by using .
danieldietrich commented 13 years ago

hendy, thank you for the detailed description! one more question: you use two eclipse distros: one for modelling and one for jee development (for example). does you bundle your generator and use/call it in the jee distro? or do you generate directly in the modelling distro? just for the sake...

ceefour commented 13 years ago

Daniel: either choice, depending whether I need "rapid prototyping" or not.

One reason why I upgraded to a 8 GB laptop is so I can launch 2 Eclipse instances at will, with separate workspaces. But sometimes workspaces share a project or two.

During the "DSL/generator development" phase, usually I will launch Modeling just for the modeling and DSL. After editing the textual model, I will launch MWE2 to generate the files to the target project. The target project is in Eclipse JEE, and I test the generated files there.

During development of a textual model (i.e. the DSL/generator is more "stable"), I need rapid prototyping. I install Xtext into my Eclipse Java EE distro, and install needed DSL(s) into the workspace. So I can just Ctrl+S a textual model and get the generated Java files etc. instantly. Since there's Xtext SDK there anyway, the Java EE distro can be used to modify the DSL/generator if wanted.

But I tend to keep my distros as light as possible, only the necessary plugins, not combining multiple work environments into one big jumbo Eclipse. Reason is to avoid conflicting Eclipse plug-ins, and maybe to conserve memory, or (atthough theoretically, there should be no problem) who knows what problems may occur due to too many installed plug-ins.

Closing this issue, let me know if you still have problems with Tycho.

ceefour commented 13 years ago

spoke to soon..

ceefour commented 13 years ago

Done.

danieldietrich commented 13 years ago

noticed, that you removed .classpath and .project from some .gitignore files. do we need them because of the compile time project dependencies?

ceefour commented 13 years ago

Honestly speaking, I'm not entirely sure. If you confirm that you can load the project correctly without pre-existing .classpath and .project files then I guess it's safe to ignore them from Git. :-)

What I know for sure is that build.properties and META-INF/MANIFEST.MF are mandatory for Tycho (and PDE) projects.

danieldietrich commented 13 years ago

i will try it being back at home...