Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 369561 - P2 resolver fails with non-standard version and source plugin enabled
Summary: P2 resolver fails with non-standard version and source plugin enabled
Status: RESOLVED INVALID
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-24 12:47 EST by Kamil Demecki CLA
Modified: 2021-04-28 16:55 EDT (History)
1 user (show)

See Also:


Attachments
maven project to reproduce problem on tycho 0.11.0 (4.89 KB, application/zip)
2012-01-24 12:49 EST, Kamil Demecki CLA
no flags Details
maven project to reproduce problem on tycho 0.13.0 (4.87 KB, application/zip)
2012-01-24 12:49 EST, Kamil Demecki CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kamil Demecki CLA 2012-01-24 12:47:27 EST
Build Identifier: 0.11.0 and 0.13.0

I'm migrating build from tycho.targetPlatform property to p2 repository. 

Base build is working correctly for tycho.targetPlatform and p2.

When enabling source plugin then build for p2 resolver finishes with error. It didn't happen for tycho.targetPlatform.

Unfortunately my (super) company has general policy to version packages and it is completely non-standard (eg CXXX_RYYY). This versioning works with tycho.targetPlatform and bundling sources (with settings strictVersions=false).

I prefer migrating to p2 as it is faster but this means no deploying sources on repository and it is quite big drawbacks



Reproducible: Always

Steps to Reproduce:
To reproduce you can invoke build from attachments (one package for tycho 0.11.0 and one for 0.13.0 because tycho packages changed its groupId)

1. OK - mvn clean install -Dp2.eclipse.url=[url] -Pp2 
2. OK - mvn clean install -Declipse.dir=[dir] -PtargetPlatform
3. FAIL - mvn clean install -Dp2.eclipse.url=[url] -Pp2,sources
4. OK - mvn clean install -Declipse.dir=[dir] -PtargetPlatform,sources
Comment 1 Kamil Demecki CLA 2012-01-24 12:49:29 EST
Created attachment 209988 [details]
maven project to reproduce problem on tycho 0.11.0
Comment 2 Kamil Demecki CLA 2012-01-24 12:49:49 EST
Created attachment 209989 [details]
maven project to reproduce problem on tycho 0.13.0
Comment 3 Kamil Demecki CLA 2012-01-24 12:52:09 EST
It is exception

Caused by: java.lang.RuntimeException: org.osgi.framework.BundleException: Invalid manifest header Bundle-Version: "CXXX_RYYY" : For input string: "CXXX_RYYY"
	at org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator.getPublisherActions(SourcesBundleDependencyMetadataGenerator.java:80)
	at org.eclipse.tycho.p2.impl.publisher.AbstractMetadataGenerator.generateMetadata(AbstractMetadataGenerator.java:58)
	at org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator.generateMetadata(SourcesBundleDependencyMetadataGenerator.java:52)
	at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.setupProjects(P2TargetPlatformResolver.java:125)
	at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.setupProject(DefaultTychoDependencyResolver.java:73)
	at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:85)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:273)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
Comment 4 Igor Fedorenko CLA 2012-01-24 13:32:19 EST
Although Tycho should produce a better error message, version in pom.xml and bundle manifests are expected to match. In your case you need to change pom.xml version to 1.0.0-SNAPSHOT.
Comment 5 Kamil Demecki CLA 2012-01-25 08:28:58 EST
Unfortunately MANIFEST.MF cannot contain CXXX_RYYY version because it contains letters.

Let me explain, not-small company has strict policy for source code tags and names of binaries packages deployed on customer server. Both contain version CXXX_RYYY (something like C\d{4,6}-R[A-Z]\d{4-6}}). I don't why but it is not possible to change it.

For packages which are used in OSGI container we define in MANIFEST.MF simply version 1.0.0 and it is OK because OSGI container matches versions only in Manifest and file name is not important and also we don't support multiple versions of same package in runtime.

For builds we are using mostly maven and ant as well and common point is remote maven repository. So for OSGI build we are referencing dependencies from nexus and use copy-dependendies goal to download them on disk and after that tycho publish-features-and-bundles goal is making local p2 repo from it. Previously instead local p2 we downloaded directory for tycho.targetPlatfrom option. In this scenario we need deploy modules on maven repository with version CXXX_RYYY (or 1.0.0-CXXX-RYYY - look at last senctence).

So we are using versions mostly to get correct jar for building. It has few advantages, for example works well for osgi and non-osgi builds and nexus is better scalable than p2 remote updatesite but it is not main point.

Build team evavaluated this kind of versioning in tycho and because of existing strictVersions=false they said this approach is possible.

It looks like bug occurs only when source bundle is generated.

Now case #1 works with p2 repository, Does your comment mean than in future tycho can break case #1? So it won't be possible use non-standard versions with p2 resolver?

One idea is use Manifest with version 1.0.0.CXXX-RYYY and and in maven 1.0.0-CXXX-RYYY. I tested it and it works OK for case #1 but still fals for case #3. I'm almost sure that in this kind of version it should work.
Comment 6 Igor Fedorenko CLA 2012-01-25 08:44:23 EST
Provide a quality patch that correctly generates source bundles for projects that use non-standard version and we will consider it. I can't promise we'll accept the patch, but if the change is reasonable and does not break existing behaviour I may agree to apply it.

Also, if all of your dependencies come from existing maven repositories (as it appears to be the case from comment 5), maven-bundle-plugin is probably a better approach.
Comment 7 Kamil Demecki CLA 2012-01-25 09:13:16 EST
Thanks for information. I cannot promise patch but will see. 

I hope that case #1 won't be broken in future version of tycho ;) (from error message it looks that it is a accident that case #1 works but #3 not).

I don't think maven-bundle-plugin is good choice. We are using Manifest first approach - developers like vanilla Eclipse only with target platform materialized on disk - we have one target platform for hundreds of plugins. Tycho allows apply minimal pom for each from this hundreds plugins and it is good - only problem is generate target platform (or local p2 repo) but is similar to situation in IDE and as well in runtime.
Comment 8 Igor Fedorenko CLA 2012-01-25 10:02:20 EST
That case #1 works in indeed an accident, there is a good chance we'll enforce versions equality between pom.xml and bundle manifest in the future.
Comment 9 Kamil Demecki CLA 2012-01-25 10:36:09 EST
Ok, it is probably that tycho with version "CXXX_RYYY" in pom.xml and 1.0.0 in Manifest won't work.

But what about versions: 1.0.0-CXXX-RYYY in pom.xml and 1.0.0.CXXX-RYYY in Manifest? It is correct version for Manifest but I'm not sure about maven - Tycho shows warning that versions don't match. 

As far I know now only 1.0.0-SNAPSHOT and 1.0.0.qualifier works with tycho out of box. (case #3 still doesn't work now but I case #1 should work in any future version if previous sentence is correct).
Comment 10 Igor Fedorenko CLA 2012-01-25 10:46:41 EST
1.0.0-CXXX-RYYY in pom.xml and 1.0.0.CXXX-RYYY in Manifest are two different versions. 1.0.0-CXXX-RYYY is not a snapshot Maven version and will not be expanded by the build.

1.0.0.CXXX-RYYY both in pom.xml and in Manifest is expected to work, however.
Comment 11 Kamil Demecki CLA 2012-01-25 11:08:57 EST
Good point ;)  I was suggested by analogy of 1.0.0-SNAPSHOT and 1.0.0.qualifier. Indeed for version 1.0.0.CXXX-RYYY (dot instead of dash after 1.0.0) both cases #1 and #3 work.

Thanks for help.
I think it better approach to use 1.0.0.CXXX-RYYY than CXXX-RYYY in builds as it is more standard and I don't mind to close this bug.

During release we're using version:set for setting versions in poms. I will try to find how Manifest version can be populated, probably by maven filtering or by qualifier possibilities.
Comment 12 Tobias Oberlies CLA 2012-05-23 09:27:36 EDT
It appears to me as if the problem is solved, and Tycho doesn't need to be changed, right?
Comment 13 Kamil Demecki CLA 2012-05-23 09:48:40 EDT
Right.