ILaunchConfigurationWorkingCopy workingCopy = launchConfig.getWorkingCopy(); workingCopy.delete(); ILaunchConfigurationType launchType = launchConfig.getType(); IContainer container = launchConfig.getFile() == null ? null : launchConfig.getFile().getParent(); ILaunchConfigurationWorkingCopy newLaunchConfig = launchType.newInstance( container, workingCopy.getName() ); // copy all attributes from 'launchConfig' to 'newLaunchConfig' newLaunchConfig.doSave();
private ILaunchConfiguration createLaunchConfiguration(GradleRunConfigurationAttributes configurationAttributes) { // derive the name of the launch configuration from the configuration attributes // since the launch configuration name must not contain ':', we replace all ':' with '.' String taskNamesOrDefault = configurationAttributes.getTasks().isEmpty() ? "(default tasks)" : CollectionsUtils.joinWithSpace(configurationAttributes.getTasks()); String rawLaunchConfigurationName = String.format("%s - %s", configurationAttributes.getWorkingDir().getName(), taskNamesOrDefault); String launchConfigurationName = this.launchManager.generateLaunchConfigurationName(rawLaunchConfigurationName.replace(':', '.')); ILaunchConfigurationType launchConfigurationType = this.launchManager.getLaunchConfigurationType(GradleRunConfigurationDelegate.ID); try { // create new launch configuration instance ILaunchConfigurationWorkingCopy launchConfiguration = launchConfigurationType.newInstance(null, launchConfigurationName); // configure the launch configuration configurationAttributes.apply(launchConfiguration); // try to persist the launch configuration and return it return persistConfiguration(launchConfiguration); } catch (CoreException e) { throw new GradlePluginsRuntimeException(String.format("Cannot create Gradle launch configuration %s.", launchConfigurationName), e); } }
public static ILaunchConfigurationWorkingCopy createBasicConfiguration(final ILaunchManager launchManager, final IProject project, final String confName) { ILaunchConfigurationWorkingCopy wConf = null; try { ILaunchConfigurationType configurationType = launchManager.getLaunchConfigurationType(TestNGLaunchConfigurationConstants.ID_TESTNG_APPLICATION); wConf = configurationType.newInstance(null /*project*/, confName); // launchManager.generateUniqueLaunchConfigurationNameFrom(confName)); wConf.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, RemoteTestNG.class.getName()); wConf.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName()); } catch(CoreException ce) { TestNGPlugin.log(ce); } return wConf; }
/** * Creates an {@link ILaunchConfiguration} from the given set of {@link ILaunchConfigurationType}s * @param types the set of {@link String} {@link ILaunchConfigurationType} identifiers * @return a new {@link ILaunchConfiguration} * @since 3.6 */ private ILaunchConfiguration createConfigurationFromTypes(Set<String> types) { //context launching always takes the first type, so we do that here as well if(types != null && types.size() > 0) { try { ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType((String) types.toArray()[0]); ILaunchConfigurationWorkingCopy copy = type.newInstance(null, DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(LaunchConfigurationsMessages.CreateLaunchConfigurationAction_New_configuration_2)); return copy; } catch(CoreException ce) { //do nothing return null } } return null; }
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType antType = launchManager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE); ILaunchConfigurationWorkingCopy workingCopy = antType.newInstance(BuilderUtils.getBuilderFolder(project, true), "lstest" ); workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false); workingCopy.setAttribute(IExternalToolConstants.ATTR_LOCATION, "${project_loc}\\YOUR_SHELL_SCRIPT"); workingCopy.setAttribute(....); ILaunchConfiguration ilc = workingCopy.doSave();
/** * Creates a launch configuration that can be used to launch a ILaunch that debug an external client connection. * * @param sd * @param connid * @return */ public static ILaunchConfigurationWorkingCopy createExternalClientConfiguration(DatabaseIdentifier databaseIdentifier, String connid) throws CoreException { ILaunchConfigurationWorkingCopy wc = null; ILaunchConfigurationType configType = getLaunchConfigType(); wc = configType.newInstance(null, "externalCon" + connid); wc.setAttribute(ROUTINE_LAUNCH_PROFILENAME, databaseIdentifier.getProfileName()); wc.setAttribute(ROUTINE_LAUNCH_DATABASENAME, databaseIdentifier.getDBname()); wc.setAttribute(ROUTINE_LAUNCH_EXTERNALID, connid); return wc; }
protected ILaunchConfiguration createConfiguration(IJavaProject type) throws Exception { ILaunchConfiguration config = null; ILaunchConfigurationWorkingCopy wc = null; ILaunchConfigurationType configType = getConfigurationType(); wc = configType.newInstance(null, getLaunchManager() .generateUniqueLaunchConfigurationNameFrom( type.getElementName())); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getElementName()); config = wc.doSave(); return config; }
protected ILaunchConfiguration createConfiguration(IJavaProject type) throws Exception { ILaunchConfiguration config = null; ILaunchConfigurationWorkingCopy wc = null; ILaunchConfigurationType configType = getConfigurationType(); wc = configType.newInstance(null, getLaunchManager() .generateUniqueLaunchConfigurationNameFrom( type.getElementName())); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getElementName()); config = wc.doSave(); return config; }
/** * Creates default launch configuration that launch given target. */ public ILaunchConfiguration createDefaultLaunchConfiguration(ILaunchRequest request) { try { // Configuration will reside in workspace meta area. IContainer configContainer = null; ILaunchConfigurationWorkingCopy wc = getLaunchManager().getLaunchConfigurationType( getDefaultLaunchConfigurationTypeID()).newInstance(configContainer, generateUniqueLaunchConfigurationName()); initDefaultLaunchConfiguration(wc, request); return wc.doSave(); } catch (Exception e) { handleException(e); return null; } }
/** * Create a temporary launch with the given id and name. This launch is not yet registered with * the ILaunchManager. * * @param id * @param name * @return * @throws CoreException */ public static ILaunch createTemporaryLaunch(String id, String name) throws CoreException { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(id); ILaunchConfigurationWorkingCopy launchConfig = type.newInstance( null, manager.generateLaunchConfigurationName(name)); // TODO(devoncarew): is this necessary? launchConfig.delete(); SDBGSourceLookupDirector sourceLookupDirector = new SDBGSourceLookupDirector(); sourceLookupDirector.initializeDefaults(launchConfig); return new Launch(launchConfig, ILaunchManager.DEBUG_MODE, sourceLookupDirector); }
/** * Returns a default collection of source locations for * the given Java project. Default source locations consist * of the given project and all of its required projects . * * @param project Java project * @return a collection of source locations for all required * projects * @exception CoreException if an exception occurs reading * computing the default locations */ public static IJavaSourceLocation[] getDefaultSourceLocations(IJavaProject project) throws CoreException { // create a temporary launch config ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy config = type.newInstance(null, project.getElementName()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getElementName()); JavaSourceLocator locator = new JavaSourceLocator(); locator.initializeDefaults(config); return locator.getSourceLocations(); }
/** * Returns a default collection of source locations for * the given Java project. Default source locations consist * of the given project and all of its required projects . * * @param project Java project * @return a collection of source locations for all required * projects * @exception CoreException if an exception occurs reading * computing the default locations */ public static IJavaSourceLocation[] getDefaultSourceLocations(IJavaProject project) throws CoreException { // create a temporary launch config ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy config = type.newInstance(null, project.getElementName()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getElementName()); JavaSourceLocator locator = new JavaSourceLocator(); locator.initializeDefaults(config); return locator.getSourceLocations(); }
protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null; ILaunchConfigurationWorkingCopy wc = null; try { ILaunchConfigurationType configType = getAJConfigurationType(); wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName())); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); config = wc.doSave(); } catch (CoreException exception) { reportErorr(exception); } return config; }
/** * Create, initialize and return a new launch configuration of the given type * * @return a new, properly-initialized launch configuration */ private ILaunchConfiguration createNewConfiguration() { try { ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = lm.getLaunchConfigurationType(getLaunchConfigurationTypeName()); String name = lm.generateLaunchConfigurationName(getName(type)); ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name); initializeConfiguration(wc); // set a flag to know the information in the new config was generated by PDE wc.setAttribute(IPDEUIConstants.GENERATED_CONFIG, true); return wc.doSave(); } catch (CoreException ce) { PDEPlugin.logException(ce); } return null; }
/** initialize the launch configuration. * * @param configurationType the name of the configuration type to create. * @param projectName the name of the project. * @param id the identifier of the launch configuration. * @param resetJavaMainClass indicates if the JAva main class should be reset from the SRE configuration. * @return the created launch configuration. * @throws CoreException if the configuration cannot be created. * @since 0.7 */ protected ILaunchConfigurationWorkingCopy initLaunchConfiguration(String configurationType, String projectName, String id, boolean resetJavaMainClass) throws CoreException { final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType(configurationType); final ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, launchManager.generateLaunchConfigurationName(id)); setProjectName(wc, projectName); setDefaultContextIdentifier(wc, null); setLaunchingFlags(wc, DEFAULT_SHOW_LOGO, DEFAULT_SHOW_LOG_INFO, DEFAULT_OFFLINE); setRuntimeConfiguration(wc, SARLRuntime.getDefaultSREInstall(), DEFAULT_USE_SYSTEM_SRE, DEFAULT_USE_PROJECT_SRE, resetJavaMainClass); JavaMigrationDelegate.updateResourceMapping(wc); return wc; }
private ILaunchConfiguration createConfiguration() throws CoreException { ILaunchConfigurationType configType = getWorkbenchLaunchConfigType(); String computedName = getComputedName(new Path(fPath).lastSegment()); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, computedName); wc.setAttribute(IPDELauncherConstants.LOCATION, LaunchArgumentsHelper.getDefaultWorkspaceLocation(computedName)); wc.setAttribute(IPDELauncherConstants.USEFEATURES, false); wc.setAttribute(IPDELauncherConstants.USE_DEFAULT, false); wc.setAttribute(IPDELauncherConstants.DOCLEAR, false); wc.setAttribute(IPDEConstants.DOCLEARLOG, false); wc.setAttribute(IPDEConstants.APPEND_ARGS_EXPLICITLY, true); wc.setAttribute(IPDELauncherConstants.ASKCLEAR, true); wc.setAttribute(IPDELauncherConstants.USE_PRODUCT, true); wc.setAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, true); wc.setAttribute(IPDELauncherConstants.AUTOMATIC_ADD, false); wc.setAttribute(IPDELauncherConstants.PRODUCT_FILE, fPath); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, PDESourcePathProvider.ID); return refreshConfiguration(wc); }
/** * Creates and saves template launch configuration for the given scrapbook file. */ public static ILaunchConfiguration createLaunchConfigurationTemplate(IFile page) throws CoreException { ILaunchConfigurationType lcType = getLaunchManager().getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); String name = MessageFormat.format(SnippetMessages.getString("ScrapbookLauncher.17"), new String[]{page.getName()}); //$NON-NLS-1$ ILaunchConfigurationWorkingCopy wc = lcType.newInstance(null, name); wc.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "org.eclipse.jdt.internal.debug.ui.snippeteditor.ScrapbookMain"); //$NON-NLS-1$ wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, page.getProject().getName()); wc.setAttribute(SCRAPBOOK_LAUNCH, SCRAPBOOK_LAUNCH); wc.setAttribute(SCRAPBOOK_FILE_PATH, page.getFullPath().toString()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, "org.eclipse.jdt.debug.ui.scrapbookSourcepathProvider"); //$NON-NLS-1$ JavaMigrationDelegate.updateResourceMapping(wc); ILaunchConfiguration config = wc.doSave(); setLaunchConfigMemento(page, config.getMemento()); return config; }
protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null; ILaunchConfigurationWorkingCopy wc = null; try { ILaunchConfigurationType configType = getConfigurationType(); wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName())); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); //CONTEXTLAUNCHING wc.setMappedResources(new IResource[] {type.getUnderlyingResource()}); config = wc.doSave(); } catch (CoreException exception) { reportErorr(exception); } return config; }
protected ILaunchConfiguration createLaunchConfiguration(IProgressMonitor monitor) throws CoreException { ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(LAUNCH_CONFIGURATION_TYPE_ID); ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(null, "-mavenBuild" + BUILD_NAME_NUM.getAndIncrement()); workingCopy.setAttribute(WORKING_DIRECTORY, getBuild().getWorkingDirectory().getAbsolutePath()); workingCopy.setAttribute(ILaunchManager.ATTR_PRIVATE, true); workingCopy.setAttribute(M2_UPDATE_SNAPSHOTS, getBuild().hasOption(CLIManager.UPDATE_SNAPSHOTS)); workingCopy.setAttribute(M2_OFFLINE, getBuild().hasOption(CLIManager.OFFLINE)); workingCopy.setAttribute(M2_SKIP_TESTS, getBuild().getProperties().containsKey(M2_SKIP_TEST)); workingCopy.setAttribute(M2_NON_RECURSIVE, getBuild().hasOption(CLIManager.NON_RECURSIVE)); workingCopy.setAttribute(M2_WORKSPACE_RESOLUTION, true); workingCopy.setAttribute(M2_DEBUG_OUTPUT, SdkLog.isDebugEnabled() || getBuild().hasOption(CLIManager.DEBUG)); workingCopy.setAttribute(M2_THREADS, 1); // not supported yet: "M2_PROFILES" and "M2_USER_SETTINGS" workingCopy.setAttribute(M2_PROPERTIES, getBuild().getPropertiesAsList()); setGoals(workingCopy, getBuild().getGoals()); IContainer container = getWorkspaceContainer(); setProjectConfiguration(workingCopy, container, monitor); setJreContainerPath(workingCopy, container); return workingCopy; }
protected ILaunchConfiguration createConfiguration(IType type) { ILaunchConfiguration config = null; try { ILaunchConfigurationType configType = getConfigurationType(); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, DebugPlugin.getDefault().getLaunchManager().generateUniqueLaunchConfigurationNameFrom(type.getElementName())); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, AppletParametersTab.DEFAULT_APPLET_WIDTH); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, AppletParametersTab.DEFAULT_APPLET_HEIGHT); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, ""); //$NON-NLS-1$ //CONTEXTLAUNCHING wc.setMappedResources(new IResource[] {type.getUnderlyingResource()}); config = wc.doSave(); } catch (CoreException ce) { reportErorr(ce); } return config; }