You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by mc...@apache.org on 2008/08/02 20:47:46 UTC

svn commit: r682034 - in /felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin: ObrDeploy.java ObrRemoteClean.java

Author: mcculls
Date: Sat Aug  2 11:47:46 2008
New Revision: 682034

URL: http://svn.apache.org/viewvc?rev=682034&view=rev
Log:
FELIX-580: support deployment of OBR metadata using prefixed URLs (-DprefixUrl=http://...) or absolute URLs (-DbundleUrl=http://...)

Modified:
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
    felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrRemoteClean.java

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java?rev=682034&r1=682033&r2=682034&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrDeploy.java Sat Aug  2 11:47:46 2008
@@ -21,6 +21,7 @@
 
 import java.io.File;
 import java.net.URI;
+import java.net.URL;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -55,6 +56,20 @@
     private boolean ignoreLock;
 
     /**
+     * Optional public URL prefix for the remote repository.
+     *
+     * @parameter expression="${prefixUrl}"
+     */
+    private String prefixUrl;
+
+    /**
+     * Optional public URL where the bundle has been deployed.
+     *
+     * @parameter expression="${bundleUrl}"
+     */
+    private String bundleUrl;
+
+    /**
      * Remote OBR Repository.
      * 
      * @parameter expression="${remoteOBR}" default-value="NONE"
@@ -90,6 +105,13 @@
     private String altDeploymentRepository;
 
     /**
+     * OBR specific deployment repository. Format: id::layout::url
+     * 
+     * @parameter expression="${obrDeploymentRepository}"
+     */
+    private String obrDeploymentRepository;
+
+    /**
      * Local Repository.
      * 
      * @parameter expression="${localRepository}"
@@ -205,6 +227,20 @@
 
             Config userConfig = new Config();
             userConfig.setRemoteFile( true );
+            
+            if ( bundleUrl != null )
+            {
+                // public URL differs from the bundle file location
+                userConfig.setRemoteBundle( URI.create( bundleUrl ) );
+            }
+            else if ( prefixUrl != null )
+            {
+                // support absolute bundle URLs based on given prefix
+                URI bundleJar = ObrUtils.getArtifactURI( localRepository, project.getArtifact() );
+                String relative = ObrUtils.getRelativeURI( ObrUtils.toFileURI( mavenRepository ),  bundleJar).toASCIIString();
+                URL resourceURL = new URL( new URL( prefixUrl + '/' ), relative );
+                userConfig.setRemoteBundle( resourceURL.toURI() );
+            }
 
             update = new ObrUpdate( repositoryXml, obrXmlFile, project, mavenRepository, userConfig, log );
             update.parseRepositoryXml();
@@ -247,6 +283,12 @@
 
     private void openRepositoryConnection( RemoteFileManager remoteFile ) throws MojoExecutionException
     {
+        // use OBR specific deployment location?
+        if ( obrDeploymentRepository != null )
+        {
+            altDeploymentRepository = obrDeploymentRepository;
+        }
+
         if ( deploymentRepository == null && altDeploymentRepository == null )
         {
             String msg = "Deployment failed: repository element was not specified in the pom inside"

Modified: felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrRemoteClean.java
URL: http://svn.apache.org/viewvc/felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrRemoteClean.java?rev=682034&r1=682033&r2=682034&view=diff
==============================================================================
--- felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrRemoteClean.java (original)
+++ felix/trunk/bundleplugin/src/main/java/org/apache/felix/obrplugin/ObrRemoteClean.java Sat Aug  2 11:47:46 2008
@@ -82,11 +82,11 @@
     private boolean ignoreLock;
     
     /**
-     * Public URL prefix for the remote repository.
+     * Optional public URL prefix for the remote repository.
      *
-     * @parameter expression="${prefixURL}"
+     * @parameter expression="${prefixUrl}"
      */
-    private String prefixURL;
+    private String prefixUrl;
 
     /**
      * Remote OBR Repository.
@@ -124,6 +124,13 @@
     private String altDeploymentRepository;
 
     /**
+     * OBR specific deployment repository. Format: id::layout::url
+     *
+     * @parameter expression="${obrDeploymentRepository}"
+     */
+    private String obrDeploymentRepository;
+
+    /**
      * The Maven project.
      * 
      * @parameter expression="${project}"
@@ -179,9 +186,9 @@
 
         RemoteFileManager remoteFile = new RemoteFileManager( m_wagonManager, settings, log );
         openRepositoryConnection( remoteFile );
-        if ( null == prefixURL || prefixURL.trim().length() == 0 )
+        if ( null == prefixUrl )
         {
-            prefixURL = remoteFile.toString();
+            prefixUrl = remoteFile.toString();
         }
 
         // ======== LOCK REMOTE OBR ========
@@ -240,6 +247,12 @@
 
     private void openRepositoryConnection( RemoteFileManager remoteFile ) throws MojoExecutionException
     {
+        // use OBR specific deployment location?
+        if ( obrDeploymentRepository != null )
+        {
+            altDeploymentRepository = obrDeploymentRepository;
+        }
+
         if ( deploymentRepository == null && altDeploymentRepository == null )
         {
             String msg = "Deployment failed: repository element was not specified in the pom inside"
@@ -286,7 +299,7 @@
 
             URL url;
             try {
-                url = new URL(prefixURL + '/' + value);
+                url = new URL( new URL( prefixUrl + '/' ), value);
             } catch (MalformedURLException e) {
                 getLog().error("Malformed URL when creating the resource absolute URI : " + e.getMessage());
                 return null;