You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2016/02/17 21:50:52 UTC

svn commit: r1730938 - in /sling/trunk/tooling/ide: artifacts/ artifacts/src/org/apache/sling/ide/artifacts/ artifacts/src/org/apache/sling/ide/artifacts/impl/ eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/

Author: rombert
Date: Wed Feb 17 20:50:51 2016
New Revision: 1730938

URL: http://svn.apache.org/viewvc?rev=1730938&view=rev
Log:
SLING-3605 - Debug based on bundles deployed on the server 

When starting the server, also install the
org.apache.sling.tooling.support.source bundle if needed.

Modified:
    sling/trunk/tooling/ide/artifacts/pom.xml
    sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifact.java
    sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java
    sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java
    sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java

Modified: sling/trunk/tooling/ide/artifacts/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/pom.xml?rev=1730938&r1=1730937&r2=1730938&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/pom.xml (original)
+++ sling/trunk/tooling/ide/artifacts/pom.xml Wed Feb 17 20:50:51 2016
@@ -75,6 +75,12 @@
                                     <version>1.0.2</version>
                                     <outputDirectory>${project.build.directory}/artifacts/sling-tooling-support-install</outputDirectory>
                                 </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.sling</groupId>
+                                    <artifactId>org.apache.sling.tooling.support.source</artifactId>
+                                    <version>0.9.0-SNAPSHOT</version>
+                                    <outputDirectory>${project.build.directory}/artifacts/sling-tooling-support-source</outputDirectory>
+                                </artifactItem>
                             </artifactItems>
                             <overWriteReleases>false</overWriteReleases>
                             <overWriteSnapshots>true</overWriteSnapshots>

Modified: sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifact.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifact.java?rev=1730938&r1=1730937&r2=1730938&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifact.java (original)
+++ sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifact.java Wed Feb 17 20:50:51 2016
@@ -52,6 +52,10 @@ public class EmbeddedArtifact {
     public String getVersion() {
         return version;
     }
+    
+    public String getOsgiFriendlyVersion() {
+        return version.replace('-', '.');
+    }
 
     /**
      * 

Modified: sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java?rev=1730938&r1=1730937&r2=1730938&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java (original)
+++ sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/EmbeddedArtifactLocator.java Wed Feb 17 20:50:51 2016
@@ -19,6 +19,10 @@ package org.apache.sling.ide.artifacts;
 public interface EmbeddedArtifactLocator {
 
     public static final String SUPPORT_BUNDLE_SYMBOLIC_NAME = "org.apache.sling.tooling.support.install";
+    
+    public static final String SUPPORT_SOURCE_BUNDLE_SYMBOLIC_NAME = "org.apache.sling.tooling.support.source";
 
     EmbeddedArtifact loadToolingSupportBundle();
+    
+    EmbeddedArtifact loadSourceSupportBundle();
 }

Modified: sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java?rev=1730938&r1=1730937&r2=1730938&view=diff
==============================================================================
--- sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java (original)
+++ sling/trunk/tooling/ide/artifacts/src/org/apache/sling/ide/artifacts/impl/ArtifactsLocatorImpl.java Wed Feb 17 20:50:51 2016
@@ -40,7 +40,7 @@ public class ArtifactsLocatorImpl implem
 
         BundleContext bundleContext = context.getBundleContext();
 
-        String version = "1.0.0"; // TODO - remove version hardcoding
+        String version = "1.0.2"; // TODO - remove version hardcoding
         String artifactId = "org.apache.sling.tooling.support.install";
         String extension = "jar";
 
@@ -50,6 +50,21 @@ public class ArtifactsLocatorImpl implem
         return new EmbeddedArtifact(artifactId + "-" + version + "." + extension, version, jarUrl);
     }
 
+    @Override
+    public EmbeddedArtifact loadSourceSupportBundle() {
+        
+        BundleContext bundleContext = context.getBundleContext();
+        
+        String version = "0.9.0.SNAPSHOT"; // TODO - remove version hardcoding
+        String artifactId = "org.apache.sling.tooling.support.source";
+        String extension = "jar";
+        
+        URL jarUrl = loadResource(bundleContext, ARTIFACTS_LOCATION + "/sling-tooling-support-source/" + artifactId
+                + "." + extension);
+        
+        return new EmbeddedArtifact(artifactId + "-" + version + "." + extension, version, jarUrl);
+    }
+
     private URL loadResource(BundleContext bundleContext, String resourceLocation) {
 
         URL resourceUrl = bundleContext.getBundle().getResource(resourceLocation);

Modified: sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java?rev=1730938&r1=1730937&r2=1730938&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java (original)
+++ sling/trunk/tooling/ide/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/SlingLaunchpadBehaviour.java Wed Feb 17 20:50:51 2016
@@ -82,7 +82,7 @@ public class SlingLaunchpadBehaviour ext
 
         boolean success = false;
         Result<ResourceProxy> result = null;
-        monitor.beginTask("Starting server", 5);
+        monitor.beginTask("Starting server", 7);
         
         Repository repository;
         try {
@@ -92,14 +92,14 @@ public class SlingLaunchpadBehaviour ext
             throw e;
         }
 
-        monitor.worked(2); // 2/5 done
+        monitor.worked(2); // 2/7 done
 
         try {
             if (getServer().getMode().equals(ILaunchManager.DEBUG_MODE)) {
                 debuggerConnection = new JVMDebuggerConnection();
                 success = debuggerConnection.connectInDebugMode(launch, getServer(), monitor);
 
-                monitor.worked(3); // 5/5 done
+                monitor.worked(5); // 7/7 done
 
             } else {
                 
@@ -107,34 +107,18 @@ public class SlingLaunchpadBehaviour ext
                 result = command.execute();
                 success = result.isSuccess();
                 
-                monitor.worked(1); // 3/5 done
+                monitor.worked(1); // 3/7 done
                 
                 RepositoryInfo repositoryInfo;
                 try {
                     repositoryInfo = ServerUtil.getRepositoryInfo(getServer(), monitor);
                     OsgiClient client = Activator.getDefault().getOsgiClientFactory().createOsgiClient(repositoryInfo);
                     EmbeddedArtifactLocator artifactLocator = Activator.getDefault().getArtifactLocator();
-                    Version remoteVersion = client.getBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME);
                     
-                    monitor.worked(1); // 4/5 done
-                    
-                    final EmbeddedArtifact supportBundle = artifactLocator.loadToolingSupportBundle();
-
-                    final Version embeddedVersion = new Version(supportBundle.getVersion());
-                    
-                    ISlingLaunchpadServer launchpadServer = (ISlingLaunchpadServer) getServer().loadAdapter(SlingLaunchpadServer.class,
-                            monitor);
-                    if (remoteVersion == null || remoteVersion.compareTo(embeddedVersion) < 0) {
-                        try ( InputStream contents = supportBundle.openInputStream() ){
-                            client.installBundle(contents, supportBundle.getName());
-                        }
-                        remoteVersion = embeddedVersion;
-
-                    }
-                    launchpadServer.setBundleVersion(EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME, remoteVersion,
-                            monitor);
-                    
-                    monitor.worked(1); // 5/5 done
+                    installBundle(monitor, client, artifactLocator.loadToolingSupportBundle(), 
+                            EmbeddedArtifactLocator.SUPPORT_BUNDLE_SYMBOLIC_NAME); // 5/7 done
+                    installBundle(monitor, client, artifactLocator.loadSourceSupportBundle(), 
+                            EmbeddedArtifactLocator.SUPPORT_SOURCE_BUNDLE_SYMBOLIC_NAME); // 7/7 done
                     
                 } catch ( IOException e) {
                     Activator.getDefault().getPluginLogger()
@@ -163,6 +147,31 @@ public class SlingLaunchpadBehaviour ext
         }
     }
 
+    private void installBundle(IProgressMonitor monitor, OsgiClient client, final EmbeddedArtifact bundle,
+            String bundleSymbolicName) throws OsgiClientException, IOException {
+        
+        Version remoteVersion = client.getBundleVersion(bundleSymbolicName);
+        
+        monitor.worked(1);
+        
+        final Version embeddedVersion = new Version(bundle.getOsgiFriendlyVersion());
+        
+        ISlingLaunchpadServer launchpadServer = (ISlingLaunchpadServer) getServer().loadAdapter(SlingLaunchpadServer.class,
+                monitor);
+        if (remoteVersion == null || remoteVersion.compareTo(embeddedVersion) < 0 
+                || ( remoteVersion.equals(embeddedVersion) || "SNAPSHOT".equals(embeddedVersion.getQualifier()))) {
+            try ( InputStream contents = bundle.openInputStream() ){
+                client.installBundle(contents, bundle.getName());
+            }
+            remoteVersion = embeddedVersion;
+
+        }
+        launchpadServer.setBundleVersion(bundleSymbolicName, remoteVersion,
+                monitor);
+        
+        monitor.worked(1);
+    }
+
     // TODO refine signature
     public void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException {
         // TODO check that ports are free