Example usage for org.eclipse.jdt.core JavaCore CLEAN

List of usage examples for org.eclipse.jdt.core JavaCore CLEAN

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore CLEAN.

Prototype

String CLEAN

To view the source code for org.eclipse.jdt.core JavaCore CLEAN.

Click Source Link

Document

Configurable option value: .

Usage

From source file:net.sf.j2s.core.builder.BatchImageBuilder.java

License:Open Source License

protected void cleanOutputFolders(boolean copyBack) throws CoreException {
    boolean deleteAll = JavaCore.CLEAN
            .equals(this.javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, true));
    if (deleteAll) {
        if (this.javaBuilder.participants != null)
            for (int i = 0, l = this.javaBuilder.participants.length; i < l; i++)
                this.javaBuilder.participants[i].cleanStarting(this.javaBuilder.javaProject);

        ArrayList visited = new ArrayList(this.sourceLocations.length);
        for (int i = 0, l = this.sourceLocations.length; i < l; i++) {
            this.notifier.subTask(
                    Messages.bind(Messages.build_cleaningOutput, this.javaBuilder.currentProject.getName()));
            ClasspathMultiDirectory sourceLocation = this.sourceLocations[i];
            if (sourceLocation.hasIndependentOutputFolder) {
                IContainer outputFolder = sourceLocation.binaryFolder;
                if (!visited.contains(outputFolder)) {
                    visited.add(outputFolder);
                    IResource[] members = outputFolder.members();
                    for (int j = 0, m = members.length; j < m; j++) {
                        IResource member = members[j];
                        if (!member.isDerived()) {
                            member.accept(new IResourceVisitor() {
                                public boolean visit(IResource resource) throws CoreException {
                                    resource.setDerived(true, null);
                                    return resource.getType() != IResource.FILE;
                                }/* w  ww .  j a v  a2s  . c  om*/
                            });
                        }
                        member.delete(IResource.FORCE, null);
                    }
                }
                this.notifier.checkCancel();
                if (copyBack)
                    copyExtraResourcesBack(sourceLocation, true);
            } else {
                boolean isOutputFolder = sourceLocation.sourceFolder.equals(sourceLocation.binaryFolder);
                final char[][] exclusionPatterns = isOutputFolder ? sourceLocation.exclusionPatterns : null; // ignore exclusionPatterns if output folder == another source folder... not this one
                final char[][] inclusionPatterns = isOutputFolder ? sourceLocation.inclusionPatterns : null; // ignore inclusionPatterns if output folder == another source folder... not this one
                sourceLocation.binaryFolder.accept(new IResourceProxyVisitor() {
                    public boolean visit(IResourceProxy proxy) throws CoreException {
                        if (proxy.getType() == IResource.FILE) {
                            if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
                                IResource resource = proxy.requestResource();
                                if (exclusionPatterns != null || inclusionPatterns != null)
                                    if (Util.isExcluded(resource.getFullPath(), inclusionPatterns,
                                            exclusionPatterns, false))
                                        return false;
                                if (!resource.isDerived())
                                    resource.setDerived(true, null);
                                resource.delete(IResource.FORCE, null);
                            }
                            return false;
                        }
                        if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
                            if (Util.isExcluded(proxy.requestFullPath(), null, exclusionPatterns, true))
                                return false;
                        BatchImageBuilder.this.notifier.checkCancel();
                        return true;
                    }
                }, IResource.NONE);
                this.notifier.checkCancel();
            }
            this.notifier.checkCancel();
        }
    } else if (copyBack) {
        for (int i = 0, l = this.sourceLocations.length; i < l; i++) {
            ClasspathMultiDirectory sourceLocation = this.sourceLocations[i];
            if (sourceLocation.hasIndependentOutputFolder)
                copyExtraResourcesBack(sourceLocation, false);
            this.notifier.checkCancel();
        }
    }
}

From source file:org.eclipse.ajdt.core.builder.AJBuilder.java

License:Open Source License

/**
 * Tidies up the output folder before a build. JDT does this by going
 * through the source and deleting the relevant .class files. That works ok
 * if you are also listening to things like resource deletes so that you
 * tidy up some .class files as you go along. AJDT does not do this, so we
 * use a different approach here. We go through the output directory and
 * recursively delete all .class files. This, of course, doesn't cope with
 * resources that might be in the output directory - but I can't delete
 * everything because some people have the output directory set to the top
 * level of their project.//ww  w  .  j a v a 2 s . com
 * 
 * There is a subtlety with linked folders being used as output folders, but
 * it does work, I added an AJDTUtils helper method which attempts IPath
 * dereferencing. if the IPath is a 'linked folder' then the helper method
 * returns the dereferenced value.
 */
protected void cleanOutputFolders(IJavaProject project, boolean refresh) throws CoreException {
    // Check the project property
    boolean deleteAll = JavaCore.CLEAN
            .equals(project.getOption(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, true));
    if (deleteAll) {
        int numberDeleted = 0;
        IPath[] paths = CoreUtils.getOutputFolders(project);
        for (int i = 0; i < paths.length; i++) {
            numberDeleted += cleanFolder(project, paths[i], refresh);
        }

        // clean inpath out folder
        String inpathOut = AspectJCorePreferences.getProjectInpathOutFolder(project.getProject());
        if (inpathOut != null && !inpathOut.equals("")) { //$NON-NLS-1$
            IPath inpathOutfolder = new Path(inpathOut);
            numberDeleted += cleanFolder(project, inpathOutfolder, refresh);
        }

        AJLog.log(AJLog.BUILDER, "Builder: Tidied output folder(s), removed class files and derived resources"); //$NON-NLS-1$
    }
}

From source file:org.eclipse.jdt.internal.core.builder.BatchImageBuilder.java

License:Open Source License

protected void cleanOutputFolders(boolean copyBack) throws CoreException {
    boolean deleteAll = JavaCore.CLEAN
            .equals(this.javaBuilder.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER, true));
    if (deleteAll) {
        if (this.javaBuilder.participants != null)
            for (int i = 0, l = this.javaBuilder.participants.length; i < l; i++)
                this.javaBuilder.participants[i].cleanStarting(this.javaBuilder.javaProject);

        ArrayList visited = new ArrayList(this.sourceLocations.length);
        for (int i = 0, l = this.sourceLocations.length; i < l; i++) {
            this.notifier.subTask(
                    Messages.bind(Messages.build_cleaningOutput, this.javaBuilder.currentProject.getName()));
            ClasspathMultiDirectory sourceLocation = this.sourceLocations[i];
            if (sourceLocation.hasIndependentOutputFolder) {
                IContainer outputFolder = sourceLocation.binaryFolder;
                if (!visited.contains(outputFolder)) {
                    visited.add(outputFolder);
                    IResource[] members = outputFolder.members();
                    for (int j = 0, m = members.length; j < m; j++) {
                        IResource member = members[j];
                        if (!member.isDerived()) {
                            member.accept(new IResourceVisitor() {
                                public boolean visit(IResource resource) throws CoreException {
                                    resource.setDerived(true, null);
                                    return resource.getType() != IResource.FILE;
                                }//from   w  ww.  jav  a  2s  . c  o  m
                            });
                        }
                        member.delete(IResource.FORCE, null);
                    }
                }
                this.notifier.checkCancel();
                if (copyBack)
                    copyExtraResourcesBack(sourceLocation, true);
            } else {
                boolean isOutputFolder = sourceLocation.sourceFolder.equals(sourceLocation.binaryFolder);
                final char[][] exclusionPatterns = isOutputFolder ? sourceLocation.exclusionPatterns : null; // ignore exclusionPatterns if output folder == another source folder... not this one
                final char[][] inclusionPatterns = isOutputFolder ? sourceLocation.inclusionPatterns : null; // ignore inclusionPatterns if output folder == another source folder... not this one
                sourceLocation.binaryFolder.accept(new IResourceProxyVisitor() {
                    public boolean visit(IResourceProxy proxy) throws CoreException {
                        if (proxy.getType() == IResource.FILE) {
                            if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) {
                                IResource resource = proxy.requestResource();
                                if (exclusionPatterns != null || inclusionPatterns != null)
                                    if (Util.isExcluded(resource.getFullPath(), inclusionPatterns,
                                            exclusionPatterns, false))
                                        return false;
                                if (!resource.isDerived())
                                    resource.setDerived(true, null);
                                resource.delete(IResource.FORCE, null);
                            }
                            return false;
                        }
                        if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
                            if (Util.isExcluded(proxy.requestFullPath(), null, exclusionPatterns, true))
                                return false;
                        BatchImageBuilder.this.notifier.checkCancel();
                        return true;
                    }
                }, IResource.NONE);
                this.notifier.checkCancel();
            }
            this.notifier.checkCancel();
        }
    } else if (copyBack) {
        for (int i = 0, l = this.sourceLocations.length; i < l; i++) {
            ClasspathMultiDirectory sourceLocation = this.sourceLocations[i];
            if (sourceLocation.hasIndependentOutputFolder)
                copyExtraResourcesBack(sourceLocation, false);
            this.notifier.checkCancel();
        }
    }
    // GROOVY start
    LanguageSupportFactory.getEventHandler().handle(this.javaBuilder.javaProject, "cleanOutputFolders");
    // GROOVY end
}

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);
}