Add OSGi metadata to Querydsl modules

Bug #779743 reported by Oliver Gierke
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

The Querydsl JARs contain manifest files but they in turn contain any import or export declarations. Would be cool if they could contain valid OSGi metadata which can be generated with little effort.

I've attached a patch that uses SpringSource Bundlor plugin to generate the metadata for Core, APT, Maven Plugin, SQL and JPA (the JPA profile pretty much). Bundlor can use Maven properties to generate the version ranges in the MANIFEST.MF, which - if used more intensively - could reduce the amount of version information duplication in pom.xml and template.mf.

Beyond that you have a split package com.mysema.util in Core module as well as SQL module which will cause trouble in an OSGi context as packages must not be split between JARs. I also had to change the version scheme to 2.2.0.beta-4-SNAPSHOT as OSGi requires a 3rd version digit to be numeric only as well.

I had to configure the JAR plugin in querydsl-root as well, as it does not include generated MANIFEST.MF files by default.

I hope the patch helps you getting started with Bundlor a bit. Feel free to contact me for further assistance.

Tags: build osgi
Revision history for this message
Oliver Gierke (ogierke) wrote :
description: updated
description: updated
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

I just added minimal template.mf into the modules and fixed the split package issue. Could you given me some hints on how I should configure the core, apt, sql, jpa and mongodb modules so that they work for you?

How much metadata do I need to put into template.mf:s to get proper manifests?

Changed in querydsl:
status: New → In Progress
Revision history for this message
Oliver Gierke (ogierke) wrote :

You can add a configuration attribute <failOnWarnings>true</failOnWarnings> to Bundlor. If configured this way Bundlor will break the build if you e.g. introduce a new dependency that you don't have added a version range in template.mf for. I didn't include it the first place as the split package generated such a warning and I didn't wanna leave you with a broken build.

What do you mean with:

"Could you given me some hints on how I should configure the core, apt, sql, jpa and mongodb modules so that they work for you?"

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Can't the version ranges be detected from the Maven metadata or does Bundlor operate only on the target jar?

Revision history for this message
Oliver Gierke (ogierke) wrote :

It partially can. Assuming you have defined a Maven property like this:

<properties>
  <spring.version>3.0.5.RELEASE</spring.version>
</properties>

then you can do something like this in the template.mf:

Import-Template:
  org.springframework.*;version="${spring.version:[=.=.=.=,+1.0.0)}"

This pretty much says: take the maven property spring.version, take it's 4 digits as lower inclusive bound and stretch the upper bound until the next major release. The result will be "[3.0.5.RELEASE,4.0.0)" in that case. So you don't need to touch the template.mf in case you update dependency versions.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

I just commited improved template.mfs.

Revision history for this message
Jean-Pierre Bergamin (ractive) wrote :

I could not find any bugtracker for the codegen and the commons-lang project that is also used by querydsl. So I just mention it here...

It would be very convenient if mysema codegen and the commons-lang projects would also be available with proper OSGi manifests.

Revision history for this message
Jean-Pierre Bergamin (ractive) wrote :

BTW: I just saw that querydsl-core/template.mf has a type. The version of the net.jcip.annotations package is wrong:

...
net.jcip.annotations.*;version="${findbugs.version}",
...

Either you should define a new property or just use 1.0.0

Revision history for this message
Jean-Pierre Bergamin (ractive) wrote :

I also would exclude the findbug imports, since they are not needed at runtime:
In template.mf:
...
Excluded-Imports:
 edu.umd.cs.findbugs.annotations.*
...

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Fixed the templates

Changed in querydsl:
status: In Progress → Fix Committed
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Released in 2.2.0

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.