refactored to publish zipped catalog

Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
diff --git a/org.eclipse.m2e.discovery.oss/pom.xml b/org.eclipse.m2e.discovery.oss/pom.xml
index b5b02f0..cd0e38a 100644
--- a/org.eclipse.m2e.discovery.oss/pom.xml
+++ b/org.eclipse.m2e.discovery.oss/pom.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <parent>
     <groupId>org.eclipse.m2e</groupId>
     <artifactId>org.eclipse.m2e.discovery-directory</artifactId>
@@ -9,12 +10,25 @@
 
   <artifactId>org.eclipse.m2e.discovery.oss</artifactId>
   <packaging>jar</packaging>
+  
+  <!-- 
+   Here is what happens here
+   
+   1. discovery.publisher.maven-plugin generates p2 repository and catalog jar
+   2. assembly-plugin creates zip file with p2 repository and catalog jar
+   3. zip file is uploaded to special "compressed" nexus url
+   4. nexus cleans desination directory and unzips everything there
+
+   This assumes nexus-pro with nexus-unpack-plugin  
+   -->
 
   <properties>
-    <!-- 
-    <m2e.marketplace.repositoryUrl>https://repository.sonatype.org/content/sites/forge-sites/m2e-marketplace-p2-repo</m2e.marketplace.repositoryUrl>
-    -->
-    <m2e.marketplace.repositoryUrl>http://localhost:8081/nexus/content/sites/xx/m2e-marketplace-p2-repo</m2e.marketplace.repositoryUrl>
+    <catalog.server-url>https://repository.sonatype.org</catalog.server-url>
+    <catalog.repo-name>forge-sites</catalog.repo-name>
+
+    <catalog.repo-path>m2e-discovery-catalog</catalog.repo-path>
+    <catalog.repo-url-compressed>${catalog.server-url}/service/local/repositories/${catalog.repo-name}/content-compressed</catalog.repo-url-compressed>
+    <catalog.repo-url>${catalog.server-url}/nexus/content/sites/${catalog.repo-name}</catalog.repo-url>
   </properties>
 
   <build>
@@ -30,7 +44,7 @@
         </includes>
       </resource>
     </resources>
-     
+
     <plugins>
       <plugin>
         <groupId>org.sonatype.m2e.discovery.publisher</groupId>
@@ -43,13 +57,34 @@
               <goal>generate</goal>
             </goals>
             <configuration>
-              <p2RepositoryUrl>${m2e.marketplace.repositoryUrl}</p2RepositoryUrl>
+              <p2RepositoryUrl>${catalog.repo-url}</p2RepositoryUrl>
             </configuration>
           </execution>
         </executions>
       </plugin>
+
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptors>
+            <descriptor>src/main/assembly/assembly.xml</descriptor>
+          </descriptors>
+        </configuration>
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+
     </plugins>
-    
+
     <pluginManagement>
       <plugins>
         <!-- This plugin's configuration is used in m2e only.-->
@@ -71,7 +106,7 @@
                   </pluginExecutionFilter>
                   <action>
                     <!-- org.sonatype.m2e.discovery.publisher.maven-plugin uses an Equinox instance, so it cannot be executed from within eclipse -->
-                    <ignore/>
+                    <ignore />
                   </action>
                 </pluginExecution>
               </pluginExecutions>
@@ -94,33 +129,15 @@
             <executions>
               <execution>
                 <id>deploy-p2-repository</id>
-                <phase>deploy</phase>
+                <phase>install</phase>
                 <goals>
-                  <goal>upload-files</goal>
+                  <goal>upload-file</goal>
                 </goals>
                 <configuration>
-                  <basedir>${project.build.directory}/p2repository/</basedir>
-                  <includes>
-                    <include>**</include>
-                  </includes>
+                  <file>${project.build.directory}/${project.artifactId}-${project.version}-catalog.zip</file>
                   <serverId>forge-releases</serverId>
-                  <repositoryUrl>${m2e.marketplace.repositoryUrl}</repositoryUrl>
-                </configuration>
-              </execution>
-
-              <execution>
-                <id>deploy-discovery-catalog</id>
-                <phase>deploy</phase>
-                <goals>
-                  <goal>upload-files</goal>
-                </goals>
-                <configuration>
-                  <basedir>${project.build.directory}</basedir>
-                  <includes>
-                    <include>org.eclipse.m2e.discovery.oss-1.0.0-SNAPSHOT.jar</include>
-                  </includes>
-                  <serverId>forge-releases</serverId>
-                  <repositoryUrl>${m2e.marketplace.repositoryUrl}</repositoryUrl>
+                  <repositoryUrl>${catalog.repo-url-compressed}</repositoryUrl>
+                  <repositoryPath>${catalog.repo-path}</repositoryPath>
                 </configuration>
               </execution>
             </executions>
@@ -128,5 +145,13 @@
         </plugins>
       </build>
     </profile>
+    
+    <profile>
+      <id>local-nexus</id>
+      <properties>
+        <catalog.server-url>http://localhost:8081/nexus</catalog.server-url>
+        <catalog.repo-name>xx</catalog.repo-name>
+      </properties>
+    </profile>
   </profiles>
 </project>
\ No newline at end of file
diff --git a/org.eclipse.m2e.discovery.oss/src/main/assembly/assembly.xml b/org.eclipse.m2e.discovery.oss/src/main/assembly/assembly.xml
new file mode 100644
index 0000000..58e7d0d
--- /dev/null
+++ b/org.eclipse.m2e.discovery.oss/src/main/assembly/assembly.xml
@@ -0,0 +1,22 @@
+<assembly>
+  <id>catalog</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>${project.build.directory}/p2repository</directory>
+      <outputDirectory>/</outputDirectory>
+    </fileSet>
+    <fileSet>
+      <directory>${project.build.directory}</directory>
+      <includes>
+        <include>${project.artifactId}-${project.version}.jar</include>
+      </includes>
+      <outputDirectory>/</outputDirectory>
+    </fileSet>
+  </fileSets>
+
+</assembly>
+
diff --git a/pom.xml b/pom.xml
index 5d71d7c..a571eda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,31 +17,6 @@
     -->
   </modules>
 
-
-<!-- 
-  <distributionManagement>
-    <repository>
-      <id>forge-releases</id>
-      <url>http://repository.sonatype.org:8081/service/local/staging/deploy/maven2</url>
-    </repository>
-    <snapshotRepository>
-      <id>forge-snapshots</id>
-      <url>http://repository.sonatype.org/content/repositories/snapshots</url>
-    </snapshotRepository>
-  </distributionManagement>
--->
-
-  <distributionManagement>
-    <repository>
-      <id>forge-releases</id>
-      <url>http://localhost:8081/nexus/service/local/staging/deploy/maven2</url>
-    </repository>
-    <snapshotRepository>
-      <id>forge-snapshots</id>
-      <url>http://localhost:8081/nexus/content/repositories/snapshots</url>
-    </snapshotRepository>
-  </distributionManagement>
-
   <properties>
     <tycho-version>0.11.0</tycho-version>
 
@@ -49,15 +24,6 @@
   </properties>
 
   <build>
-    <extensions>
-      <extension>
-        <groupId>org.apache.maven.wagon</groupId>
-        <artifactId>wagon-ssh-external</artifactId>
-        <version>1.0-beta-7</version>
-      </extension>
-    </extensions>
-    <plugins>
-    </plugins>
     <pluginManagement>
       <plugins>
         <plugin>