diff options
author | donghyuk.yang <donghyuk.yang@samsung.com> | 2014-05-04 21:12:31 +0900 |
---|---|---|
committer | donghyuk.yang <donghyuk.yang@samsung.com> | 2014-05-04 21:12:31 +0900 |
commit | 77b561fec876227aeac735ac92946921025a2834 (patch) | |
tree | cab646ab0c1da335bc560c85cfdb1fe9e22fb2f5 | |
parent | 0856ee344745c4d41cf55efd4c812c1eaef387dc (diff) | |
download | nativeplatform-eplugin-77b561fec876227aeac735ac92946921025a2834.tar.gz nativeplatform-eplugin-77b561fec876227aeac735ac92946921025a2834.tar.bz2 nativeplatform-eplugin-77b561fec876227aeac735ac92946921025a2834.zip |
LAUNCH: Cached package information after building a project
IDE tried a few times for getting package information when launching a
project before. Now, IDE tries just an one time for getting package
information and cache it.
Change-Id: Ifb95e165002baa71745f0217184146e441f80e42
Signed-off-by: donghyuk.yang <donghyuk.yang@samsung.com>
15 files changed, 143 insertions, 32 deletions
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java index 6042ebd5..52b316b4 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/Activator.java @@ -32,6 +32,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; +import org.tizen.common.util.OSChecker; import org.tizen.nativecommon.build.ProjectTypeManager; import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.build.PlatformProjectDependentBuilder; @@ -73,10 +74,12 @@ public class Activator extends AbstractUIPlugin { PlatformProjectDependentPackager.getInstance(), true); PreferencesManager.setDefaultValues(); CommandUtil.clearPlatformTempDir(); - PlatformResourceChangeListener listener = new PlatformResourceChangeListener(); - ResourcesPlugin.getWorkspace().addResourceChangeListener( - listener, IResourceChangeEvent.PRE_DELETE); SmartDevelopmentBridge.addDeviceChangeListener(new DeviceChangeListener(), true); + if (OSChecker.isWindows()) { + PlatformResourceChangeListener listener = new PlatformResourceChangeListener(); + ResourcesPlugin.getWorkspace().addResourceChangeListener( + listener, IResourceChangeEvent.PRE_DELETE); + } } /* diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/PlatformResourceChangeListener.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/PlatformResourceChangeListener.java index d8f59d29..d0d25b16 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/PlatformResourceChangeListener.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/PlatformResourceChangeListener.java @@ -8,6 +8,7 @@ import org.eclipse.core.resources.IResourceDeltaVisitor; import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
+import org.tizen.nativeplatform.util.PackageStoreManager;
import org.tizen.nativeplatform.util.PlatformProjectUtil;
public class PlatformResourceChangeListener implements IResourceChangeListener {
@@ -19,10 +20,8 @@ public class PlatformResourceChangeListener implements IResourceChangeListener { case IResourceChangeEvent.PRE_DELETE:
if (res.getType() == IResource.PROJECT) {
String projectName = res.getName();
- System.out.print("Project ");
- System.out.print(res.getFullPath());
- System.out.println(" is about to be deleted.");
PlatformProjectUtil.removeRemoteProject(projectName);
+ PackageStoreManager.clearStore(projectName);
}
}
}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildResultProcessor.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildResultProcessor.java index 96ef786c..56b14d39 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildResultProcessor.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/gbs/GBSBuildResultProcessor.java @@ -51,19 +51,27 @@ import org.tizen.nativeplatform.build.IBuildResultProcessor; import org.tizen.nativeplatform.build.PlatformConfigurationManager; import org.tizen.nativeplatform.filefilter.RpmFileFilter; import org.tizen.nativeplatform.filefilter.XmlFileFilter; +import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; +import org.tizen.nativeplatform.pkg.commander.factory.PkgModelMakerFactory; +import org.tizen.nativeplatform.pkg.model.IPackage; import org.tizen.nativeplatform.remote.connection.RemoteConnectionManager; import org.tizen.nativeplatform.rootstrap.RootstrapManager; +import org.tizen.nativeplatform.util.PackageStoreManager; +import org.tizen.nativeplatform.util.PlatformProjectUtil; import org.tizen.nativeplatform.util.PlatformUserInteraction; import org.tizen.nativeplatform.util.RootstrapUtil; import org.tizen.nativeplatform.views.model.PlatformRootstrap; public class GBSBuildResultProcessor implements IBuildResultProcessor { + private IProject project; private IConfiguration config; private List<String> rpmfiles = new ArrayList<String>(); private List<String> xmlfiles = new ArrayList<String>(); + private IPkgModelMaker modelMaker = PkgModelMakerFactory.getMaker(PlatformProjectUtil.getPkgType()); public GBSBuildResultProcessor(IConfiguration config) { + this.project = (IProject)config.getOwner(); this.config = config; } @@ -71,6 +79,9 @@ public class GBSBuildResultProcessor implements IBuildResultProcessor { public boolean process(String[] buildArguments) { if (buildArguments != null && buildArguments.length > 0) { if (buildArguments[0].equals("clean")) { + if (OSChecker.isWindows()) { + remoteCleanProcess(); + } return true; } } @@ -84,6 +95,10 @@ public class GBSBuildResultProcessor implements IBuildResultProcessor { UserLogger.end(PlatformUserInteraction.CATE_SYNCRONIZE, PlatformUserInteraction.SYNC_OUTPUT); return result; } + + private void remoteCleanProcess() { + PackageStoreManager.removeStore(project, config); + } private boolean localProcess(String[] buildArguments) { String targetId = PlatformConfigurationManager.getBuildTargetName(config); @@ -182,6 +197,8 @@ public class GBSBuildResultProcessor implements IBuildResultProcessor { e.printStackTrace(); } } + List<IPackage> pkgs = modelMaker.makeModels(rpmfiles); + PackageStoreManager.put(project, config, pkgs); return true; } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/command/launcher/CommandUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/command/launcher/CommandUtil.java index 46a2d034..10afda91 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/command/launcher/CommandUtil.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/command/launcher/CommandUtil.java @@ -48,19 +48,26 @@ public class CommandUtil { public static String[] splitCommandArgs(String args) { List<String> argList = new ArrayList<String>(); - if (args.length() > LIMIT_COMMAND_LENGTH) { - String[] splited = args.split(" "); - String newArgs = ""; - for (String arg : splited) { - if (newArgs.length() < LIMIT_COMMAND_LENGTH) { - newArgs += arg + " "; + if (args.length() > LIMIT_COMMAND_LENGTH) { + String[] splited = args.split("' "); + StringBuffer newArgs = new StringBuffer(); + int length = splited.length; + for (int i = 0 ; i < length ; i++) { + String arg = splited[i]; + if (i == length - 1) { + newArgs.append(arg); + } else if (newArgs.length() < LIMIT_COMMAND_LENGTH) { + newArgs.append(arg).append("' "); } else { - newArgs += arg + " "; - argList.add(newArgs.trim()); - newArgs = ""; + newArgs.append(arg).append("'"); + int end = newArgs.length(); + argList.add(newArgs.toString()); + newArgs = new StringBuffer(); } } - argList.add(newArgs.trim()); + if (newArgs.length() > 0) { + argList.add(newArgs.toString()); + } } else { argList.add(args); } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java index b72dc251..88604595 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/launch/ui/shortcut/PlatformProjectLaunchShortcut.java @@ -71,7 +71,9 @@ public class PlatformProjectLaunchShortcut extends PlatformProjectCommonLaunchSh TizenLaunchConfiguration tc = new TizenLaunchConfiguration(wc, device); tc.setDefaults(); setAttributes(wc, project); - setSourceContainer(project, wc); + if (!mode.equals("run")) { + setSourceContainer(project, wc); + } ICProjectDescription projDes = CCorePlugin.getDefault().getProjectDescription(project); if (projDes != null) { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java index 720d7dde..abfb6717 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/IPkgCommander.java @@ -89,6 +89,8 @@ public interface IPkgCommander { ICommandStatus uninstallPkg(String pkg, IProgressMonitor monitor); ICommandStatus downloadFilesFromRemote(String[] fileList); + + ICommandStatus downlaodFileFromRemote(String src, String dst); ICommandStatus copyFilesToTmpDir(String[] fileList); diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java index 7d528574..1c90b20c 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/deb/DebCommanderHost.java @@ -328,9 +328,12 @@ public class DebCommanderHost implements IPkgCommander { @Override public ICommandStatus downloadFilesFromRemote(String[] fileList) { - // TODO Auto-generated method stub return null; } + + public ICommandStatus downlaodFileFromRemote(String src, String dst) { + return null; + } @Override public void actionBeforeUsingZypper() { diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RemoteRpmModelMaker.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RemoteRpmModelMaker.java index bb52b305..825e1279 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RemoteRpmModelMaker.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RemoteRpmModelMaker.java @@ -33,6 +33,7 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.tizen.common.util.FilenameUtil; import org.tizen.nativeplatform.pkg.commander.IPkgModelMaker; import org.tizen.nativeplatform.pkg.commander.PkgCommandTarget; import org.tizen.nativeplatform.pkg.model.IPackage; diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java index 92aceda0..9b751be5 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderCommon.java @@ -172,6 +172,10 @@ public abstract class RpmCommanderCommon implements IPkgCommander { return null; } + public ICommandStatus downlaodFileFromRemote(String src, String dst) { + return null; + } + public String getArchFromRemoteFile(String filePath) { return ""; } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java index 4f3086c2..061f3ba0 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/pkg/commander/rpm/RpmCommanderDevice.java @@ -102,6 +102,21 @@ public class RpmCommanderDevice extends RpmCommanderCommon { return new CommandStatus(IStatus.OK, value, null); } + public ICommandStatus downlaodFileFromRemote(String src, String dst) { + String keyPath = SSHUtil.getDeviceSshPrivateKeyPath(); + String host = RemoteConnectionManager.getRemoteTools().getHost(); + String user = RemoteConnectionManager.getRemoteTools().getUser(); + String command = String.format("scp -i %s -o StrictHostKeyChecking=no " + + "%s@%s:%s %s", keyPath, user, host, src, dst); + ICommandStatus status = execute(command, null, false); + if (status.isOk()) { + List<String> value = new ArrayList<String>(); + value.add(dst); + printResultLog(String.format("[RDS] Downloaded file: %s \n " + "-> %s", src, dst)); + return new CommandStatus(IStatus.OK, value, null); + } + return status; + } public ICommandStatus downloadFilesFromRemote(String[] fileList) { List<String> value = new ArrayList<String>(); @@ -132,9 +147,10 @@ public class RpmCommanderDevice extends RpmCommanderCommon { String command = String.format("scp -i %s -o StrictHostKeyChecking=no " + "%s@%s:%s %s", keyPath, user, host, files, TMP_DIR); ICommandStatus status = execute(command, null, true); + if (status.isOk()) { return new CommandStatus(IStatus.OK, value, null); - } + } return status; } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java index da7eadce..93607894 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/rds/RemoteRpmRapidDeployer.java @@ -128,21 +128,12 @@ public class RemoteRpmRapidDeployer { private boolean processCopiedFiles(List<String> fileList) { if (isDeviceCommander()) { - String cachingDir = LocalCommandUtil.getCachingDir(project); - IRemoteCopyTools copytool = RemoteConnectionManager.getRemoteTools().getCopyTool(); for (final String file : fileList) { String remoteFilepath = new Path(RemoteCommandUtil.getCachingDir(project)).append(file).toString(); - String filename = FilenameUtil.getFilename(file); - String srcPath = new Path(cachingDir).append(filename).toOSString(); - try { - copytool.downloadFileToFile(remoteFilepath, srcPath); - } catch (Exception e) { - e.printStackTrace(); - } - String targetFilePath = new Path(file).removeFirstSegments(1).toString(); - ICommandStatus status = commander.copyFile(srcPath, targetFilePath); + String targetFilePath = new Path(file).removeFirstSegments(1).toString(); + ICommandStatus status = commander.downlaodFileFromRemote(remoteFilepath, targetFilePath); if (status == null || !status.isOk()) { - logger.error(String.format("Failed to copy files [%s]", srcPath)); + logger.error(String.format("Failed to copy files [%s]", remoteFilepath)); return false; } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/IPackageUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/IPackageUtil.java index 467ccd69..58616ca4 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/IPackageUtil.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/IPackageUtil.java @@ -13,4 +13,5 @@ public interface IPackageUtil { boolean build(IProject project, IConfiguration config, IProgressMonitor monitor) throws CoreException;
void cachePkgChecksum(IProject project, IConfiguration config);
List<IPackage> getPackages(IProject project, IConfiguration config);
+ List<IPackage> getPackages(List<String> pkgPath);
}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageStoreManager.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageStoreManager.java new file mode 100644 index 00000000..79950e3c --- /dev/null +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageStoreManager.java @@ -0,0 +1,48 @@ +package org.tizen.nativeplatform.util;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.resources.IProject;
+import org.tizen.nativeplatform.pkg.model.IPackage;
+
+public class PackageStoreManager {
+ public static Map<String, List<IPackage>> store = new HashMap<String, List<IPackage>>();
+
+ public static void put(IProject project, IConfiguration config, List<IPackage> pkgs) {
+ String key = getKey(project, config);
+ if (store.get(key) != null) {
+ store.remove(key);
+ }
+ store.put(key, pkgs);
+ }
+
+ public static void clearStore(String projectName) {
+ Set<String> removableKey = new HashSet<String>();
+ for (String key : store.keySet()) {
+ if (key.startsWith(projectName + "_")) {
+ removableKey.add(key);
+ }
+ }
+ for (String key : removableKey) {
+ store.remove(key);
+ }
+ }
+
+ public static void removeStore(IProject project, IConfiguration config) {
+ store.remove(getKey(project, config));
+ }
+
+ public static List<IPackage> get(IProject project, IConfiguration config) {
+ return store.get(getKey(project, config));
+ }
+
+ private static String getKey(IProject project, IConfiguration config) {
+ String key = String.format("%s_%s", project.getName(), config.getName());
+ return key;
+ }
+}
diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java index 40d778d9..ac986412 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/PackageUtil.java @@ -123,4 +123,10 @@ public class PackageUtil implements IPackageUtil { } return modelMaker.makeModels(pkgs); } + + @Override + public List<IPackage> getPackages(List<String> pkgPath) { + // RemotePackageUtil uses this method. + return null; + } } diff --git a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/RemotePackageUtil.java b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/RemotePackageUtil.java index 73f01985..48b7ed32 100644 --- a/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/RemotePackageUtil.java +++ b/org.tizen.nativeplatform/src/org/tizen/nativeplatform/util/RemotePackageUtil.java @@ -76,6 +76,10 @@ public class RemotePackageUtil extends PackageUtil { */ public List<IPackage> getPackages(IProject project, IConfiguration config) { + List<IPackage> cached = PackageStoreManager.get(project, config); + if (cached != null) { + return cached; + } List<String> pkgs = new ArrayList<String>(); String targetPath = RootstrapUtil.getUserSyncWorkspacePath(project.getName()); String configPath = new Path(targetPath).append(config.getName()).toString(); @@ -100,6 +104,13 @@ public class RemotePackageUtil extends PackageUtil { e.printStackTrace(); return null; } - return modelMaker.makeModels(pkgs); + List<IPackage> newPkgs = getPackages(pkgs); + PackageStoreManager.put(project, config, newPkgs); + return newPkgs; + } + + public List<IPackage> getPackages(List<String> pkgPath) { + List<IPackage> pkgmodel = modelMaker.makeModels(pkgPath); + return pkgmodel; } } |