Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "PDE/UI/SourceReferences"

< PDE‎ | UI
(Extensibility: Generating and Importing Source Reference Headers)
(Add info on generating headers with Tycho)
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Eclipse Source Reference Headers ==
 
== Eclipse Source Reference Headers ==
  
During 3.6, PDE introduced the '''Eclipse-SourceReferences''' header to bundle manifests. The header provides a list of [http://maven.apache.org/scm/scm-url-format.html SCMURLs] that reference the source code associated with a binary bundle. PDE build has extensible support for generating headers and tooling in the IDE provides support to import projects into the workspace corresponding to binary bundles. Often a bundle has only one SCMURL associated with it. For example, following is a header included in the "org.eclipse.debug.ui" bundle from the 3.6 M7 build:
+
During 3.6, PDE introduced '''Eclipse-SourceReferences''' headers to bundle manifests. The header provides a list of [http://maven.apache.org/scm/scm-url-format.html SCMURLs] that reference the source code associated with a binary bundle. PDE build has extensible support for generating source reference headers and the IDE supports importing projects into the workspace corresponding to headers. Usually a bundle has only one SCMURL associated with it. For example, following is a header included in the "org.eclipse.debug.ui" bundle from the 3.6 M7 build:
  
 
<code>Eclipse-SourceReferences: scm:cvs:pserver:dev.eclipse.org:/cvsroot/eclipse:org.eclipse.debug.core;tag=v20100427</code>
 
<code>Eclipse-SourceReferences: scm:cvs:pserver:dev.eclipse.org:/cvsroot/eclipse:org.eclipse.debug.core;tag=v20100427</code>
 +
 +
Support to generate headers and import from different repositories is extensible. The Eclipse SDK provides support for CVS.
  
 
== Importing Projects from CVS ==
 
== Importing Projects from CVS ==
Line 15: Line 17:
 
[[Image:Repo-import-2.png]]
 
[[Image:Repo-import-2.png]]
  
The last page of the wizard allows you to import the specific versions of the projects that were used in the build or from HEAD. For this example, I will choose HEAD. Pressing '''Finish''' imports the projects into the workspace.
+
The last page of the wizard allows you to import the specific versions of the projects that were used in the build or from HEAD. For this example, I will choose HEAD. Pressing '''Finish''' imports the projects into the workspace, connected to the CVS repository.
  
 
[[Image:Repo-import-3.png]]
 
[[Image:Repo-import-3.png]]
Line 33: Line 35:
 
PDE provides two new '''experimental / internal''' extension points to support import operations in the SDK:
 
PDE provides two new '''experimental / internal''' extension points to support import operations in the SDK:
  
* org.eclipse.pde.core.bundleImporters - A bundle importer is capable of creating a project in the workspace based on specific entries contained in a bundle manifest (implements '''org.eclipse.pde.internal.core.importing.provisional.IBundleImporterDelegate''').
+
* ''org.eclipse.pde.core.bundleImporters'' - A bundle importer is capable of creating a project in the workspace based on specific entries contained in a bundle manifest (implements '''org.eclipse.pde.internal.core.importing.provisional.IBundleImporterDelegate'''). A bundle importer is provided with the manifest (map of header value pairs) of each bundle. For each bundle that the importer supports, it creates and returns a bundle import description (org.eclipse.pde.internal.core.importing.provisional.BundleImportDescription).
* org.eclipse.pde.ui.bundleImportPages - A bundle import page provides a wizard page used in the Plug-in import wizard to configure settings for bundles to be imported by a bundle importer extension (implements org.eclipse.pde.internal.ui.provisional.IBundeImportWizardPage).
+
* ''org.eclipse.pde.ui.bundleImportPages'' - A bundle import page provides a wizard page used in the Plug-in import wizard to configure settings for bundles to be imported by a bundle importer extension (implements '''org.eclipse.pde.internal.ui.provisional.IBundeImportWizardPage'''). The page is provided with any bundle import descriptions associated with bundles the user has selected for import. The page can then modify/annotate/further restrict the bundle import descriptions. The resulting importing descriptions are passed to the bundle importer when finish is pressed.
 +
 
 +
Since the extension points are experimental for the 3.6 release, the interfaces implemented by the extensions are in the internal (non-API) namespace. The SDK provides implemtations of all three extensions for CVS. For example, the CVS bundle import page adds information to bundle import descriptions if the user decides to import from HEAD.
 +
 
 +
=== Generating Source Reference Headers with Tycho ===
 +
 
 +
Source reference headers can also be generated with Tycho with [https://www.eclipse.org/tycho/sitedocs/tycho-packaging-plugin/package-plugin-mojo.html tycho-packaging:package-plugin].
 +
 
 +
For example, if a project is located in Eclipse's Git repos add a property with the SCM URL like this:
 +
 
 +
<pre>
 +
    &lt;properties&gt;
 +
        &lt;tycho.scmUrl&gt;scm:git:git://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git&lt;/tycho.scmUrl&gt;
 +
    &lt;/properties&gt;
 +
</pre>
 +
 
 +
For a repository located on GitHub the equivalent property would look like:
 +
<pre>
 +
    &lt;properties&gt;
 +
        &lt;tycho.scmUrl&gt;scm:git:https://github.com/eclipse/january.git&lt;/tycho.scmUrl&gt;
 +
    &lt;/properties&gt;
 +
</pre>
 +
 
 +
Then add the packaging plug-in to the build:
 +
 
 +
<pre>
 +
    &lt;build&gt;
 +
        &lt;plugins&gt;
 +
            &lt;plugin&gt;
 +
                &lt;groupId&gt;org.eclipse.tycho&lt;/groupId&gt;
 +
                &lt;artifactId&gt;tycho-packaging-plugin&lt;/artifactId&gt;
 +
                &lt;version&gt;${tycho-version}&lt;/version&gt;
 +
                &lt;dependencies&gt;
 +
                    &lt;!-- Use jgit to resolve source references for git: type SCM --&gt;
 +
                    &lt;dependency&gt;
 +
                        &lt;groupId&gt;org.eclipse.tycho.extras&lt;/groupId&gt;
 +
                        &lt;artifactId&gt;tycho-sourceref-jgit&lt;/artifactId&gt;
 +
                        &lt;version&gt;${tycho-extras-version}&lt;/version&gt;
 +
                    &lt;/dependency&gt;
 +
                &lt;/dependencies&gt;
 +
                &lt;configuration&gt;
 +
                    &lt;sourceReferences&gt;
 +
                        &lt;-- Generate the source reference in the MANIFEST.MF --&gt;
 +
                        &lt;generate&gt;true&lt;/generate&gt;
 +
                    &lt;/sourceReferences&gt;
 +
                &lt;/configuration&gt;
 +
            &lt;/plugin&gt;
 +
        &lt;/plugins&gt;
 +
    &lt;/build&gt;
 +
</pre>
 +
 
  
Since the extension points are experimental for the 3.6 release, the interfaces implemented by the extensions are in the internal (non-API) namespace.
+
[[Category:PDE]][[Category:PDE/Build|Source References]]

Revision as of 13:53, 24 February 2017

Eclipse Source Reference Headers

During 3.6, PDE introduced Eclipse-SourceReferences headers to bundle manifests. The header provides a list of SCMURLs that reference the source code associated with a binary bundle. PDE build has extensible support for generating source reference headers and the IDE supports importing projects into the workspace corresponding to headers. Usually a bundle has only one SCMURL associated with it. For example, following is a header included in the "org.eclipse.debug.ui" bundle from the 3.6 M7 build:

Eclipse-SourceReferences: scm:cvs:pserver:dev.eclipse.org:/cvsroot/eclipse:org.eclipse.debug.core;tag=v20100427

Support to generate headers and import from different repositories is extensible. The Eclipse SDK provides support for CVS.

Importing Projects from CVS

The SCMURLs generated in the Eclipse SDK refer to projects in the Eclipse CVS repository. To import projects from CVS use PDE's import wizard (use the File > Import action and select Plug-in Development > Plug-ins and Fragments on the first page of the import wizard). For this example, we'll import from the active target platform. Choose the Projects from a repository radio button at the bottom of the wizard page and press Next.

Repo-import-1.png

All bundles with published SCMURLs will be available for importing. Select the bundles you want to import, and press Next. For this example, I have selected bundles related to the debug platform.

Repo-import-2.png

The last page of the wizard allows you to import the specific versions of the projects that were used in the build or from HEAD. For this example, I will choose HEAD. Pressing Finish imports the projects into the workspace, connected to the CVS repository.

Repo-import-3.png

Extensibility: Generating and Importing Source Reference Headers

PDE build optionally generates source reference headers during a build. This feature is turned on by specifying the following property:

generateSourceReferences = true

The headers themselves are generated by fetch factories. PDE build uses fetch factories to fetch source code from repositories (there is an org.eclipse.pde.build.fetchFactories extension point). Each repository (CVS, etc.), provides a specific implementation of an IFetchFactory. To include source reference headers a fetch factory must provide a KEY_SOURCE_REFERENCES property when parsing a map file entry, in the implementation of parseMapFileEntry(String, Properties, Map).

For example, the CVS fetch factory implementation sets a {key, value} pair in the map for each project being fetched, like:

{"sourceReferences", "Eclipse-SourceReferences: scm:cvs:pserver:dev.eclipse.org:/cvsroot/eclipse:org.eclipse.debug.core;tag=v20100427"}

PDE provides two new experimental / internal extension points to support import operations in the SDK:

  • org.eclipse.pde.core.bundleImporters - A bundle importer is capable of creating a project in the workspace based on specific entries contained in a bundle manifest (implements org.eclipse.pde.internal.core.importing.provisional.IBundleImporterDelegate). A bundle importer is provided with the manifest (map of header value pairs) of each bundle. For each bundle that the importer supports, it creates and returns a bundle import description (org.eclipse.pde.internal.core.importing.provisional.BundleImportDescription).
  • org.eclipse.pde.ui.bundleImportPages - A bundle import page provides a wizard page used in the Plug-in import wizard to configure settings for bundles to be imported by a bundle importer extension (implements org.eclipse.pde.internal.ui.provisional.IBundeImportWizardPage). The page is provided with any bundle import descriptions associated with bundles the user has selected for import. The page can then modify/annotate/further restrict the bundle import descriptions. The resulting importing descriptions are passed to the bundle importer when finish is pressed.

Since the extension points are experimental for the 3.6 release, the interfaces implemented by the extensions are in the internal (non-API) namespace. The SDK provides implemtations of all three extensions for CVS. For example, the CVS bundle import page adds information to bundle import descriptions if the user decides to import from HEAD.

Generating Source Reference Headers with Tycho

Source reference headers can also be generated with Tycho with tycho-packaging:package-plugin.

For example, if a project is located in Eclipse's Git repos add a property with the SCM URL like this:

    <properties>
        <tycho.scmUrl>scm:git:git://git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git</tycho.scmUrl>
    </properties>

For a repository located on GitHub the equivalent property would look like:

    <properties>
        <tycho.scmUrl>scm:git:https://github.com/eclipse/january.git</tycho.scmUrl>
    </properties>

Then add the packaging plug-in to the build:

    <build>
        <plugins>
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-packaging-plugin</artifactId>
                <version>${tycho-version}</version>
                <dependencies>
                    <!-- Use jgit to resolve source references for git: type SCM -->
                    <dependency>
                        <groupId>org.eclipse.tycho.extras</groupId>
                        <artifactId>tycho-sourceref-jgit</artifactId>
                        <version>${tycho-extras-version}</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <sourceReferences>
                        <-- Generate the source reference in the MANIFEST.MF -->
                        <generate>true</generate>
                    </sourceReferences>
                </configuration>
            </plugin>
        </plugins>
    </build>

Back to the top