/** Create & return a new configuration based on the specified <code>IType</code>. */ protected ILaunchConfiguration createConfiguration(IType type) { String launcherName = MainLauncher.this.getLauncherName(); ILaunchConfigurationType configType = MainLauncher.this.getLaunchConfigurationType(); ILaunchConfigurationWorkingCopy wc = null; try { wc = configType.newInstance(null, launcherName); } catch (CoreException exception) { JDIDebugUIPlugin.log(exception); return null; } wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); MainLauncher.this.setAdditionalAttributes(wc); ILaunchConfiguration config = null; try { config = wc.doSave(); } catch (CoreException exception) { JDIDebugUIPlugin.log(exception); } return config; }
/* (non-Javadoc) * @see org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchShortcut#createConfiguration(org.eclipse.jdt.core.IType) */ @Override protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null; ILaunchConfigurationWorkingCopy wc = null; try { ILaunchConfigurationType configType = getConfigurationType(); wc = configType.newInstance( null, getLaunchManager().generateLaunchConfigurationName(type.getTypeQualifiedName('.'))); // wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, // type.getFullyQualifiedName()); wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); wc.setMappedResources(new IResource[] {type.getUnderlyingResource()}); config = wc.doSave(); } catch (CoreException exception) { MessageDialog.openError( JDIDebugUIPlugin.getActiveWorkbenchShell(), LauncherMessages.JavaLaunchShortcut_3, exception.getStatus().getMessage()); } return config; }
public ILaunchConfiguration asLaunchConfiguration() { final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType type = manager.getLaunchConfigurationType(ErlangLaunchDelegate.CONFIGURATION_TYPE_INTERNAL); ILaunchConfigurationWorkingCopy workingCopy; try { final RuntimeInfo info = getRuntimeInfo(); final String name = getNodeName(); workingCopy = type.newInstance(null, name); workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, Charsets.ISO_8859_1.name()); workingCopy.setAttribute( DebugPlugin.ATTR_PROCESS_FACTORY_ID, "org.erlide.core.ertsProcessFactory"); workingCopy.setAttribute(ErlLaunchAttributes.NODE_NAME, getNodeName()); workingCopy.setAttribute(ErlLaunchAttributes.RUNTIME_NAME, info.getName()); workingCopy.setAttribute(ErlLaunchAttributes.COOKIE, getCookie()); // workingCopy.setAttribute(ErlLaunchAttributes.CONSOLE, // !options.contains(BackendOptions.NO_CONSOLE)); workingCopy.setAttribute(ErlLaunchAttributes.USE_LONG_NAME, hasLongName()); workingCopy.setAttribute(ErlLaunchAttributes.INTERNAL, isInternal()); return workingCopy; } catch (final CoreException e) { e.printStackTrace(); return null; } }
private static ILaunchConfiguration createLaunchConfigurationForProject(IJavaProject javaProject) throws CoreException { DebugPlugin plugin = DebugPlugin.getDefault(); ILaunchManager manager = plugin.getLaunchManager(); ILaunchConfigurationType javaAppType = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy wc = javaAppType.newInstance(null, "temp-config"); wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, javaProject.getElementName()); return wc; }
/** * Tests the {@link * BuilderCoreUtils#isUnmigratedConfig(org.eclipse.debug.core.ILaunchConfiguration)} method * * @throws Exception */ public void testIsUnmigratedConfig1() throws Exception { ILaunchConfigurationType type = AbstractAntUITest.getLaunchManager() .getLaunchConfigurationType( IAntLaunchConstants.ID_ANT_BUILDER_LAUNCH_CONFIGURATION_TYPE); if (type != null) { ILaunchConfigurationWorkingCopy config = type.newInstance( BuilderCoreUtils.getBuilderFolder(getProject(), true), "testIsUnmigratedConfig1"); //$NON-NLS-1$ assertTrue( "should be considered 'unmigrated'", BuilderCoreUtils.isUnmigratedConfig(config)); // $NON-NLS-1$ } else { fail("could not find the Ant builder launch configuration type"); // $NON-NLS-1$ } }
private void launch(String pName, String fName, String mode) { try { ILaunchConfiguration found = null; ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType lct = lm.getLaunchConfigurationType(GoLaunchConfigurationDelegate.ID); ILaunchConfiguration[] lcfgs = lm.getLaunchConfigurations(lct); for (ILaunchConfiguration lcf : lcfgs) { String project = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_PROJECT, ""); String mainfile = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_MAIN, ""); String prgArgs = lcf.getAttribute(GoConstants.GO_CONF_ATTRIBUTE_ARGS, ""); if (prgArgs.isEmpty()) { // this is an empty run, no params, don't mix with already // definded with params if (project.equalsIgnoreCase(pName) && Path.fromOSString(fName).equals(Path.fromOSString(mainfile))) { found = lcf; break; } } } if (found == null) { // create a new launch configuration String cfgName = lm.generateLaunchConfigurationName(Path.fromOSString(fName).lastSegment()); ILaunchConfigurationWorkingCopy workingCopy = lct.newInstance(null, cfgName); workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_PROJECT, pName); workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_MAIN, fName); workingCopy.setAttribute(GoConstants.GO_CONF_ATTRIBUTE_ARGS, ""); workingCopy.setAttribute( GoConstants.GO_CONF_ATTRIBUTE_BUILD_CONFIG, BuildConfiguration.RELEASE.toString()); workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true); workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, "UTF-8"); found = workingCopy.doSave(); } if (found != null) { found.launch(mode, null, true, true); } } catch (CoreException ce) { Activator.logError(ce); } }
/** * @param host * @param port * @param timeout * @param appName * @param launchName * @return non-null launch configuration to debug the given application name. * @throws CoreException if unable to resolve launch configuration. */ protected ILaunchConfiguration resolveLaunchConfiguration(String host, int port, int timeout) throws CoreException { String launchLabel = getLaunchLabel(); String configID = provider.getLaunchConfigurationID() != null ? provider.getLaunchConfigurationID() : CloudFoundryDebuggingLaunchConfigDelegate.LAUNCH_CONFIGURATION_ID; launchConfigType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(configID); if (launchConfigType != null) { IProject project = getApplicationModule().getLocalModule().getProject(); // Create the launch configuration, whether the project exists // or not, as there may // not be a local project associated with the deployed app ILaunchConfiguration launchConfiguration = launchConfigType.newInstance(project, launchLabel); ILaunchConfigurationWorkingCopy wc = launchConfiguration.getWorkingCopy(); if (project != null && project.isAccessible()) { wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName()); } // Convert all to String to make it consistent when reading the // attributes later. wc.setAttribute(CloudFoundryDebuggingLaunchConfigDelegate.HOST_NAME, host); wc.setAttribute(CloudFoundryDebuggingLaunchConfigDelegate.PORT, port + ""); // $NON-NLS-1$ wc.setAttribute( CloudFoundryDebuggingLaunchConfigDelegate.TIME_OUT, timeout + ""); // $NON-NLS-1$ wc.setAttribute(DebugOperations.CLOUD_DEBUG_LAUNCH_ID, getDebuggerConnectionIdentifier()); wc.setAttribute(DebugOperations.CLOUD_DEBUG_SERVER, getCloudFoundryServer().getServerId()); wc.setAttribute( DebugOperations.CLOUD_DEBUG_APP_NAME, getApplicationModule().getDeployedApplicationName()); return launchConfiguration = wc.doSave(); } else { throw CloudErrorUtil.toCoreException( "No debug launch configuration found for - " + provider.getLaunchConfigurationID()); // $NON-NLS-1$ } }
protected ILaunchConfiguration createNewLaunchConfiguration(IFile file) { final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType(getConfigType()); try { ILaunchConfigurationWorkingCopy newConfig = configType.newInstance( null, launchManager.generateLaunchConfigurationName(file.getName())); newConfig.setAttribute(FILE_NAME, file.getFullPath().toString()); // newConfig.setAttribute(OPERATION_CLASS, "org.yakindu.Operations"); return newConfig.doSave(); } catch (CoreException e) { e.printStackTrace(); } throw new IllegalStateException(); }
protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null; ILaunchConfigurationWorkingCopy wc = null; try { ILaunchConfigurationType configType = getAJConfigurationType(); wc = configType.newInstance( null, getLaunchManager().generateLaunchConfigurationName(type.getElementName())); wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); config = wc.doSave(); } catch (CoreException exception) { reportErorr(exception); } return config; }
private ILaunchConfiguration createLaunchConfiguration(IContainer basedir, String goal) { try { ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID); String launchSafeGoalName = goal.replace(':', '-'); ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance( null, // NLS.bind( Messages.ExecutePomAction_executing, launchSafeGoalName, basedir.getLocation().toString().replace('/', '-'))); workingCopy.setAttribute( MavenLaunchConstants.ATTR_POM_DIR, basedir.getLocation().toOSString()); workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, goal); workingCopy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true); workingCopy.setAttribute(RefreshTab.ATTR_REFRESH_SCOPE, "${project}"); // $NON-NLS-1$ workingCopy.setAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, true); setProjectConfiguration(workingCopy, basedir); IPath path = getJREContainerPath(basedir); if (path != null) { workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, path.toPortableString()); } // TODO when launching Maven with debugger consider to add the following property // -Dmaven.surefire.debug="-Xdebug // -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent // -Djava.compiler=NONE" return workingCopy; } catch (CoreException ex) { log.error(ex.getMessage(), ex); } return null; }
ILaunchConfigurationWorkingCopy createConfiguration(IPath targetPath) throws CoreException { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType configType = manager.getLaunchConfigurationType(launchId); ILaunchConfigurationWorkingCopy wc; wc = configType.newInstance( null, manager.generateUniqueLaunchConfigurationNameFrom(targetPath.lastSegment())); wc.setAttribute(LaunchConstants.ATTR_LAUNCH_TARGET, targetPath.toString()); wc.setAttribute(LaunchConstants.ATTR_CLEAN, LaunchConstants.DEFAULT_CLEAN); wc.setAttribute(LaunchConstants.ATTR_DYNAMIC_BUNDLES, LaunchConstants.DEFAULT_DYNAMIC_BUNDLES); IResource targetResource = ResourcesPlugin.getWorkspace().getRoot().findMember(targetPath); if (targetResource != null && targetResource.exists()) wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, targetResource.getProject().getName()); return wc; }
private ILaunchConfiguration getLaunchConfiguration( final RuntimeInfo info, final Set<BackendOptions> options) { final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType type = manager.getLaunchConfigurationType(ErlangLaunchDelegate.CONFIGURATION_TYPE_INTERNAL); ILaunchConfigurationWorkingCopy workingCopy; try { workingCopy = type.newInstance(null, "internal " + info.getNodeName()); workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, "ISO-8859-1"); workingCopy.setAttribute(ErlLaunchAttributes.NODE_NAME, info.getNodeName()); workingCopy.setAttribute(ErlLaunchAttributes.RUNTIME_NAME, info.getName()); workingCopy.setAttribute(ErlLaunchAttributes.COOKIE, info.getCookie()); workingCopy.setAttribute( ErlLaunchAttributes.CONSOLE, !options.contains(BackendOptions.NO_CONSOLE)); workingCopy.setAttribute(ErlLaunchAttributes.USE_LONG_NAME, false); return workingCopy; } catch (final CoreException e) { e.printStackTrace(); return null; } }
/** * Creates a launch configuration with the given name in the given location * * @param launchConfigName * @param path * @return the handle to the new launch configuration * @throws CoreException */ public static ILaunchConfiguration createLaunchConfiguration(String launchConfigName, String path) throws CoreException { ILaunchConfigurationType type = AbstractAntUITest.getLaunchManager() .getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE); ILaunchConfigurationWorkingCopy config = type.newInstance( AbstractAntUITest.getJavaProject().getProject().getFolder("launchConfigurations"), launchConfigName); //$NON-NLS-1$ config.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, AbstractAntUITest.getJavaProject().getElementName()); config.setAttribute( IExternalToolConstants.ATTR_LOCATION, "${workspace_loc:/" + path + "}"); // $NON-NLS-1$ //$NON-NLS-2$ config.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); config.doSave(); return config; }
private ILaunchConfiguration getLaunchConfiguration( final Collection<IErlProject> projects, final String mode) throws CoreException { final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final List<String> projectNames = getProjectNames(projects); String name = ListsUtils.packList(projectNames, "_"); if (name.length() > 15) { name = ListsUtils.packList(StringUtils.removeCommonPrefixes(projectNames), "_"); } // try and find one final ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(); for (final ILaunchConfiguration launchConfiguration : launchConfigurations) { if (launchConfiguration.getName().equals(name)) { if (mode.equals(ILaunchManager.DEBUG_MODE)) { return addInterpretedModules(projects, launchConfiguration); } return launchConfiguration; } } // try and make one final ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(ErlangLaunchDelegate.CONFIGURATION_TYPE); ILaunchConfigurationWorkingCopy wc = null; wc = launchConfigurationType.newInstance(null, name); wc.setAttribute( ErlLaunchAttributes.PROJECTS, ListsUtils.packList(projectNames, PROJECT_NAME_SEPARATOR)); wc.setAttribute( ErlLaunchAttributes.RUNTIME_NAME, projects.iterator().next().getRuntimeInfo().getName()); wc.setAttribute(ErlLaunchAttributes.NODE_NAME, name); wc.setAttribute(ErlLaunchAttributes.CONSOLE, true); wc.setAttribute(ErlLaunchAttributes.INTERNAL, false); wc.setAttribute(ErlLaunchAttributes.LOAD_ALL_NODES, false); wc.setAttribute(ErlLaunchAttributes.COOKIE, "erlide"); wc.setAttribute("org.eclipse.debug.core.environmentVariables", Maps.newHashMap()); if (mode.equals("debug")) { final List<String> moduleNames = getProjectAndModuleNames(projects); wc.setAttribute(ErlLaunchAttributes.DEBUG_INTERPRET_MODULES, moduleNames); } wc.setMappedResources(getProjectResources(projects)); return wc.doSave(); }
/** * Verifies that the classpath entry is valid and won't cause the launch to fail. * * @param entry The entry to validate. * @param serverProject The project that the test server will run out of. * @return true if it's valid */ public static boolean classpathEntryIsValid(String entry, IProject serverProject) { try { ILaunchConfigurationType type = DebugPlugin.getDefault() .getLaunchManager() .getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy copy = type.newInstance(null, "ezeTemp"); // $NON-NLS-1$ copy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, serverProject.getName()); copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false); List<String> classpath = new ArrayList<String>(1); classpath.add(entry); copy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath); JavaRuntime.resolveRuntimeClasspath( JavaRuntime.computeUnresolvedRuntimeClasspath(copy), copy); return true; } catch (CoreException ce) { return false; } }
/** * Creates a shared launch configuration for launching Ant in a separate VM with the given name. * * @since 3.5 */ public static void createLaunchConfigurationForSeparateVM( String launchConfigName, String buildFileName) throws Exception { String bf = buildFileName; ILaunchConfigurationType type = AbstractAntUITest.getLaunchManager() .getLaunchConfigurationType(IAntLaunchConstants.ID_ANT_LAUNCH_CONFIGURATION_TYPE); ILaunchConfigurationWorkingCopy config = type.newInstance( AbstractAntUITest.getJavaProject().getProject().getFolder("launchConfigurations"), launchConfigName); //$NON-NLS-1$ config.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "org.eclipse.ant.internal.launching.remote.InternalAntRunner"); //$NON-NLS-1$ config.setAttribute( IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, "org.eclipse.ant.ui.AntClasspathProvider"); //$NON-NLS-1$ config.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, AbstractAntUITest.getJavaProject().getElementName()); if (bf == null) { bf = launchConfigName; } config.setAttribute( IExternalToolConstants.ATTR_LOCATION, "${workspace_loc:/" + PROJECT_NAME + "/buildfiles/" + bf + ".xml}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ config.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); config.setAttribute( DebugPlugin.ATTR_PROCESS_FACTORY_ID, IAntUIConstants.REMOTE_ANT_PROCESS_FACTORY_ID); ProjectHelper.setVM(config); config.doSave(); }
protected void create(ILaunchConfigurationType configType) { try { ILaunchConfigurationWorkingCopy wc = configType.newInstance( null, DebugPlugin.getDefault() .getLaunchManager() .generateLaunchConfigurationName("New launch")); // TODO(devoncarew): init this launch config with a starting resource and name wc.doSave(); launchConfigurationDialog.selectLaunchConfiguration(wc.getName()); } catch (CoreException exception) { DebugErrorHandler.errorDialog( launchConfigurationDialog.getShell(), "Error Created Launch", "Unable to create the selected launch: " + exception.toString(), exception); } }
public static ILaunchConfiguration getLaunchConfiguration( IProject project, String script, boolean persist) throws CoreException { ILaunchConfigurationType configType = getLaunchConfigurationType(); IGrailsInstall install = GrailsCoreActivator.getDefault().getInstallManager().getGrailsInstall(project); if (install == null) { return null; } String nameAndScript = (script != null ? "(" + script + ")" : ""); if (project != null) { nameAndScript = project.getName() + " " + nameAndScript; } nameAndScript = sanitize(nameAndScript); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, nameAndScript); GrailsLaunchArgumentUtils.prepareLaunchConfiguration( project, script, install, GrailsBuildSettingsHelper.getBaseDir(project), wc); if (persist) { return wc.doSave(); } else { return wc; } }
public void exec(final IProject project, final IProgressMonitor monitor) { final ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType configType = lm.getLaunchConfigurationType( "org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); try { final String projectName = project.getName(); final ILaunchConfigurationWorkingCopy config = configType.newInstance( null, lm.generateLaunchConfigurationName(LAUT_ENTRY + " " + projectName)); config.setAttribute("org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", true); config.setAttribute("org.eclipse.debug.ui.ATTR_CAPTURE_IN_CONSOLE", true); config.setAttribute("org.eclipse.debug.ui.ATTR_PRIVATE", true); config.setAttribute( "org.eclipse.debug.core.ATTR_REFRESH_SCOPE", "${working_set:<?xml version=\"1.0\" encoding=\"UTF-8\"?><resources><item path=\"/" + project.getName() + "\" type=\"4\"/></resources>}"); config.setAttribute( "org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE", "${projects:" + projectName + "}"); config.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", getExecPath()); config.setAttribute( "org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", "-f \"" + project.getLocation().toOSString() + "\""); config.setAttribute( "org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY", getWorkingPath().toOSString()); new LaunchHelper().launch(config, ILaunchManager.RUN_MODE, monitor); } catch (CoreException e) { AlloyCore.logError("Problem launching laut tool.", e); } }
private boolean execMavenLaunch( final IProject project, final String goal, final IMavenProjectFacade facade, IProgressMonitor monitor) throws CoreException { final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(LAUNCH_CONFIGURATION_TYPE_ID); final IPath basedirLocation = project.getLocation(); final String newName = launchManager.generateLaunchConfigurationName(basedirLocation.lastSegment()); final ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName); workingCopy.setAttribute(ATTR_POM_DIR, basedirLocation.toString()); workingCopy.setAttribute(ATTR_GOALS, goal); workingCopy.setAttribute(ATTR_UPDATE_SNAPSHOTS, true); workingCopy.setAttribute(ATTR_WORKSPACE_RESOLUTION, true); workingCopy.setAttribute(ATTR_SKIP_TESTS, true); if (facade != null) { final ResolverConfiguration configuration = facade.getResolverConfiguration(); final String selectedProfiles = configuration.getSelectedProfiles(); if (selectedProfiles != null && selectedProfiles.length() > 0) { workingCopy.setAttribute(ATTR_PROFILES, selectedProfiles); } new LaunchHelper().launch(workingCopy, "run", monitor); return true; } else { return false; } }
protected ILaunchConfiguration createConfiguration(LaunchConfigurationInfo info) throws CoreException { ILaunchConfiguration config = null; ILaunchConfigurationWorkingCopy wc = null; final ILaunchConfigurationType configType = getLaunchManager() .getLaunchConfigurationType("migdb.dsl.ide.launch.OpsLaunchConfigurationType"); wc = configType.newInstance( null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(info.name)); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, info.project); wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, MigDbLauncher.class.getName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, false); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, info.opsFile); wc.setAttribute(RefreshTab.ATTR_REFRESH_SCOPE, "${workspace}"); wc.setAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, true); config = wc.doSave(); return config; }
public static boolean deployModel( List<IResource> resources, String carnotHome, String carnotWork) { boolean deployed = false; if (null != resources && !resources.isEmpty()) { try { IProject project = getCommonProject(resources); ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType( IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy wc = type.newInstance(null, "Infinity Process Model Deployment"); // $NON-NLS-1$ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName()); wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, ModelingCoreActivator.ID_DEPLOY_MODEL_CP_PROVIDER); wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, ModelDeploymentTool.class.getName()); // Activate if debugging deployment is needed. // String debug = // " -Xdebug -Xnoagent -Djava.compiler=NONE // -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"; // String debug = // " -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"; wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "-Xms50m -Xmx256m" + getLocaleArgs()); // $NON-NLS-1$ // "-Xms50m -Xmx256m" + debug); boolean version = PlatformUI.getPreferenceStore().getBoolean(BpmProjectNature.PREFERENCE_DEPLOY_version); String realm = PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_realm); String partition = PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_partition); String user = PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_id); String password = PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_password); String domain = PlatformUI.getPreferenceStore().getString(BpmProjectNature.PREFERENCE_DEPLOY_domain); StringBuilder programAttributes = new StringBuilder(); boolean separator = false; for (IResource resource : resources) { // addArgument(programAttributes, "filename64", resource.getLocation().toOSString(), true, // separator); // separator = true; try { String fileName = resource.getLocation().toOSString(); String encodedFileName = new String(Base64.encode(fileName.getBytes(XpdlUtils.UTF8_ENCODING))); addArgument( programAttributes, "filename64", encodedFileName, false, separator); // $NON-NLS-1$ separator = true; } catch (UnsupportedEncodingException e) { // should never happen since UTF-8 is standard supported on all java versions. e.printStackTrace(); } } if (version) { addArgument( programAttributes, "version", Boolean.TRUE.toString(), false, true); //$NON-NLS-1$ //$NON-NLS-2$ } if (!StringUtils.isEmpty(user) && !StringUtils.isEmpty(password)) { addArgument(programAttributes, "user", user, true, true); // $NON-NLS-1$ addArgument( programAttributes, "password", password, true, true); // $NON-NLS-1$ if (!StringUtils.isEmpty(realm)) { addArgument(programAttributes, "realm", realm, true, true); // $NON-NLS-1$ } if (!StringUtils.isEmpty(partition)) { addArgument( programAttributes, "partition", partition, true, true); // $NON-NLS-1$ } if (!StringUtils.isEmpty(domain)) { addArgument(programAttributes, "domain", domain, true, true); // $NON-NLS-1$ } } wc.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programAttributes.toString()); wc.setAttribute(CarnotToolClasspathProvider.ATTR_HOME_LOCATION, carnotHome); wc.setAttribute(CarnotToolClasspathProvider.ATTR_WORK_LOCATION, carnotWork); wc.setAttribute( CarnotToolClasspathProvider.ATTR_EXTRA_LOCATION, BpmCoreLibrariesClasspathContainer.getLibraryLocation( DeployPlugin.PLUGIN_ID, new String[] {"bin", ""}) .toString()); //$NON-NLS-1$ //$NON-NLS-2$ ILaunchConfiguration config = wc.doSave(); ILaunch toolLaunch = config.launch(ILaunchManager.RUN_MODE, null); deployed = (0 < toolLaunch.getProcesses().length); config.delete(); wc.delete(); } catch (CoreException e) { // TODO e.printStackTrace(); } } return deployed; }
private ILaunchConfiguration getLaunchConfiguration(IContainer basedir, String mode) { if (goalName != null) { return createLaunchConfiguration(basedir, goalName); } ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID); // scan existing launch configurations IPath basedirLocation = basedir.getLocation(); if (!showDialog) { try { // ILaunch[] launches = launchManager.getLaunches(); // ILaunchConfiguration[] launchConfigurations = null; // if(launches.length > 0) { // for(int i = 0; i < launches.length; i++ ) { // ILaunchConfiguration config = launches[i].getLaunchConfiguration(); // if(config != null && launchConfigurationType.equals(config.getType())) { // launchConfigurations = new ILaunchConfiguration[] {config}; // } // } // } // if(launchConfigurations == null) { // launchConfigurations = // launchManager.getLaunchConfigurations(launchConfigurationType); // } ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(launchConfigurationType); ArrayList<ILaunchConfiguration> matchingConfigs = new ArrayList<ILaunchConfiguration>(); for (ILaunchConfiguration configuration : launchConfigurations) { // substitute variables String workDir = LaunchingUtils.substituteVar( configuration.getAttribute(MavenLaunchConstants.ATTR_POM_DIR, (String) null)); if (workDir == null) { continue; } IPath workPath = new Path(workDir); if (basedirLocation.equals(workPath)) { matchingConfigs.add(configuration); } } if (matchingConfigs.size() == 1) { log.info("Using existing launch configuration"); return matchingConfigs.get(0); } else if (matchingConfigs.size() > 1) { final IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation(); ElementListSelectionDialog dialog = new ElementListSelectionDialog( getShell(), // new ILabelProvider() { public Image getImage(Object element) { return labelProvider.getImage(element); } public String getText(Object element) { if (element instanceof ILaunchConfiguration) { ILaunchConfiguration configuration = (ILaunchConfiguration) element; try { return labelProvider.getText(element) + " : " + configuration.getAttribute(MavenLaunchConstants.ATTR_GOALS, ""); } catch (CoreException ex) { // ignore } } return labelProvider.getText(element); } public boolean isLabelProperty(Object element, String property) { return labelProvider.isLabelProperty(element, property); } public void addListener(ILabelProviderListener listener) { labelProvider.addListener(listener); } public void removeListener(ILabelProviderListener listener) { labelProvider.removeListener(listener); } public void dispose() { labelProvider.dispose(); } }); dialog.setElements( matchingConfigs.toArray(new ILaunchConfiguration[matchingConfigs.size()])); dialog.setTitle(Messages.ExecutePomAction_dialog_title); if (mode.equals(ILaunchManager.DEBUG_MODE)) { dialog.setMessage(Messages.ExecutePomAction_dialog_debug_message); } else { dialog.setMessage(Messages.ExecutePomAction_dialog_run_message); } dialog.setMultipleSelection(false); int result = dialog.open(); labelProvider.dispose(); return result == Window.OK ? (ILaunchConfiguration) dialog.getFirstResult() : null; } } catch (CoreException ex) { log.error(ex.getMessage(), ex); } } log.info("Creating new launch configuration"); String newName = launchManager.generateUniqueLaunchConfigurationNameFrom(basedirLocation.lastSegment()); try { ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, newName); workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, basedirLocation.toString()); setProjectConfiguration(workingCopy, basedir); // set other defaults if needed // MavenLaunchMainTab maintab = new MavenLaunchMainTab(); // maintab.setDefaults(workingCopy); // maintab.dispose(); return workingCopy.doSave(); } catch (Exception ex) { log.error("Error creating new launch configuration", ex); } return null; }
protected ILaunchConfiguration createLaunchConfiguration(IContainer basedir, String goal) { try { ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID); String launchSafeGoalName = goal.replace(':', '-'); ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance( null, // NLS.bind( org.eclipse.m2e.internal.launch.Messages.ExecutePomAction_executing, launchSafeGoalName, basedir.getLocation().toString().replace('/', '-'))); workingCopy.setAttribute( MavenLaunchConstants.ATTR_POM_DIR, basedir.getLocation().toOSString()); workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, goal); workingCopy.setAttribute(ILaunchManager.ATTR_PRIVATE, true); workingCopy.setAttribute( RefreshUtil.ATTR_REFRESH_SCOPE, RefreshUtil.MEMENTO_SELECTED_PROJECT); workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_RECURSIVE, true); // seems no need refresh project, so won't set it. // workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, // basedir.getProject().getName()); // --------------Special settings for Talend---------- if (isCaptureOutputInConsoleView()) { // by default will catch the output in console. so set null workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, (String) null); } else { workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, Boolean.FALSE.toString()); } // not same, set it. Else use the preference directly. if (debugOutput != MavenPlugin.getMavenConfiguration().isDebugOutput()) { workingCopy.setAttribute(MavenLaunchConstants.ATTR_DEBUG_OUTPUT, this.debugOutput); // -X -e } // -Dmaven.test.skip=true -DskipTests workingCopy.setAttribute(MavenLaunchConstants.ATTR_SKIP_TESTS, this.skipTests); // ------------------------ setProjectConfiguration(workingCopy, basedir); IPath path = getJREContainerPath(basedir); if (path != null) { workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, path.toPortableString()); } String programArgs = getArgumentValue(TalendProcessArgumentConstant.ARG_PROGRAM_ARGUMENTS); if (StringUtils.isNotEmpty(programArgs)) { workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, programArgs); } // TODO when launching Maven with debugger consider to add the following property // -Dmaven.surefire.debug="-Xdebug // -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent // -Djava.compiler=NONE" return workingCopy; } catch (CoreException ex) { ExceptionHandler.process(ex); } return null; }