Example usage for org.eclipse.jdt.internal.core.util Messages build_duplicateResource

List of usage examples for org.eclipse.jdt.internal.core.util Messages build_duplicateResource

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.util Messages build_duplicateResource.

Prototype

String build_duplicateResource

To view the source code for org.eclipse.jdt.internal.core.util Messages build_duplicateResource.

Click Source Link

Usage

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

License:Open Source License

protected void copyExtraResourcesBack(ClasspathMultiDirectory sourceLocation, final boolean deletedAll)
        throws CoreException {
    // When, if ever, does a builder need to copy resources files (not .java or .class) into the output folder?
    // If we wipe the output folder at the beginning of the build then all 'extra' resources must be copied to the output folder.

    this.notifier.subTask(Messages.build_copyingResources);
    final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
    final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
    final char[][] inclusionPatterns = sourceLocation.inclusionPatterns;
    final IContainer outputFolder = sourceLocation.binaryFolder;
    final boolean isAlsoProject = sourceLocation.sourceFolder.equals(this.javaBuilder.currentProject);
    sourceLocation.sourceFolder.accept(new IResourceProxyVisitor() {
        public boolean visit(IResourceProxy proxy) throws CoreException {
            IResource resource = null;/* ww  w .j a  v a  2s.  c  om*/
            switch (proxy.getType()) {
            case IResource.FILE:
                if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName())
                        || org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName()))
                    return false;

                resource = proxy.requestResource();
                if (BatchImageBuilder.this.javaBuilder.filterExtraResource(resource))
                    return false;
                if (exclusionPatterns != null || inclusionPatterns != null)
                    if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false))
                        return false;

                IPath partialPath = resource.getFullPath().removeFirstSegments(segmentCount);
                IResource copiedResource = outputFolder.getFile(partialPath);
                if (copiedResource.exists()) {
                    if (deletedAll) {
                        IResource originalResource = findOriginalResource(partialPath);
                        String id = originalResource.getFullPath().removeFirstSegments(1).toString();
                        createProblemFor(resource, null, Messages.bind(Messages.build_duplicateResource, id),
                                BatchImageBuilder.this.javaBuilder.javaProject
                                        .getOption(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, true));
                        return false;
                    }
                    copiedResource.delete(IResource.FORCE, null); // last one wins
                }
                createFolder(partialPath.removeLastSegments(1), outputFolder); // ensure package folder exists
                copyResource(resource, copiedResource);
                return false;
            case IResource.FOLDER:
                resource = proxy.requestResource();
                if (BatchImageBuilder.this.javaBuilder.filterExtraResource(resource))
                    return false;
                if (isAlsoProject && isExcludedFromProject(resource.getFullPath()))
                    return false; // the sourceFolder == project
                if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
                    if (Util.isExcluded(resource.getFullPath(), null, exclusionPatterns, true))
                        return false;
            }
            return true;
        }
    }, IResource.NONE);
}

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

License:Open Source License

protected void copyExtraResourcesBack(ClasspathMultiDirectory sourceLocation, final boolean deletedAll)
        throws CoreException {
    // When, if ever, does a builder need to copy resources files (not .java or .class) into the output folder?
    // If we wipe the output folder at the beginning of the build then all 'extra' resources must be copied to the output folder.

    this.notifier.subTask(Messages.build_copyingResources);
    final int segmentCount = sourceLocation.sourceFolder.getFullPath().segmentCount();
    final char[][] exclusionPatterns = sourceLocation.exclusionPatterns;
    final char[][] inclusionPatterns = sourceLocation.inclusionPatterns;
    final IContainer outputFolder = sourceLocation.binaryFolder;
    final boolean isAlsoProject = sourceLocation.sourceFolder.equals(this.javaBuilder.currentProject);
    // GROOVY start
    final boolean isInterestingProject = LanguageSupportFactory
            .isInterestingProject(this.javaBuilder.getProject());
    // GROOVY end
    sourceLocation.sourceFolder.accept(new IResourceProxyVisitor() {
        public boolean visit(IResourceProxy proxy) throws CoreException {
            IResource resource = null;// w  w  w . j av a2s.  c  o  m
            switch (proxy.getType()) {
            case IResource.FILE:
                // GROOVY start
                /* old {
                if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName()) ||
                   org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName())) return false;
                } new */
                // copy groovy files if not in a groovy project
                // Also, must keep the call to 'isJavaLikeFileName' to keep Scala plugin happy: GRECLIPSE-404
                // here it is the same test as above, except 
                if ((LanguageSupportFactory.isSourceFile(proxy.getName(), isInterestingProject)
                        && org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(proxy.getName()))
                        || org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(proxy.getName()))
                    return false;
                // GROOVY end

                resource = proxy.requestResource();
                if (BatchImageBuilder.this.javaBuilder.filterExtraResource(resource))
                    return false;
                if (exclusionPatterns != null || inclusionPatterns != null)
                    if (Util.isExcluded(resource.getFullPath(), inclusionPatterns, exclusionPatterns, false))
                        return false;

                IPath partialPath = resource.getFullPath().removeFirstSegments(segmentCount);
                IResource copiedResource = outputFolder.getFile(partialPath);
                if (copiedResource.exists()) {
                    if (deletedAll) {
                        IResource originalResource = findOriginalResource(partialPath);
                        String id = originalResource.getFullPath().removeFirstSegments(1).toString();
                        createProblemFor(resource, null, Messages.bind(Messages.build_duplicateResource, id),
                                BatchImageBuilder.this.javaBuilder.javaProject
                                        .getOption(JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE, true));
                        return false;
                    }
                    copiedResource.delete(IResource.FORCE, null); // last one wins
                }
                createFolder(partialPath.removeLastSegments(1), outputFolder); // ensure package folder exists
                copyResource(resource, copiedResource);
                return false;
            case IResource.FOLDER:
                resource = proxy.requestResource();
                if (BatchImageBuilder.this.javaBuilder.filterExtraResource(resource))
                    return false;
                if (isAlsoProject && isExcludedFromProject(resource.getFullPath()))
                    return false; // the sourceFolder == project
                if (exclusionPatterns != null && inclusionPatterns == null) // must walk children if inclusionPatterns != null
                    if (Util.isExcluded(resource.getFullPath(), null, exclusionPatterns, true))
                        return false;
            }
            return true;
        }
    }, IResource.NONE);
}