当前位置: 首页>>代码示例>>Java>>正文


Java IJavaProject.setOutputLocation方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.IJavaProject.setOutputLocation方法的典型用法代码示例。如果您正苦于以下问题:Java IJavaProject.setOutputLocation方法的具体用法?Java IJavaProject.setOutputLocation怎么用?Java IJavaProject.setOutputLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.IJavaProject的用法示例。


在下文中一共展示了IJavaProject.setOutputLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createProject

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static IJavaProject createProject(String name) throws CoreException {

		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
		IProject project = root.getProject(name);
		if (!project.exists()) {
			project.create(new NullProgressMonitor());
		} else {
			project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
		}

		if (!project.isOpen()) {
			project.open(new NullProgressMonitor());
		}

		IFolder binFolder = project.getFolder("bin");
		if (!binFolder.exists()) {
			createFolder(binFolder, false, true, new NullProgressMonitor());
		}
		IPath outputLocation = binFolder.getFullPath();

		addNatureToProject(project, JavaCore.NATURE_ID, new NullProgressMonitor());

		IJavaProject jproject = JavaCore.create(project);
		jproject.setOutputLocation(outputLocation, new NullProgressMonitor());

		IClasspathEntry[] entries = PreferenceConstants.getDefaultJRELibrary();

		jproject.setRawClasspath(entries, new NullProgressMonitor());

		return jproject;
	}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:32,代码来源:ProjectHelper.java

示例2: createProject

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * This method creates a new java project based on the user inputs, captured in WizardInput object.
 * The new project is created in the current workspace.
 * @param wizardInput
 * @return IJavaProject
 * @throws CoreException
 * @throws IOException
 **/
public IJavaProject createProject(WizardInput wizardInput) throws CoreException, IOException
{
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(wizardInput.getProjectName());
	project.create(null);
	project.open(null);		
	IProjectDescription description = project.getDescription();
	description.setNatureIds(new String[] { JavaCore.NATURE_ID });
	project.setDescription(description, null);
	IJavaProject javaProject = JavaCore.create(project); 
	IFolder binFolder = project.getFolder("bin");
	binFolder.create(false, true, null);
	javaProject.setOutputLocation(binFolder.getFullPath(), null);
	List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
	IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
	LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
	for (LibraryLocation element : locations) {
	 entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
	}
	InputStream is = new BufferedInputStream(new FileInputStream(wizardInput.getSootPath().toOSString()));
    IFile jarFile = project.getFile("soot-trunk.jar");
    jarFile.create(is, false, null);
    IPath path = jarFile.getFullPath();
    entries.add(JavaCore.newLibraryEntry(path, null, null));
	javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);		
	IFolder sourceFolder = project.getFolder("src");
	sourceFolder.create(false, true, null);
	IPackageFragmentRoot root1 = javaProject.getPackageFragmentRoot(sourceFolder);
	IClasspathEntry[] oldEntries = javaProject.getRawClasspath();
	IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1];
	System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length);
	newEntries[oldEntries.length] = JavaCore.newSourceEntry(root1.getPath());
	javaProject.setRawClasspath(newEntries, null);
	String filepath = sourceFolder.getLocation().toOSString();
	File file = new File(filepath);
	wizardInput.setFile(file);
	try {
		CodeGenerator.generateSource(wizardInput);
	} catch (JClassAlreadyExistsException e) {
		e.printStackTrace();
	}
	sourceFolder.refreshLocal(1, null);
	javaProject.open(null);
	return javaProject;
}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:54,代码来源:ProjectGenerator.java

示例3: createProject

import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
 * Creates the custom project structure at the specified location and name
 * The Project will have below natures:<br>
 * <b>Java</b> and Custom nature as per <b>ETL</b> project
 * @param projectName Project name
 * @param location Where should the project be saved
 * @return
 */
public IProject createProject(String projectName, URI location){
	if (StringUtils.isNotBlank(projectName) && projectName.contains(" ")){
		MessageBox messageBox = new MessageBox(new Shell(), SWT.ICON_ERROR | SWT.OK);
		messageBox.setText("Error");
		messageBox.setMessage("The Project Name has spaces");
		if(messageBox.open()==SWT.OK)
		{
			return null;
		}
	}
	else if(StringUtils.isBlank(projectName)){
		throw new InvalidProjectNameException();
	}
	IProject project = null;
	try {
		project = createBaseProject(projectName, location);
		if(project!=null)
		{
			addNature(project);
			addToProjectStructure(project, paths);
			IJavaProject javaProject = JavaCore.create(project);

			IFolder binFolder = project.getFolder(CustomMessages.ProjectSupport_BIN);
			javaProject.setOutputLocation(binFolder.getFullPath(), null);

			List<IClasspathEntry> entries = addJavaLibrariesInClassPath();

			IFolder libFolder = project.getFolder(CustomMessages.ProjectSupport_LIB);

			//add libs to project class path 
			String installLocation = Platform.getInstallLocation().getURL().getPath();

			//copyExternalLibAndAddToClassPath(installLocation + CustomMessages.ProjectSupport_LIB, libFolder, entries);

			copyBuildFile(installLocation + CustomMessages.ProjectSupport_CONFIG_FOLDER + "/" + 
					CustomMessages.ProjectSupport_GRADLE + "/" + BUILD, project);
			
			copyBuildFile(installLocation + CustomMessages.ProjectSupport_CONFIG_FOLDER + "/" + 
					CustomMessages.ProjectSupport_GRADLE + "/" + PROPERTIES, project);
			
			copyBuildFile(installLocation + CustomMessages.ProjectSupport_CONFIG_FOLDER + "/" + 
					MAVEN, project);
			
			updateMavenFile(POM_XML, project);
			
			javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);

			//set source folder entry in classpath
			javaProject.setRawClasspath(setSourceFolderInClassPath(project, javaProject), null);
		}
	} catch (CoreException e) {
		logger.debug("Failed to create Project with parameters as projectName : {} location : {}, exception : {}", 
				new Object[]{projectName, location, e});
		project = null;
	}

	return project;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:67,代码来源:ProjectStructureCreator.java


注:本文中的org.eclipse.jdt.core.IJavaProject.setOutputLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。