List of usage examples for org.eclipse.jdt.core JavaCore CORE_JAVA_BUILD_RESOURCE_COPY_FILTER
String CORE_JAVA_BUILD_RESOURCE_COPY_FILTER
To view the source code for org.eclipse.jdt.core JavaCore CORE_JAVA_BUILD_RESOURCE_COPY_FILTER.
Click Source Link
From source file:com.javadude.antxr.eclipse.core.AntxrCorePlugin.java
License:Open Source License
/** {@inheritDoc} */ @Override//from ww w.ja v a 2 s.c o m @SuppressWarnings("unchecked") public void start(BundleContext context) throws Exception { super.start(context); // Add ANTXR grammar files to JDT builder's copy exclusion filter Hashtable options = JavaCore.getOptions(); String filter = (String) options.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER); StringTokenizer st = new StringTokenizer(filter, ","); boolean found = false; while (st.hasMoreTokens()) { if (st.nextToken().equals("*.antxr")) { found = true; break; } } if (!found) { if (AntxrCorePlugin.isDebug()) { System.out.println("Adding '*.antxr' to JDT builder's " + "resource filter (" + filter + ")"); } options.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, filter + ",*.antxr"); JavaCore.setOptions(options); } }
From source file:net.sf.j2s.core.builder.JavaBuilder.java
License:Open Source License
private int initializeBuilder(int kind, boolean forBuild) throws CoreException { // some calls just need the nameEnvironment initialized so skip the rest this.javaProject = (JavaProject) JavaCore.create(this.currentProject); this.workspaceRoot = this.currentProject.getWorkspace().getRoot(); if (forBuild) { // cache the known participants for this project this.participants = JavaModelManager.getJavaModelManager().compilationParticipants .getCompilationParticipants(this.javaProject); if (this.participants != null) for (int i = 0, l = this.participants.length; i < l; i++) if (this.participants[i] .aboutToBuild(this.javaProject) == CompilationParticipant.NEEDS_FULL_BUILD) kind = FULL_BUILD;/*from ww w .jav a 2s . c o m*/ // Flush the existing external files cache if this is the beginning of a build cycle String projectName = this.currentProject.getName(); if (builtProjects == null || builtProjects.contains(projectName)) { try { Method method = JavaModel.class.getMethod("flushExternalFileCache", new Class[] { Void.class }); if (method != null) { method.invoke(JavaModel.class, new Object[0]); } } catch (Throwable e) { e.printStackTrace(); } //JavaModel.flushExternalFileCache(); builtProjects = new ArrayList(); } builtProjects.add(projectName); } this.binaryLocationsPerProject = new SimpleLookupTable(3); this.nameEnvironment = new NameEnvironment(this.workspaceRoot, this.javaProject, this.binaryLocationsPerProject, this.notifier); if (forBuild) { String filterSequence = this.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true); char[][] filters = filterSequence != null && filterSequence.length() > 0 ? CharOperation.splitAndTrimOn(',', filterSequence.toCharArray()) : null; if (filters == null) { this.extraResourceFileFilters = null; this.extraResourceFolderFilters = null; } else { int fileCount = 0, folderCount = 0; for (int i = 0, l = filters.length; i < l; i++) { char[] f = filters[i]; if (f.length == 0) continue; if (f[f.length - 1] == '/') folderCount++; else fileCount++; } this.extraResourceFileFilters = new char[fileCount][]; this.extraResourceFolderFilters = new String[folderCount]; for (int i = 0, l = filters.length; i < l; i++) { char[] f = filters[i]; if (f.length == 0) continue; if (f[f.length - 1] == '/') this.extraResourceFolderFilters[--folderCount] = new String(f, 0, f.length - 1); else this.extraResourceFileFilters[--fileCount] = f; } } } return kind; }
From source file:nz.ac.auckland.ptjava.builder.PTJavaFileBuilderNature.java
License:Open Source License
/** * Add the nature to the specified project if it does not already have it. * //from w w w .ja v a 2 s.c om * @param project the project to be modified */ public static void addNature(IProject project) { // Cannot modify closed projects. if (!project.isOpen()) return; // Get the description. IProjectDescription description; try { description = project.getDescription(); } catch (CoreException e) { PTJavaLog.logError(e); return; } // Determine if the project already has the nature. List<String> newIds = new ArrayList<String>(); newIds.addAll(Arrays.asList(description.getNatureIds())); int index = newIds.indexOf(NATURE_ID); if (index != -1) return; // Add the nature newIds.add(NATURE_ID); description.setNatureIds(newIds.toArray(new String[newIds.size()])); try { // Save the description. project.setDescription(description, null); if (project.hasNature(JavaCore.NATURE_ID)) { IJavaProject javaProject = JavaCore.create(project); // set up compiler to not copy .ptjava files to output Map options = javaProject.getOptions(false); options.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "*.ptjava"); javaProject.setOptions(options); } else { PTJavaLog.logInfo("The project to add ParaTask nature does not have Java nature!"); } } catch (CoreException e) { PTJavaLog.logError(e); } }
From source file:org.antlr.eclipse.core.AntlrCorePlugin.java
License:Open Source License
/** {@inheritDoc} */ @Override// w w w. j a va2 s . c o m public void start(final BundleContext context) throws Exception { super.start(context); // Add ANTLR grammar files to JDT builder's copy exclusion filter Hashtable<String, String> options = JavaCore.getOptions(); String filter = options.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER); StringTokenizer st = new StringTokenizer(filter, ","); boolean found = false; while (st.hasMoreTokens()) { if (st.nextToken().equals("*.g")) { found = true; break; } } if (!found) { if (isDebug()) { System.out.println("Adding '*.g' to JDT builder's " + "resource filter (" + filter + ")"); } options.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, filter + ",*.g"); JavaCore.setOptions(options); } createClasspathVariable("org.antlr", ANTLR_HOME); }
From source file:org.eclipse.ajdt.core.builder.AJBuilder.java
License:Open Source License
/** * Bug 91131 - Checking to see if the user has selected to use project * setting for building. Unfortunately, there is no way of checking * whether the user has selected to use project settings other than to * see whether the options contained on the building page are in the * IEclipsePreferences. There is also the need for this extra check, * rather than just whether there are any IEclipsePreferences, * in Eclipse 3.1 because there are several property pages for the * different compiler options./* ww w . j a v a 2 s. c o m*/ */ private boolean usingProjectBuildingOptions(String[] keys) { List<String> listOfKeys = Arrays.asList(keys); return (listOfKeys.contains(JavaCore.COMPILER_PB_MAX_PER_UNIT) || listOfKeys.contains(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE) || listOfKeys.contains(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH) || listOfKeys.contains(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER) || listOfKeys.contains(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) || listOfKeys.contains(JavaCore.CORE_CIRCULAR_CLASSPATH) || listOfKeys.contains(JavaCore.CORE_INCOMPLETE_CLASSPATH) || listOfKeys.contains(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL)); }
From source file:org.eclipse.ant.internal.ui.datatransfer.BuildFileCreator.java
License:Open Source License
private void createCopyResources(List<String> srcDirs, List<String> classDirs, Element element, List<List<String>> inclusionLists, List<List<String>> exclusionLists) { // Check filter for copying resources String filter = project.getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true); StringTokenizer tokenizer = new StringTokenizer(filter, ","); //$NON-NLS-1$ ArrayList<String> filters = new ArrayList<>(); while (tokenizer.hasMoreTokens()) { filters.add(tokenizer.nextToken()); }/*from w ww . j ava 2 s .com*/ filters.add("*.java"); //$NON-NLS-1$ // prefix filters with wildcard for (int i = 0; i < filters.size(); i++) { String item = filters.get(i).trim(); if (item.equals("*")) //$NON-NLS-1$ { // everything is excluded from copying return; } filters.set(i, "**/" + item); //$NON-NLS-1$ } // <copy todir="classes" includeemptydirs="false"> // <fileset dir="src" excludes="**/*.java"/> // </copy> for (int i = 0; i < srcDirs.size(); i++) { String srcDir = srcDirs.get(i); String classDir = classDirs.get(i); if (!EclipseClasspath.isReference(classDir)) { Element copyElement = doc.createElement("copy"); //$NON-NLS-1$ copyElement.setAttribute("todir", classDir); //$NON-NLS-1$ copyElement.setAttribute("includeemptydirs", "false"); //$NON-NLS-1$ //$NON-NLS-2$ Element filesetElement = doc.createElement("fileset"); //$NON-NLS-1$ filesetElement.setAttribute(IAntCoreConstants.DIR, srcDir); List<String> inclusions = inclusionLists.get(i); List<String> exclusions = exclusionLists.get(i); for (String inclusion : inclusions) { Element includeElement = doc.createElement("include"); //$NON-NLS-1$ includeElement.setAttribute(IAntCoreConstants.NAME, inclusion); filesetElement.appendChild(includeElement); } for (String exclusion : filters) { Element excludeElement = doc.createElement("exclude"); //$NON-NLS-1$ excludeElement.setAttribute(IAntCoreConstants.NAME, exclusion); filesetElement.appendChild(excludeElement); } for (String exclusion : exclusions) { Element excludeElement = doc.createElement("exclude"); //$NON-NLS-1$ excludeElement.setAttribute(IAntCoreConstants.NAME, exclusion); filesetElement.appendChild(excludeElement); } copyElement.appendChild(filesetElement); element.appendChild(copyElement); } } }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
private Hashtable getDefaultOptionsNoInitialization() { Map defaultOptionsMap = new CompilerOptions().getMap(); // compiler defaults // Override some compiler defaults defaultOptionsMap.put(JavaCore.COMPILER_LOCAL_VARIABLE_ATTR, JavaCore.GENERATE); defaultOptionsMap.put(JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL, JavaCore.PRESERVE); defaultOptionsMap.put(JavaCore.COMPILER_TASK_TAGS, JavaCore.DEFAULT_TASK_TAGS); defaultOptionsMap.put(JavaCore.COMPILER_TASK_PRIORITIES, JavaCore.DEFAULT_TASK_PRIORITIES); defaultOptionsMap.put(JavaCore.COMPILER_TASK_CASE_SENSITIVE, JavaCore.ENABLED); defaultOptionsMap.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); defaultOptionsMap.put(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, JavaCore.ERROR); // Builder settings defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, JavaCore.ABORT); defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, JavaCore.WARNING); defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, JavaCore.CLEAN); // JavaCore settings defaultOptionsMap.put(JavaCore.CORE_JAVA_BUILD_ORDER, JavaCore.IGNORE); defaultOptionsMap.put(JavaCore.CORE_INCOMPLETE_CLASSPATH, JavaCore.ERROR); defaultOptionsMap.put(JavaCore.CORE_CIRCULAR_CLASSPATH, JavaCore.ERROR); defaultOptionsMap.put(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, JavaCore.IGNORE); defaultOptionsMap.put(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, JavaCore.WARNING); defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS, JavaCore.ENABLED); defaultOptionsMap.put(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS, JavaCore.ENABLED); // Formatter settings defaultOptionsMap.putAll(DefaultCodeFormatterConstants.getEclipseDefaultSettings()); // CodeAssist settings defaultOptionsMap.put(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.DISABLED); defaultOptionsMap.put(JavaCore.CODEASSIST_DEPRECATION_CHECK, JavaCore.DISABLED); defaultOptionsMap.put(JavaCore.CODEASSIST_IMPLICIT_QUALIFICATION, JavaCore.DISABLED); defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_PREFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_PREFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_PREFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_PREFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_PREFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_FIELD_SUFFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FINAL_FIELD_SUFFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$ defaultOptionsMap.put(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaCore.ENABLED); defaultOptionsMap.put(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaCore.DISABLED); defaultOptionsMap.put(JavaCore.CODEASSIST_CAMEL_CASE_MATCH, JavaCore.ENABLED); defaultOptionsMap.put(JavaCore.CODEASSIST_SUGGEST_STATIC_IMPORTS, JavaCore.ENABLED); // Time out for parameter names defaultOptionsMap.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "50"); //$NON-NLS-1$ return new Hashtable(defaultOptionsMap); }
From source file:org.eclipse.jdt.internal.core.JavaProject.java
License:Open Source License
/** * Returns the project custom preference pool. * Project preferences may include custom encoding. * @return IEclipsePreferences or <code>null</code> if the project * does not have a java nature.//ww w . j ava2s . com */ public IEclipsePreferences getEclipsePreferences() { if (!JavaProject.hasJavaNature(this.project)) return null; // Get cached preferences if exist JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager() .getPerProjectInfo(this.project, true); if (perProjectInfo.preferences != null) return perProjectInfo.preferences; // Init project preferences IScopeContext context = new ProjectScope(getProject()); final IEclipsePreferences eclipsePreferences = context.getNode(JavaCore.PLUGIN_ID); updatePreferences(eclipsePreferences); perProjectInfo.preferences = eclipsePreferences; // Listen to new preferences node final IEclipsePreferences eclipseParentPreferences = (IEclipsePreferences) eclipsePreferences.parent(); if (eclipseParentPreferences != null) { if (this.preferencesNodeListener != null) { eclipseParentPreferences.removeNodeChangeListener(this.preferencesNodeListener); } this.preferencesNodeListener = new IEclipsePreferences.INodeChangeListener() { public void added(IEclipsePreferences.NodeChangeEvent event) { // do nothing } public void removed(IEclipsePreferences.NodeChangeEvent event) { if (event.getChild() == eclipsePreferences) { JavaModelManager.getJavaModelManager().resetProjectPreferences(JavaProject.this); } } }; eclipseParentPreferences.addNodeChangeListener(this.preferencesNodeListener); } // Listen to preferences changes if (this.preferencesChangeListener != null) { eclipsePreferences.removePreferenceChangeListener(this.preferencesChangeListener); } this.preferencesChangeListener = new IEclipsePreferences.IPreferenceChangeListener() { public void preferenceChange(IEclipsePreferences.PreferenceChangeEvent event) { String propertyName = event.getKey(); JavaModelManager manager = JavaModelManager.getJavaModelManager(); if (propertyName.startsWith(JavaCore.PLUGIN_ID)) { if (propertyName.equals(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER) || propertyName.equals(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER) || propertyName.equals(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE) || propertyName .equals(JavaCore.CORE_JAVA_BUILD_RECREATE_MODIFIED_CLASS_FILES_IN_OUTPUT_FOLDER) || propertyName.equals(JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH) || propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS) || propertyName.equals(JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS) || propertyName.equals(JavaCore.CORE_INCOMPLETE_CLASSPATH) || propertyName.equals(JavaCore.CORE_CIRCULAR_CLASSPATH) || propertyName.equals(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE) || propertyName.equals(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL)) { manager.deltaState.addClasspathValidation(JavaProject.this); } manager.resetProjectOptions(JavaProject.this); JavaProject.this.resetCaches(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=233568 } } }; eclipsePreferences.addPreferenceChangeListener(this.preferencesChangeListener); return eclipsePreferences; }
From source file:org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase.java
License:Open Source License
@SuppressWarnings("unchecked") protected void setUp() throws Exception { System.out.println("TEST-SETUP: " + getName()); super.setUp(); workspace = ResourcesPlugin.getWorkspace(); IWorkspaceDescription description = workspace.getDescription(); description.setAutoBuilding(false);// ww w . j a va 2 s. co m workspace.setDescription(description); // lets not assume we've got subversion in the target platform Hashtable<String, String> options = JavaCore.getOptions(); options.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, ".svn/"); JavaCore.setOptions(options); projectRefreshJob = MavenPluginActivator.getDefault().getProjectManagerRefreshJob(); projectRefreshJob.sleep(); downloadSourcesJob = ((BuildPathManager) MavenJdtPlugin.getDefault().getBuildpathManager()) .getDownloadSourcesJob(); downloadSourcesJob.sleep(); mavenConfiguration = MavenPlugin.getMavenConfiguration(); oldUserSettingsFile = mavenConfiguration.getUserSettingsFile(); File settings = new File("settings.xml").getCanonicalFile(); if (settings.canRead()) { String userSettingsFile = settings.getAbsolutePath(); System.out.println("Setting user settings file: " + userSettingsFile); mavenConfiguration.setUserSettingsFile(userSettingsFile); } ArtifactRepository localRepository = MavenPlugin.getMaven().getLocalRepository(); if (localRepository != null) { repo = new File(localRepository.getBasedir()); } else { fail("Cannot determine local repository path"); } // make sure all tests use default metadata by default LifecycleMappingFactory.setUseDefaultLifecycleMappingMetadataSource(true); LifecycleMappingFactory.setDefaultLifecycleMappingMetadataSource(null); WorkspaceHelpers.cleanWorkspace(); }
From source file:org.eclipse.xtend.ide.builder.JavaProjectPreferencesInitializer.java
License:Open Source License
@SuppressWarnings("restriction") @Inject/*from w w w .ja va 2 s . c o m*/ public void addOwnFileExtensionsToJavaBuildResourceCopyFilter(FileExtensionProvider extensionProvider) { @SuppressWarnings("deprecation") IScopeContext defaultScope = new DefaultScope(); // The class org.eclipse.jdt.internal.launching.LaunchingPreferenceInitializer has this very nasty habit // of replacing all RESOURCE_COPY_FILTERs with its own filter. Calling getNode(LaunchingPlugin.ID_PLUGIN) // causes LaunchingPreferenceInitializer to be executed that afterwards we can append our filters safely. // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=395366 defaultScope.getNode(org.eclipse.jdt.internal.launching.LaunchingPlugin.ID_PLUGIN); IEclipsePreferences dnode = defaultScope.getNode(JavaCore.PLUGIN_ID); if (dnode == null) return; Set<String> filters = Sets.newLinkedHashSet(); for (String filter : dnode.get(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, "").split(",")) { String trimmed = filter.trim(); if (!"".equals(trimmed)) filters.add(trimmed); } for (String ext : extensionProvider.getFileExtensions()) filters.add("*." + ext); dnode.put(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, Joiner.on(", ").join(filters)); try { dnode.flush(); } catch (BackingStoreException e) { log.error("Error saving preferences", e); } }