Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
Fixed generated metadata in p2 repositories for source bundles
Browse files Browse the repository at this point in the history
the genereted provides-element now has the same type as repositores
built by p2. See org.eclipse.equinox.p2.publisher.eclipse.BundlesAction
vor details.

Signed-off-by: Veselin Markov <veselin_m84@yahoo.com>
  • Loading branch information
Veselin Markov committed Aug 18, 2018
1 parent 75826ff commit 1b9f9e6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;

import java.util.List;
Expand Down Expand Up @@ -144,6 +145,32 @@ public void platformFilterConvertedToFilter () throws Exception
assertThat ( iu.getFilter (), is ( platformFilter ) );
}

@Test
public void providesTypeBundle () throws Exception
{
final BundleInformation bi = new BundleInformation ();
bi.setSourceBunde ( false );
final P2MetaDataInformation p2info = new P2MetaDataInformation ();

final InstallableUnit iu = InstallableUnit.fromBundle ( bi, p2info );

assertThat ( iu, hasProvided ( "org.eclipse.equinox.p2.eclipse.type", "bundle", "1.0.0" ) );
assertThat ( iu, not ( hasProvided ( "org.eclipse.equinox.p2.eclipse.type", "source", "1.0.0" ) ) );
}

@Test
public void providesTypeSource () throws Exception
{
final BundleInformation bi = new BundleInformation ();
bi.setSourceBunde ( true );
final P2MetaDataInformation p2info = new P2MetaDataInformation ();

final InstallableUnit iu = InstallableUnit.fromBundle ( bi, p2info );

assertThat ( iu, hasProvided ( "org.eclipse.equinox.p2.eclipse.type", "source", "1.0.0" ) );
assertThat ( iu, not ( hasProvided ( "org.eclipse.equinox.p2.eclipse.type", "bundle", "1.0.0" ) ) );
}

static private final Matcher<InstallableUnit> hasProvided ( final String namespace, final String name, final String version )
{
return new CustomTypeSafeMatcher<InstallableUnit> ( "IU with 'provided'-element [namespace=" + namespace + ", name=" + name + ", version=" + version + " ]" ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,14 @@ public static InstallableUnit fromBundle ( final BundleInformation bundle, final

addProvides ( result, "osgi.bundle", bundle.getId (), "" + bundle.getVersion () );
addProvides ( result, "org.eclipse.equinox.p2.iu", bundle.getId (), "" + bundle.getVersion () );
addProvides ( result, "org.eclipse.equinox.p2.eclipse.type", "bundle", "1.0.0" );

if ( bundle.isSourceBundle () )
{
addProvides ( result, "org.eclipse.equinox.p2.eclipse.type", "source", "1.0.0" );
}
else
{
addProvides ( result, "org.eclipse.equinox.p2.eclipse.type", "bundle", "1.0.0" );
}
for ( final PackageExport pe : bundle.getPackageExports () )
{
addProvides ( result, "java.package", pe.getName (), makeVersion ( pe.getVersion () ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ public String getEffective ()

private String eclipsePlatformFilter;

private boolean sourceBundle;

public void setEclipseBundleShape ( final String eclipseBundleShape )
{
this.eclipseBundleShape = eclipseBundleShape;
Expand Down Expand Up @@ -656,4 +658,14 @@ public String toJson ()
{
return ParserHelper.newGson ().toJson ( this );
}

public void setSourceBunde ( final boolean source )
{
this.sourceBundle = source;
}

public boolean isSourceBundle ()
{
return this.sourceBundle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ else if ( this.file != null )

result.setRequiredExecutionEnvironments ( Headers.parseStringList ( ma.getValue ( Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT ) ) );
result.setEclipsePlatformFilter ( ma.getValue ( "Eclipse-PlatformFilter" ) );
result.setSourceBunde ( ma.getValue ( "Eclipse-SourceBundle" ) != null );

processImportPackage ( result, ma );
processExportPackage ( result, ma );
Expand Down

0 comments on commit 1b9f9e6

Please sign in to comment.