Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] Tycho and code generation: Best practices

On 06/05/2012 10:44 AM, Christian Soltenborn wrote:
So I'm asking myself: How do you guys handle code generation and
committing of POMs? Are there any best practices which would suit my
very situation?
APPROACH 1: the Maven way, static pom.xml
I tend to think that you should create the folders for bundles you will generate, and put a pom.xml in them. You should try to get "mvn install" to work directly on a bundle that will be generated, and having a pom.xml containing the necessary steps to generate the contents of the pom.
Maven provide the "generate-source" build goal dedicated to this use-case, that's IMHO the way to go.

In a nutshell, my advice is:
* Create 1 folder for each bundle where generation will take place
* Commit a pom.xml into it.
* Try to tweak the pom.xml to be able to generate sources for this bundle directly from its pom

But, I am not sure how Tycho behaves with generate-source, maybe it performs validation before this steps so it wouldn't work without a MANIFEST.MF. If it is so, you can probably open a bug for that use-case, which is very common.

OR, APPROACH 2: The p2 way, generating dynamically IUs for generated stuff
This is more inspired of how source-feature work in Tycho: most Tycho packagingType ultimately ends and are consumed in the build as p2 IUs. For source-features, build creates another feature additionally to the standard one, and uses tycho-p2-plugin to publish its p2 metadata and make it consumable in the rest of the build.
Then you could think of a Maven "generator" module that would perform generation and then invoke tycho-p2-plugin to publish metadata for all newly created bundles. These should be available in other part of the build.
But in that case, your modules are not autonomous: they rely on the "generator".


To be honest, I already thought about both approaches, but never implemented one. Everything I wrote are just ideas, so don't put too much hope in actually setting them up ;)
--
Mickael Istria
Eclipse developer at JBoss, by Red Hat
My blog - My Tweets

Back to the top