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 "Tycho/Nexus Unzip Plugin"

(Deploying the plug-in)
(Download)
(40 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''<font color="red">WARNING - EARLY DRAFT</font>''': this plugin is not released yet and docs are in early draft and probably not complete/ [https://bugs.eclipse.org/bugs/show_bug.cgi?id=398731 buggy]. If you want to try it, you will need to build the plugin yourself from [http://git.eclipse.org/c/tycho/org.eclipse.tycho.nexus.git/ source].
+
= Nexus Unzip Repository  =
  
<br>
+
== What is it ? ==
  
= Nexus Unzip Repository =
+
The Unzip Repository is a plugin for the [http://www.sonatype.org/nexus/ Nexus OSS] maven repository manager.<br/>
 +
It enables binary p2 artifact exchange between tycho projects via Nexus.
  
The Unzip Repository is a new Nexus repository type that shadows the build results of a standard Maven 2 repository and allows to browse into zip and jar artifacts. The use case is to offer p2 repositories that were built with Tycho packaging type <tt>eclipse-repository</tt> and deployed as zip to Nexus so that other Tycho projects can reference them.  
+
== How does it work ? ==
 +
 
 +
# The first tycho project ("producer") deploys a (zipped) p2 repository to nexus. It does this by simply using <tt>mvn deploy</tt> on a maven project with packaging type <tt>eclipse-repository</tt>
 +
# The second tycho project ("consumer") uses the p2 repository deployed by "producer". This is done using a special "unzip" URL providing an "unzipped view" on the zipped p2 repository
 +
 
 +
== Implementation Details ==
 +
 
 +
The Unzip Repository is a new Nexus repository type that shadows the build results of a standard Maven 2 repository and allows to browse into zip and jar artifacts.  
  
 
Example:  
 
Example:  
  
*p2 repo zip as artifact in Maven 2 Repository: <br><pre>http://&lt;NEXUS_HOST&gt;/nexus/content/repositories/public/org/example/demo/org.example.demo.repository/0.1.0/org.example.demo.repository-0.1.0.zip</pre>
+
*p2 repo zip as artifact in Maven 2 Repository:<br>
*Same artifact viewed as unzipped p2 repository using a virtual unzip repo named <tt>public.unzip</tt>:<br>
+
http&#58;//&lt;NEXUS_HOST&gt;/nexus/content/repositories/public/org/example/org.example.repository/0.1.0/org.example.repository-0.1.0-assembly.zip
<pre>http://&lt;NEXUS_HOST&gt;/nexus/content/repositories/public.unzip/org/example/demo/org.example.demo.repository/0.1.0/org.example.demo.repository-0.1.0.zip-unzip</pre>  
+
*Same artifact viewed as unzipped p2 repository using a virtual unzip repo named <tt>public.unzip</tt>:
<br>
+
http&#58;//&lt;NEXUS_HOST&gt;/nexus/content/repositories/'''<font color="red">public.unzip</font>'''/org/example/org.example.repository/0.1.0/org.example.repository-0.1.0-assembly.zip'''<font color="red">-unzip</font>'''
 +
 
 +
{{warning|"Unzip" URLs of redeployable artifacts (e.g. snapshots) cannot be used while the artifact is redeployed!|The current implementation does not guarantee that you find valid content under the "unzip" URL of such artifacts while they are redeployed. Take care to not access those URLs during redeployment.}}
  
 
== Installation and Configuration  ==
 
== Installation and Configuration  ==
  
=== Prerequisites ===
+
=== Prerequisites ===
  
The Nexus Unzip Repository Plugin requires [http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.sonatype.nexus%22%20AND%20a%3A%22nexus-oss-webapp%22%20 Nexus OSS >= 2.3.0] installed
+
Nexus Unzip Repository Plugin 0.13.0 requires [http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22nexus-bundle-template%22 Nexus OSS version 2.7.x] installed (NOTE it does not currently work with nexus 2.8.x, see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=432793 bug 432793]) .
  
=== Deploying the plug-in  ===
+
=== Download ===
  
 +
Get the nexus unzip-repository-plugin version 0.13.0 from [http://repo1.maven.org/maven2/org/eclipse/tycho/nexus/unzip-repository-plugin/0.13.0/unzip-repository-plugin-0.13.0-bundle.zip maven central].
  
To enable a Nexus server to provide direct access to files inside zip/jar archives you need to deploy the Nexus Unzip Repository Plugin to the Nexus server instance and configure a new virtual repository using the Unzip Repository type.
+
=== Deploying the plug-in  ===
 +
 
 +
To enable a Nexus server to provide direct access to files inside zip/jar archives, you need to deploy the Nexus Unzip Repository Plugin to the Nexus server instance and configure a new virtual repository using the Unzip Repository type.  
  
 
#Stop the Nexus instance  
 
#Stop the Nexus instance  
#Navigate to the plugin repository in the work dir <tt>${NEXUS_WORK}/nexus/plugin-repository</tt>
+
#Unzip the <tt>unzip-repository-plugin-&lt;VERSION&gt;-bundle.zip</tt> into <tt>${NEXUS_WORK}/plugin-repository/</tt> folder  
#Unzip the <tt>unzip-repository-plugin-&lt;VERSION&gt;-bundle.zip</tt> into the <tt>plugin-repository/</tt> folder  
+
 
#Restart the Nexus server  
 
#Restart the Nexus server  
#Verify that the Unzip Repository Plugin is activated, by opening the Plugin Console from the Administration sub-menu of the Nexus UI
+
#To verify that the Unzip Repository Plugin is activated, open the Plugin Console from the Administration sub-menu of the Nexus UI
  
 
=== Configuring an unzip repository (using hosted/proxy/virtual repo as master)  ===
 
=== Configuring an unzip repository (using hosted/proxy/virtual repo as master)  ===
Line 39: Line 51:
 
#Choose the Repositories View from the side menu  
 
#Choose the Repositories View from the side menu  
 
#Open the Add menu and choose Virtual Repository. The detail view below the repository list opens a form to specify further repository configuration.  
 
#Open the Add menu and choose Virtual Repository. The detail view below the repository list opens a form to specify further repository configuration.  
#Enter a unique repository ID and choose a (display) name. You cannot alter the repository type.
+
#Enter a unique repository ID and choose a (display) name
#Choose <tt>Unzip Repository Template</tt> as the repository provider. The repository format is fixed.
+
#Choose <tt>Unzip Repository Template</tt> as the repository provider
#Select the intended repository from the list of the source nexus repositories  
+
#Select the intended repository from the list of the source nexus repositories (see below if you want to configure a group as source repository)
 
#Save the repository config  
 
#Save the repository config  
#To verify the setup of the unzip repository, you can now select the repository from the repository list and start browsing the folders *and* into archives that you have deployed into the previously selected master repository. You can also open the URL given in the Repository Path column to browse in the standard web browser.
+
#To verify the setup of the unzip repository, you can now select the repository from the repository list and start browsing the folders '''and''' into archives that you have deployed into the previously selected master repository. You can also open the URL given in the Repository Path column to browse in the standard web browser.
  
 
=== Configuring a group as master for the unzip repository  ===
 
=== Configuring a group as master for the unzip repository  ===
  
All groups and repositories configuration are stored in the nexus.xml config file in the Nexus work folder. You need to edit this directly in a text editor to configure a group as master.  
+
All groups and repositories configuration are stored in the nexus.xml config file in the Nexus work folder. Due to a limitation of the configuration web UI, you currently have to edit this file directly in a text editor in order to configure a group repository as master.  
  
 
#Stop Nexus  
 
#Stop Nexus  
 
#Open <tt>${NEXUS_WORK}/conf/nexus.xml</tt>  
 
#Open <tt>${NEXUS_WORK}/conf/nexus.xml</tt>  
 
#Add a new repository element with following structure
 
#Add a new repository element with following structure
<pre>&lt;repository&gt;
+
&lt;repository&gt;
      &lt;id&gt;master.group.unzip&lt;/id&gt;
+
  &lt;id&gt;master.group.unzip&lt;/id&gt;
      &lt;name&gt;Group Unzip&lt;/name&gt;
+
  &lt;name&gt;Group Unzip&lt;/name&gt;
      &lt;providerRole&gt;org.sonatype.nexus.proxy.repository.ShadowRepository&lt;/providerRole&gt;
+
  &lt;providerRole&gt;org.eclipse.tycho.nexus.internal.plugin.UnzipRepository&lt;/providerRole&gt;
      &lt;providerHint&gt;org.eclipse.tycho.nexus.plugin.DefaultUnzipRepository&lt;/providerHint&gt;
+
  &lt;providerHint&gt;org.eclipse.tycho.nexus.plugin.DefaultUnzipRepository&lt;/providerHint&gt;
      &lt;localStatus&gt;IN_SERVICE&lt;/localStatus&gt;
+
  &lt;localStatus&gt;IN_SERVICE&lt;/localStatus&gt;
      &lt;notFoundCacheActive&gt;true&lt;/notFoundCacheActive&gt;
+
  &lt;notFoundCacheActive&gt;true&lt;/notFoundCacheActive&gt;
      &lt;notFoundCacheTTL&gt;15&lt;/notFoundCacheTTL&gt;
+
  &lt;notFoundCacheTTL&gt;15&lt;/notFoundCacheTTL&gt;
      &lt;userManaged&gt;true&lt;/userManaged&gt;
+
  &lt;userManaged&gt;true&lt;/userManaged&gt;
      &lt;exposed&gt;true&lt;/exposed&gt;
+
  &lt;exposed&gt;true&lt;/exposed&gt;
      &lt;browseable&gt;true&lt;/browseable&gt;
+
  &lt;browseable&gt;true&lt;/browseable&gt;
      &lt;writePolicy&gt;READ_ONLY&lt;/writePolicy&gt;
+
  &lt;writePolicy&gt;READ_ONLY&lt;/writePolicy&gt;
      &lt;searchable&gt;true&lt;/searchable&gt;
+
  &lt;searchable&gt;true&lt;/searchable&gt;
      &lt;localStorage&gt;
+
  &lt;localStorage&gt;
        &lt;provider&gt;file&lt;/provider&gt;
+
    &lt;provider&gt;file&lt;/provider&gt;
      &lt;/localStorage&gt;
+
  &lt;/localStorage&gt;
      &lt;externalConfiguration&gt;
+
  &lt;externalConfiguration&gt;
        &lt;masterRepositoryId&gt;master.group&lt;/masterRepositoryId&gt;
+
    &lt;masterRepositoryId&gt;public&lt;/masterRepositoryId&gt;
        &lt;synchronizeAtStartup&gt;false&lt;/synchronizeAtStartup&gt;
+
    &lt;useVirtualVersion&gt;true&lt;/useVirtualVersion&gt;
        &lt;useVirtualVersion&gt;true&lt;/useVirtualVersion&gt;
+
    &lt;synchronizeAtStartup&gt;false&lt;/synchronizeAtStartup&gt;
      &lt;/externalConfiguration&gt;
+
  &lt;/externalConfiguration&gt;
    &lt;/repository&gt;
+
&lt;/repository&gt;
</pre>
+
Note that you specify the repository id (not the name) of the group in the <tt>masterRepositoryId</tt> element. <br>4. Restart Nexus
Note that you write the repository id (not the name) of the group in the <tt>masterRepositoryId</tt> element. <br>4. Restart Nexus  
+
 
 +
<span id="Virtual versions">
 +
=== Enabling virtual versions SNAPSHOT and RELEASE  ===
 +
 
 +
Especially for <tt>SNAPSHOT</tt> versions, it's generally useful to be able to reference the latest SNAPSHOT version of a p2 repository without having to specify the actual timestamp of the latest SNAPSHOT<br>
 +
http&#58;//&lt;NEXUS_HOST&gt;/nexus/content/repositories/public.unzip/org/example/org.example.repository/0.1.0-SNAPSHOT/org.example.repository-0.1.0'''<font color="red">-SNAPSHOT</font>'''-assembly.zip-unzip
 +
 
 +
Again due to a limitation of the configuration web UI, you currently have to manually edit <tt>${NEXUS_WORK}/conf/nexus.xml</tt>.
 +
To enable virtual SNAPSHOT version expansion, configure '''useVirtualVersion=true''' in <tt>${NEXUS_WORK}/conf/nexus.xml</tt> and restart nexus. For example:
 +
&lt;repository&gt;
 +
  &lt;id&gt;master.group.unzip&lt;/id&gt;
 +
  &lt;name&gt;Group Unzip&lt;/name&gt;
 +
  &lt;providerRole&gt;org.eclipse.tycho.nexus.internal.plugin.UnzipRepository&lt;/providerRole&gt;
 +
  &lt;providerHint&gt;org.eclipse.tycho.nexus.plugin.DefaultUnzipRepository&lt;/providerHint&gt;
 +
  &lt;localStatus&gt;IN_SERVICE&lt;/localStatus&gt;
 +
  &lt;notFoundCacheActive&gt;true&lt;/notFoundCacheActive&gt;
 +
  &lt;notFoundCacheTTL&gt;15&lt;/notFoundCacheTTL&gt;
 +
  &lt;userManaged&gt;true&lt;/userManaged&gt;
 +
  &lt;exposed&gt;true&lt;/exposed&gt;
 +
  &lt;browseable&gt;true&lt;/browseable&gt;
 +
  &lt;writePolicy&gt;READ_ONLY&lt;/writePolicy&gt;
 +
  &lt;searchable&gt;true&lt;/searchable&gt;
 +
  &lt;localStorage&gt;
 +
    &lt;provider&gt;file&lt;/provider&gt;
 +
  &lt;/localStorage&gt;
 +
  &lt;externalConfiguration&gt;
 +
    &lt;masterRepositoryId&gt;public&lt;/masterRepositoryId&gt;
 +
    &lt;useVirtualVersion&gt;'''<font color="red">true</font>'''&lt;/useVirtualVersion&gt;
 +
    &lt;synchronizeAtStartup&gt;false&lt;/synchronizeAtStartup&gt;
 +
  &lt;/externalConfiguration&gt;
 +
&lt;/repository&gt;
 +
</span>
 +
 
 +
== Contributing ==
 +
 
 +
The project source code is hosted at [http://git.eclipse.org/c/tycho/org.eclipse.tycho.nexus.git/ eclipse] with the Tycho project. You can also fork it on [https://github.com/eclipse/tycho.nexus github].
 +
See [[Tycho/Contributor Guide]] for details on how to contribute.
  
[[Category:Tycho]]
+
[[Category:Tycho|Nexus Unzip Plugin]]

Revision as of 05:33, 15 April 2014

Nexus Unzip Repository

What is it ?

The Unzip Repository is a plugin for the Nexus OSS maven repository manager.
It enables binary p2 artifact exchange between tycho projects via Nexus.

How does it work ?

  1. The first tycho project ("producer") deploys a (zipped) p2 repository to nexus. It does this by simply using mvn deploy on a maven project with packaging type eclipse-repository
  2. The second tycho project ("consumer") uses the p2 repository deployed by "producer". This is done using a special "unzip" URL providing an "unzipped view" on the zipped p2 repository

Implementation Details

The Unzip Repository is a new Nexus repository type that shadows the build results of a standard Maven 2 repository and allows to browse into zip and jar artifacts.

Example:

  • p2 repo zip as artifact in Maven 2 Repository:
http://<NEXUS_HOST>/nexus/content/repositories/public/org/example/org.example.repository/0.1.0/org.example.repository-0.1.0-assembly.zip
  • Same artifact viewed as unzipped p2 repository using a virtual unzip repo named public.unzip:
http://<NEXUS_HOST>/nexus/content/repositories/public.unzip/org/example/org.example.repository/0.1.0/org.example.repository-0.1.0-assembly.zip-unzip
Warning2.png
"Unzip" URLs of redeployable artifacts (e.g. snapshots) cannot be used while the artifact is redeployed!
The current implementation does not guarantee that you find valid content under the "unzip" URL of such artifacts while they are redeployed. Take care to not access those URLs during redeployment.


Installation and Configuration

Prerequisites

Nexus Unzip Repository Plugin 0.13.0 requires Nexus OSS version 2.7.x installed (NOTE it does not currently work with nexus 2.8.x, see bug 432793) .

Download

Get the nexus unzip-repository-plugin version 0.13.0 from maven central.

Deploying the plug-in

To enable a Nexus server to provide direct access to files inside zip/jar archives, you need to deploy the Nexus Unzip Repository Plugin to the Nexus server instance and configure a new virtual repository using the Unzip Repository type.

  1. Stop the Nexus instance
  2. Unzip the unzip-repository-plugin-<VERSION>-bundle.zip into ${NEXUS_WORK}/plugin-repository/ folder
  3. Restart the Nexus server
  4. To verify that the Unzip Repository Plugin is activated, open the Plugin Console from the Administration sub-menu of the Nexus UI

Configuring an unzip repository (using hosted/proxy/virtual repo as master)

WARNING: Using the Nexus Web UI you can only assign hosted, proxy and virtual repositories as the master repository. To configure a group as the used master , you need to configure it directly in the configuration file on the Nexus host machine. Details in the section below.

  1. Open the Nexus Web UI
  2. Login with your administrative user
  3. Choose the Repositories View from the side menu
  4. Open the Add menu and choose Virtual Repository. The detail view below the repository list opens a form to specify further repository configuration.
  5. Enter a unique repository ID and choose a (display) name
  6. Choose Unzip Repository Template as the repository provider
  7. Select the intended repository from the list of the source nexus repositories (see below if you want to configure a group as source repository)
  8. Save the repository config
  9. To verify the setup of the unzip repository, you can now select the repository from the repository list and start browsing the folders and into archives that you have deployed into the previously selected master repository. You can also open the URL given in the Repository Path column to browse in the standard web browser.

Configuring a group as master for the unzip repository

All groups and repositories configuration are stored in the nexus.xml config file in the Nexus work folder. Due to a limitation of the configuration web UI, you currently have to edit this file directly in a text editor in order to configure a group repository as master.

  1. Stop Nexus
  2. Open ${NEXUS_WORK}/conf/nexus.xml
  3. Add a new repository element with following structure
<repository>
  <id>master.group.unzip</id>
  <name>Group Unzip</name>
  <providerRole>org.eclipse.tycho.nexus.internal.plugin.UnzipRepository</providerRole>
  <providerHint>org.eclipse.tycho.nexus.plugin.DefaultUnzipRepository</providerHint>
  <localStatus>IN_SERVICE</localStatus>
  <notFoundCacheActive>true</notFoundCacheActive>
  <notFoundCacheTTL>15</notFoundCacheTTL>
  <userManaged>true</userManaged>
  <exposed>true</exposed>
  <browseable>true</browseable>
  <writePolicy>READ_ONLY</writePolicy>
  <searchable>true</searchable>
  <localStorage>
    <provider>file</provider>
  </localStorage>
  <externalConfiguration>
    <masterRepositoryId>public</masterRepositoryId>
    <useVirtualVersion>true</useVirtualVersion>
    <synchronizeAtStartup>false</synchronizeAtStartup>
  </externalConfiguration>
</repository>

Note that you specify the repository id (not the name) of the group in the masterRepositoryId element.
4. Restart Nexus

Enabling virtual versions SNAPSHOT and RELEASE

Especially for SNAPSHOT versions, it's generally useful to be able to reference the latest SNAPSHOT version of a p2 repository without having to specify the actual timestamp of the latest SNAPSHOT

http://<NEXUS_HOST>/nexus/content/repositories/public.unzip/org/example/org.example.repository/0.1.0-SNAPSHOT/org.example.repository-0.1.0-SNAPSHOT-assembly.zip-unzip

Again due to a limitation of the configuration web UI, you currently have to manually edit ${NEXUS_WORK}/conf/nexus.xml. To enable virtual SNAPSHOT version expansion, configure useVirtualVersion=true in ${NEXUS_WORK}/conf/nexus.xml and restart nexus. For example:

<repository>
  <id>master.group.unzip</id>
  <name>Group Unzip</name>
  <providerRole>org.eclipse.tycho.nexus.internal.plugin.UnzipRepository</providerRole>
  <providerHint>org.eclipse.tycho.nexus.plugin.DefaultUnzipRepository</providerHint>
  <localStatus>IN_SERVICE</localStatus>
  <notFoundCacheActive>true</notFoundCacheActive>
  <notFoundCacheTTL>15</notFoundCacheTTL>
  <userManaged>true</userManaged>
  <exposed>true</exposed>
  <browseable>true</browseable>
  <writePolicy>READ_ONLY</writePolicy>
  <searchable>true</searchable>
  <localStorage>
    <provider>file</provider>
  </localStorage>
  <externalConfiguration>
    <masterRepositoryId>public</masterRepositoryId>
    <useVirtualVersion>true</useVirtualVersion>
    <synchronizeAtStartup>false</synchronizeAtStartup>
  </externalConfiguration>
</repository>

Contributing

The project source code is hosted at eclipse with the Tycho project. You can also fork it on github. See Tycho/Contributor Guide for details on how to contribute.

Back to the top