diff --git a/java/remote-servers/impl/remote-servers-java-impl.iml b/java/remote-servers/impl/remote-servers-java-impl.iml
index c98f909fbfd8..b0228d7f4075 100644
--- a/java/remote-servers/impl/remote-servers-java-impl.iml
+++ b/java/remote-servers/impl/remote-servers-java-impl.iml
@@ -12,7 +12,7 @@
-
+
diff --git a/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentSourceHandlerBase.java b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentSourceHandlerBase.java
new file mode 100644
index 000000000000..3b50c7752e3d
--- /dev/null
+++ b/java/remote-servers/impl/src/com/intellij/remoteServer/impl/util/ArtifactDeploymentSourceHandlerBase.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.remoteServer.impl.util;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.packaging.artifacts.Artifact;
+import com.intellij.remoteServer.agent.util.CloudGitApplication;
+import com.intellij.remoteServer.configuration.deployment.ArtifactDeploymentSource;
+import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
+import com.intellij.remoteServer.util.DeploymentSourceHandler;
+import com.intellij.remoteServer.util.ServerRuntimeException;
+
+import java.io.File;
+
+/**
+ * @author michael.golubev
+ */
+public abstract class ArtifactDeploymentSourceHandlerBase implements DeploymentSourceHandler {
+
+ private static final Logger LOG = Logger.getInstance("#" + ArtifactDeploymentSourceHandlerBase.class.getName());
+
+ private Artifact myArtifact;
+ private File myRepositoryRootFile;
+
+ protected File getArtifactFile() {
+ return new File(myArtifact.getOutputFilePath());
+ }
+
+ @Override
+ public File getRepositoryRootFile() {
+ return myRepositoryRootFile;
+ }
+
+ @Override
+ public boolean init(DeploymentSource deploymentSource) throws ServerRuntimeException {
+ if (!(deploymentSource instanceof ArtifactDeploymentSource)) {
+ return false;
+ }
+ ArtifactDeploymentSource artifactDeploymentSource = (ArtifactDeploymentSource)deploymentSource;
+ Artifact artifact = artifactDeploymentSource.getArtifact();
+ if (artifact == null) {
+ throw new ServerRuntimeException("Artifact not found " + artifactDeploymentSource.getArtifactPointer().getArtifactName());
+ }
+
+ String outputPath = artifact.getOutputPath();
+ LOG.assertTrue(outputPath != null, "Artifact output path not found");
+ myRepositoryRootFile = new File(outputPath, "/deploy");
+ if (!myRepositoryRootFile.exists()) {
+ if (!myRepositoryRootFile.mkdir()) {
+ throw new ServerRuntimeException("Unable to create deploy folder");
+ }
+ }
+ myArtifact = artifact;
+ return true;
+ }
+}
diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/util/DeploymentSourceHandler.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/DeploymentSourceHandler.java
new file mode 100644
index 000000000000..0dba5d2932b5
--- /dev/null
+++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/util/DeploymentSourceHandler.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.remoteServer.util;
+
+import com.intellij.remoteServer.agent.util.CloudGitApplication;
+import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
+
+import java.io.File;
+
+/**
+ * @author michael.golubev
+ */
+public interface DeploymentSourceHandler {
+
+ boolean init(DeploymentSource deploymentSource) throws ServerRuntimeException;
+
+ File getRepositoryRootFile();
+
+ CloudGitApplication deploy() throws ServerRuntimeException;
+}
diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentConfiguratorBase.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentConfiguratorBase.java
new file mode 100644
index 000000000000..c1fb091012cc
--- /dev/null
+++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentConfiguratorBase.java
@@ -0,0 +1,59 @@
+package com.intellij.remoteServer.util;
+
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.module.ModulePointerManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.remoteServer.ServerType;
+import com.intellij.remoteServer.configuration.ServerConfiguration;
+import com.intellij.remoteServer.configuration.deployment.DeploymentConfiguration;
+import com.intellij.remoteServer.configuration.deployment.DeploymentConfigurator;
+import com.intellij.remoteServer.configuration.deployment.DeploymentSource;
+import com.intellij.remoteServer.impl.configuration.deployment.ModuleDeploymentSourceImpl;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author michael.golubev
+ */
+public abstract class CloudGitDeploymentConfiguratorBase
+ extends DeploymentConfigurator {
+
+ private final Project myProject;
+ private ServerType myServerType;
+
+ public CloudGitDeploymentConfiguratorBase(Project project, ServerType serverType) {
+ myProject = project;
+ myServerType = serverType;
+ }
+
+ @Nullable
+ public static CloudGitDeploymentSourceHandlerProvider getDeploymentSourceHandlerProvider(ServerType> serverType) {
+ for (CloudGitDeploymentSourceHandlerProvider provider : CloudGitDeploymentSourceHandlerProvider.EP_NAME.getExtensions()) {
+ if (provider.getServerType() == serverType) {
+ return provider;
+ }
+ }
+ return null;
+ }
+
+ @NotNull
+ @Override
+ public List getAvailableDeploymentSources() {
+ if (myProject.isDefault()) return Collections.emptyList();
+ List result = new ArrayList();
+ ModulePointerManager pointerManager = ModulePointerManager.getInstance(myProject);
+ for (Module module : ModuleManager.getInstance(myProject).getModules()) {
+ result.add(new ModuleDeploymentSourceImpl(pointerManager.create(module)));
+ }
+ CloudGitDeploymentSourceHandlerProvider provider = getDeploymentSourceHandlerProvider(myServerType);
+ if (provider != null) {
+ result.addAll(provider.getDeploymentSources(myProject));
+ }
+ return result;
+ }
+}
diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
index 41bc988f23af..74bf0ea3b8e5 100644
--- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
+++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/CloudGitDeploymentRuntime.java
@@ -12,7 +12,9 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.VcsException;
+import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.agent.util.CloudGitAgent;
import com.intellij.remoteServer.agent.util.CloudGitAgentDeployment;
import com.intellij.remoteServer.agent.util.CloudGitApplication;
@@ -38,6 +40,8 @@ import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
/**
* @author michael.golubev
@@ -53,6 +57,7 @@ public abstract class CloudGitDeploymentRuntime serverType) throws ServerRuntimeException {
myConfiguration = serverConfiguration;
myTasksExecutor = taskExecutor;
myLogManager = logManager;
@@ -84,25 +90,31 @@ public abstract class CloudGitDeploymentRuntime handlers = new ArrayList();
+ handlers.add(new ModuleDeploymentSourceHandler());
+ CloudGitDeploymentSourceHandlerProvider handlerProvider
+ = CloudGitDeploymentConfiguratorBase.getDeploymentSourceHandlerProvider(serverType);
+ if (handlerProvider != null) {
+ handlers.addAll(handlerProvider.getHandlers(this));
+ }
DeploymentSource deploymentSource = task.getSource();
- if (!(deploymentSource instanceof ModuleDeploymentSource)) {
- throw new ServerRuntimeException("Module deployment source is the only supported");
+ for (DeploymentSourceHandler sourceHandler : handlers) {
+ if (sourceHandler.init(deploymentSource)) {
+ mySourceHandler = sourceHandler;
+ break;
+ }
+ }
+ if (mySourceHandler == null) {
+ throw new ServerRuntimeException("Unknown deployment source");
}
- ModuleDeploymentSource moduleDeploymentSource = (ModuleDeploymentSource)deploymentSource;
- Module module = moduleDeploymentSource.getModule();
- if (module == null) {
- throw new ServerRuntimeException("Module not found: " + moduleDeploymentSource.getModulePointer().getModuleName());
- }
-
- VirtualFile contentRoot = moduleDeploymentSource.getContentRoot();
- LOG.assertTrue(contentRoot != null, "Content root is not found");
- myContentRoot = contentRoot;
-
- File contentRootFile = moduleDeploymentSource.getFile();
- LOG.assertTrue(contentRootFile != null, "Content root file is not found");
+ File contentRootFile = mySourceHandler.getRepositoryRootFile();
myContentRootFile = contentRootFile;
+ VirtualFile contentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(myContentRootFile);
+ LOG.assertTrue(contentRoot != null, "Repository root is not found");
+ myContentRoot = contentRoot;
+
myProject = task.getProject();
myGitRepositoryManager = GitUtil.getRepositoryManager(myProject);
myGit = ServiceManager.getService(Git.class);
@@ -142,59 +154,7 @@ public abstract class CloudGitDeploymentRuntime EP_NAME
+ = ExtensionPointName.create("Git4Idea.remoteServer.CloudGitDeploymentSourceHandlerProvider");
+
+ ServerType> getServerType();
+
+ Collection getDeploymentSources(Project project);
+
+ List getHandlers(CloudGitDeploymentRuntime, ?, ?> deploymentRuntime);
+}
diff --git a/plugins/git4idea/src/META-INF/plugin.xml b/plugins/git4idea/src/META-INF/plugin.xml
index 0c98e1491a7b..1d2beb25ad28 100644
--- a/plugins/git4idea/src/META-INF/plugin.xml
+++ b/plugins/git4idea/src/META-INF/plugin.xml
@@ -193,6 +193,8 @@
-
+
+