List of usage examples for org.eclipse.jdt.core IJavaProject setOption
void setOption(String optionName, String optionValue);
From source file:org.eclipse.wb.tests.designer.core.util.ast.AstEditorTest.java
License:Open Source License
/** * If project configured to consider {@link JavaCore#COMPILER_PB_UNNECESSARY_TYPE_CHECK} as error, * we may fail, because we declare visible variables with casts. *//*from w w w . ja va 2s . co m*/ public void test_ASTParser_parseExpression_warning_unnecessaryCast() throws Exception { createTypeDeclaration_Test("public class Test {", " public Test() {", " Object var;", " // marker", " }", "}"); // configure IJavaProject to handle warning as error { IJavaProject javaProject = m_lastEditor.getModelUnit().getJavaProject(); javaProject.setOption(JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK, "error"); } // parse expression try { int position = m_lastEditor.indexOf("// marker"); String expressionSource = "var = (java.lang.Object) null"; check_ASTParser_parseExpression(position, expressionSource); } finally { do_projectDispose(); } }
From source file:org.gololang.gldt.jdt.internal.GoloProject.java
License:Apache License
/** * Exclude all Golo files from compilation * //from ww w .j a v a2 s . co m * @param javaProject */ public static void excludeGoloFilesFromOutput(final IProject project) { // make sure .golo files are not copied to the output dir IJavaProject javaProject = JavaCore.create(project); if (javaProject != null) { String excludedResources = javaProject.getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true); if (excludedResources.indexOf(GoloJdtConstants.GOLO_FILE_FILTER) == -1) { excludedResources = excludedResources.length() == 0 ? GoloJdtConstants.GOLO_FILE_FILTER : excludedResources + ',' + GoloJdtConstants.GOLO_FILE_FILTER; javaProject.setOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, excludedResources); } } }
From source file:org.gololang.gldt.jdt.internal.GoloProject.java
License:Apache License
/** * Include all Golo files for compilation * // ww w.j a v a 2 s.co m * @param project */ public static void includeGoloFilesInOutput(final IProject project) { // make sure .golo files are not copied to the output dir IJavaProject javaProject = JavaCore.create(project); if (javaProject != null) { final String[] excludedResourcesArray = javaProject .getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true).split(","); final List<String> excludedResources = new ArrayList<String>(); for (int i = 0; i < excludedResourcesArray.length; i++) { final String excluded = excludedResourcesArray[i].trim(); if (excluded.endsWith(GoloJdtConstants.GOLO_FILE_FILTER)) continue; excludedResources.add(excluded); } javaProject.setOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, Joiner.on(',').join(excludedResources)); } }
From source file:org.hibernate.eclipse.console.test.project.TestProject.java
License:Open Source License
protected IJavaProject buildJavaProject(IProject project) { IJavaProject javaProject = JavaCore.create(project); try {//ww w. j a v a2 s . c o m addJavaNature(); } catch (CoreException ce) { throw new RuntimeException(ce); } javaProject.setOption(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); javaProject.setOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5); javaProject.setOption(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5); return javaProject; }
From source file:org.maven.ide.eclipse.embedder.BuildPathManager.java
License:Apache License
private void setOption(IJavaProject javaProject, Map options, String name) { String newValue = (String) options.get(name); if (newValue == null) { newValue = (String) JavaCore.getDefaultOptions().get(name); }//from w w w . j a v a2 s. c om String currentValue = javaProject.getOption(name, false); if (!newValue.equals(currentValue)) { javaProject.setOption(name, newValue); } }
From source file:org.talend.designer.maven.tools.creator.CreateMavenCodeProject.java
License:Open Source License
/** * Clear compliance settings from project, and set them into Eclipse compliance settings * //from w ww . j a va2 s . com * @param javaProject */ private static void clearProjectIndenpendComplianceSettings(IJavaProject javaProject) { Map<String, String> projectComplianceOptions = javaProject.getOptions(false); if (projectComplianceOptions == null || projectComplianceOptions.isEmpty()) { return; } String compilerCompliance = javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, false); // clear compliance settings from project Set<String> keySet = projectComplianceOptions.keySet(); for (String key : keySet) { javaProject.setOption(key, null); } IEclipsePreferences pluginPreferences = InstanceScope.INSTANCE.getNode(DesignerMavenPlugin.PLUGIN_ID); boolean isAlreadySetEclipsePreferences = pluginPreferences.getBoolean(IS_ALREADY_SET_ECLIPSE_COMPLIANCE, false); // if already setted them, then can't modify them anymore since user can customize them. if (!isAlreadySetEclipsePreferences) { pluginPreferences.putBoolean(IS_ALREADY_SET_ECLIPSE_COMPLIANCE, true); if (compilerCompliance != null) { IEclipsePreferences eclipsePreferences = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID); // set compliance settings to Eclipse Map<String, String> complianceOptions = new HashMap<String, String>(); JavaCore.setComplianceOptions(compilerCompliance, complianceOptions); if (!complianceOptions.isEmpty()) { Set<Entry<String, String>> entrySet = complianceOptions.entrySet(); for (Entry<String, String> entry : entrySet) { eclipsePreferences.put(entry.getKey(), entry.getValue()); } } try { // save changes eclipsePreferences.flush(); pluginPreferences.flush(); } catch (BackingStoreException e) { ExceptionHandler.process(e); } } } }
From source file:org.talend.designer.maven.utils.MavenProjectUtils.java
License:Open Source License
/** * Clear compliance settings from project, and set them into Eclipse compliance settings * // ww w . j a v a2 s. c om * @param javaProject */ private static void clearProjectIndenpendComplianceSettings(IJavaProject javaProject) { Map<String, String> projectComplianceOptions = javaProject.getOptions(false); if (projectComplianceOptions == null || projectComplianceOptions.isEmpty()) { return; } String compilerCompliance = JavaUtils.getProjectJavaVersion(); // clear compliance settings from project Set<String> keySet = projectComplianceOptions.keySet(); for (String key : keySet) { javaProject.setOption(key, null); } if (compilerCompliance != null) { IEclipsePreferences eclipsePreferences = InstanceScope.INSTANCE.getNode(JavaCore.PLUGIN_ID); // set compliance settings to Eclipse Map<String, String> complianceOptions = new HashMap<String, String>(); JavaCore.setComplianceOptions(compilerCompliance, complianceOptions); if (!complianceOptions.isEmpty()) { Set<Entry<String, String>> entrySet = complianceOptions.entrySet(); for (Entry<String, String> entry : entrySet) { eclipsePreferences.put(entry.getKey(), entry.getValue()); } } try { // save changes eclipsePreferences.flush(); } catch (BackingStoreException e) { ExceptionHandler.process(e); } } }