stempler / bnd-platform

Build OSGi bundles and Eclipse Update Sites from existing JARs, e.g. from Maven repositories (Plugin for Gradle)
Apache License 2.0
79 stars 30 forks source link

Illegal version for source feature #14

Closed HaasJona closed 7 years ago

HaasJona commented 8 years ago

Maybe I'm doing something wrong, but I have a plugin and the corresponding source plugin in a local maven repository. I'm trying to create a feature and updatesite from them, but I get the following exception when building the updatesite:

Status ERROR: org.eclipse.equinox.p2.artifact.repository code=0 Format "format(n[.n=0;[.n=0;[.S=[A-Za-z0-9_-];='';]]])" was unable to parse 1.0.0-SNAPSHOT java.lang.IllegalArgumentException: Format "format(n[.n=0;[.n=0;[.S=[A-Za-z0-9_-];='';]]])" was unable to parse 1.0.0-SNAPSHOT

Product publishing ended with the following exception:
java.lang.IllegalArgumentException: Format "format(n[.n=0;[.n=0;[.S=[A-Za-z0-9_-];='';]]])" was unable to parse 1.0.0-SNAPSHOT
    at org.eclipse.equinox.internal.p2.metadata.VersionFormat.parse(VersionFormat.java:275)
    at org.eclipse.equinox.internal.p2.metadata.VersionParser.parse(VersionParser.java:89)
    at org.eclipse.equinox.p2.metadata.Version.create(Version.java:79)
    at org.eclipse.equinox.p2.metadata.Version.parseVersion(Version.java:141)
    at org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry.<init>(FeatureEntry.java:63)
    at org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureManifestParser.processPlugin(FeatureManifestParser.java:236)
    at org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureManifestParser.startElement(FeatureManifestParser.java:270)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
    at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:357)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2787)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:118)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
    at org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureManifestParser.parse(FeatureManifestParser.java:126)
    at org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser.parse(FeatureParser.java:89)
    at org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction.getFeatures(FeaturesAction.java:518)
    at org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction.perform(FeaturesAction.java:604)
    at org.eclipse.equinox.p2.publisher.Publisher$ArtifactProcess.run(Publisher.java:207)
    at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.executeBatch(SimpleArtifactRepository.java:1294)
    at org.eclipse.equinox.p2.publisher.Publisher.publish(Publisher.java:231)
    at org.eclipse.equinox.p2.publisher.AbstractPublisherApplication.run(AbstractPublisherApplication.java:283)
    at org.eclipse.equinox.p2.publisher.AbstractPublisherApplication.run(AbstractPublisherApplication.java:253)
    at org.eclipse.equinox.p2.publisher.AbstractPublisherApplication.start(AbstractPublisherApplication.java:315)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.equinox.internal.app.AnyThreadAppLauncher.run(AnyThreadAppLauncher.java:26)
    at java.lang.Thread.run(Thread.java:745)

Looking at the Features shows that one source plugin has an incorrect maven-like version number:

<feature id="xxx" label="xxx" version="1.0.0.bnd-65Nwvw" provider-name="xxx">
<plugin id="my.plugin" download-size="0" install-size="0" version="1.0.0.201608151337" unpack="false"/>
<plugin id="my.plugin.source" download-size="0" install-size="0" version="1.0.0-SNAPSHOT" unpack="false"/>
<plugin id="org.apache.batik.dom" download-size="0" install-size="0" version="1.6.0.v201011041432" unpack="false"/>
<plugin id="org.apache.batik.dom.svg" download-size="0" install-size="0" version="1.6.0.v201011041432" unpack="false"/>
<plugin id="org.apache.batik.transcoder" download-size="0" install-size="0" version="1.6.0.v201011041432" unpack="false"/>
<plugin id="org.apache.batik.util" download-size="0" install-size="0" version="1.6.0.v201011041432" unpack="false"/>
<plugin id="org.apache.batik.xml" download-size="0" install-size="0" version="1.6.0.v201011041432" unpack="false"/>
<plugin id="org.eclipse.birt" download-size="0" install-size="0" version="4.3.2.v201308301349" unpack="false"/>
<plugin id="org.eclipse.core.commands" download-size="0" install-size="0" version="3.6.100.v20130515-1857" unpack="false"/>
<plugin id="org.eclipse.core.commands.source" download-size="0" install-size="0" version="3.6.100.v20130515-1857" unpack="false"/>
<plugin id="org.eclipse.core.jobs" download-size="0" install-size="0" version="3.5.300.v20130429-1813" unpack="false"/>
<plugin id="org.eclipse.core.jobs.source" download-size="0" install-size="0" version="3.5.300.v20130429-1813" unpack="false"/>
<plugin id="org.eclipse.core.runtime" download-size="0" install-size="0" version="3.9.0.v20130326-1255" unpack="false"/>
<plugin id="org.eclipse.core.runtime.source" download-size="0" install-size="0" version="3.9.0.v20130326-1255" unpack="false"/>
<plugin id="org.eclipse.draw2d" download-size="0" install-size="0" version="3.10.100.201606061308" unpack="false"/>
<plugin id="org.eclipse.e4.core.contexts" download-size="0" install-size="0" version="1.3.1.v20130905-0905" unpack="false"/>
<plugin id="org.eclipse.e4.core.contexts.source" download-size="0" install-size="0" version="1.3.1.v20130905-0905" unpack="false"/>
<plugin id="org.eclipse.emf.common" download-size="0" install-size="0" version="2.9.1.v20130827-0309" unpack="false"/>
<plugin id="org.eclipse.emf.ecore" download-size="0" install-size="0" version="2.9.1.v20130827-0309" unpack="false"/>
<plugin id="org.eclipse.emf.edit" download-size="0" install-size="0" version="2.5.0.v200906151043" unpack="false"/>
<plugin id="org.eclipse.equinox.common" download-size="0" install-size="0" version="3.6.200.v20130402-1505" unpack="false"/>
<plugin id="org.eclipse.equinox.common.source" download-size="0" install-size="0" version="3.6.200.v20130402-1505" unpack="false"/>
<plugin id="org.eclipse.equinox.registry" download-size="0" install-size="0" version="3.5.301.v20130717-1549" unpack="false"/>
<plugin id="org.eclipse.equinox.registry.source" download-size="0" install-size="0" version="3.5.301.v20130717-1549" unpack="false"/>
<plugin id="org.eclipse.gef" download-size="0" install-size="0" version="3.11.0.201606061308" unpack="false"/>
<plugin id="org.eclipse.jface" download-size="0" install-size="0" version="3.9.1.v20130725-1141" unpack="false"/>
<plugin id="org.eclipse.jface.source" download-size="0" install-size="0" version="3.9.1.v20130725-1141" unpack="false"/>
<plugin id="org.eclipse.swt" download-size="0" install-size="0" version="3.102.1.v20130827-2021" unpack="false"/>
<plugin id="org.eclipse.swt.gtk.linux.x86_64" download-size="0" install-size="0" version="3.102.1.v20130827-2048" unpack="false"/>
<plugin id="org.eclipse.swt.gtk.linux.x86_64.source" download-size="0" install-size="0" version="3.102.1.v20130827-2048" unpack="false"/>
<plugin id="org.eclipse.ui" download-size="0" install-size="0" version="3.105.0.v20130522-1122" unpack="false"/>
<plugin id="org.eclipse.ui.forms" download-size="0" install-size="0" version="3.6.1.v20130822-1117" unpack="false"/>
<plugin id="org.eclipse.ui.forms.source" download-size="0" install-size="0" version="3.6.1.v20130822-1117" unpack="false"/>
<plugin id="org.eclipse.ui.source" download-size="0" install-size="0" version="3.105.0.v20130522-1122" unpack="false"/>
<plugin id="org.eclipse.ui.views.properties.tabbed" download-size="0" install-size="0" version="3.6.0.v20130515-1857" unpack="false"/>
<plugin id="org.eclipse.ui.views.properties.tabbed.source" download-size="0" install-size="0" version="3.6.0.v20130515-1857" unpack="false"/>
<plugin id="org.eclipse.ui.workbench" download-size="0" install-size="0" version="3.105.1.v20130821-1411" unpack="false"/>
<plugin id="org.eclipse.ui.workbench.source" download-size="0" install-size="0" version="3.105.1.v20130821-1411" unpack="false"/>
<plugin id="osgi.core" download-size="0" install-size="0" version="6.0.0.201403061837" unpack="false"/>
</feature>

The corresponding binary plugin has a correct version, so I'm not sure what's going on here. Disabling the source plugins with

platform {
    fetchSources = false
}

solves the problem, but I would like to include the sources on my updatesite.

Also I'm wondering if it's possible to remove the org.eclipse.* plugins from the feature/updatesite because while they're a dependency, I don't really want to publish them in my own updatesite.

stempler commented 8 years ago

Looking at the Features shows that one source plugin has an incorrect maven-like version number

Yes, that's strange. If it the source bundle is processed by bnd-platform it should OSGify the version.

Can you show the excerpt of your build.gradle where you add the dependency to your plugin? Do you build your plugin also with the same Gradle build or does this happen somewhere else?

Also I'm wondering if it's possible to remove the org.eclipse.* plugins from the feature/updatesite because while they're a dependency, I don't really want to publish them in my own updatesite.

If the Eclipse stuff is recognized as dependency because they are transitive Maven dependencies (e.g. provided via unpuzzle or the like), then you can use the standard mechanism in Gradle to exclude them from the platform configuration (and thus from the update site).

HaasJona commented 8 years ago

Can you show the excerpt of your build.gradle where you add the dependency to your plugin?

This is the project that creates the feature:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.standardout:bnd-platform:1.4.0'
    }
}

defaultTasks 'clean', 'updateSiteZip'

apply plugin: 'org.standardout.bnd-platform'

platform {
    //fetchSources = false
}

dependencies {
    platform project(':de.plugin.dobj')
}

de.plugin.dobj is a goomph project that builds a eclipse plugin. It has dependencies to the "my.plugin" and to the eclipse bundles. "my.plugin" is build via tycho and put into a local maven repo, but not sure if that matters.

If the Eclipse stuff is recognized as dependency because they are transitive Maven dependencies (e.g. provided via unpuzzle or the like), then you can use the standard mechanism in Gradle to exclude them from the platform configuration (and thus from the update site).

Thanks, didn't realized it was that easy.

stempler commented 8 years ago

I found that dependencies on projects are not so easy to deal with (or I just don't have the necessary knowledge of the Gradle internals), see also this issue.

What you could try is instead adding your plugin via the local maven repo. Something like this:

repositories {
  mavenLocal()
}

dependencies {
  platform "mygroup:myplugin:$pluginVersion"
}
HaasJona commented 8 years ago

What you could try is instead adding your plugin via the local maven repo. Something like this:

Weird, that makes the source plugin appear twice, and one time with correct version.

<feature id="xxx" label="xxx" version="1.0.0.bnd-Ovs7LA" provider-name="xxx">
<plugin id="my.plugin" download-size="0" install-size="0" version="1.0.0.201608151337" unpack="false"/>
<plugin id="my.plugin.source" download-size="0" install-size="0" version="1.0.0-SNAPSHOT" unpack="false"/>
<plugin id="my.plugin.source" download-size="0" install-size="0" version="1.0.0.201608151337" unpack="false"/>
</feature>
stempler commented 8 years ago

Strange, no idea where the second one could come from. When you disable fetchSources both are removed?

HaasJona commented 8 years ago

When you disable fetchSources both are removed?

Yes.

I will try to investigate, I realize that my project might be strange. Just trying to automate building eclipse plugins and features with gradle.

stempler commented 8 years ago

I assume your project is not publicly available somewhere so I could try to reproduce and look for a likely candidate for the cause?

Anyway, this would be what I would probably check:

Also, a simple workaround may be, that before the updateSite task, but after bundles, you delete the undesired source Jar. Not pretty, but easy and fast to implement.

HaasJona commented 8 years ago

I assume your project is not publicly available somewhere so I could try to reproduce and look for a likely candidate for the cause?

No, unfortunately there is some company specific code in there that I can't release into the public. I will try to create a minimal example when I have some time.

michaelamaura commented 8 years ago

I get the same problem when I'm resolving artifacts from my local maven repository.

For me it looks like the source artifacts are added twice:

Therefore my feature.xml is looking like this;

...
  <plugin id="com.example.artifact" download-size="0" install-size="0" version="4.0.0.SNAPSHOT" unpack="false" />
  <plugin id="com.example.artifact.source" download-size="0" install-size="0" version="4.0.0-SNAPSHOT" unpack="false" />
  <plugin id="com.example.artifact.source" download-size="0" install-size="0" version="4.0.0.SNAPSHOT" unpack="false" />
...

I have another example with an artifact that is already a bundle. Due to some misconfigurations the bundle version is not identical to the maven version. This will lead to the following:

...
  <plugin id="gsa-dataService-common" download-size="0" install-size="0" version="3.0.9.20151029122409" unpack="false" />
  <plugin id="gsa-dataService-common.source" download-size="0" install-size="0" version="3.0.9" unpack="false" />
  <plugin id="gsa-dataService-common.source" download-size="0" install-size="0" version="3.0.9.20151029122409" unpack="false" />
...

Funnily in the plugins dir the file there is only one file with the correct version in both cases.