Search in sources :

Example 1 with ResourceRootDescriptor

use of org.jetbrains.jps.builders.java.ResourceRootDescriptor in project intellij-community by JetBrains.

the class ResourcesTarget method computeRootDescriptors.

@NotNull
@Override
public List<ResourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
    List<ResourceRootDescriptor> roots = new ArrayList<>();
    JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
    Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);
    for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> sourceRoot : myModule.getSourceRoots(type)) {
        if (!isExcludedFromCompilation(excludedRootProviders, sourceRoot)) {
            final String packagePrefix = sourceRoot.getProperties().getPackagePrefix();
            final File rootFile = sourceRoot.getFile();
            roots.add(new FilteredResourceRootDescriptor(rootFile, this, packagePrefix, computeRootExcludes(rootFile, index)));
        }
    }
    JavaResourceRootType resourceType = isTests() ? JavaResourceRootType.TEST_RESOURCE : JavaResourceRootType.RESOURCE;
    for (JpsTypedModuleSourceRoot<JavaResourceRootProperties> root : myModule.getSourceRoots(resourceType)) {
        if (!isExcludedFromCompilation(excludedRootProviders, root)) {
            File rootFile = root.getFile();
            String relativeOutputPath = root.getProperties().getRelativeOutputPath();
            roots.add(new ResourceRootDescriptor(rootFile, this, relativeOutputPath.replace('/', '.'), computeRootExcludes(rootFile, index)));
        }
    }
    return roots;
}
Also used : ArrayList(java.util.ArrayList) ExcludedJavaSourceRootProvider(org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider) ResourceRootDescriptor(org.jetbrains.jps.builders.java.ResourceRootDescriptor) FilteredResourceRootDescriptor(org.jetbrains.jps.builders.java.FilteredResourceRootDescriptor) File(java.io.File) FilteredResourceRootDescriptor(org.jetbrains.jps.builders.java.FilteredResourceRootDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ResourceRootDescriptor

use of org.jetbrains.jps.builders.java.ResourceRootDescriptor in project intellij-community by JetBrains.

the class ResourcesTarget method writeConfiguration.

@Override
public void writeConfiguration(ProjectDescriptor pd, PrintWriter out) {
    int fingerprint = 0;
    final BuildRootIndex rootIndex = pd.getBuildRootIndex();
    final List<ResourceRootDescriptor> roots = rootIndex.getTargetRoots(this, null);
    for (ResourceRootDescriptor root : roots) {
        fingerprint += FileUtil.fileHashCode(root.getRootFile());
        fingerprint += root.getPackagePrefix().hashCode();
    }
    out.write(Integer.toHexString(fingerprint));
}
Also used : BuildRootIndex(org.jetbrains.jps.builders.BuildRootIndex) ResourceRootDescriptor(org.jetbrains.jps.builders.java.ResourceRootDescriptor) FilteredResourceRootDescriptor(org.jetbrains.jps.builders.java.FilteredResourceRootDescriptor)

Example 3 with ResourceRootDescriptor

use of org.jetbrains.jps.builders.java.ResourceRootDescriptor in project intellij-community by JetBrains.

the class CheckResourcesTarget method computeRootDescriptors.

@NotNull
@Override
public List<GroovyResourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
    ResourcesTarget target = new ResourcesTarget(myModule, ResourcesTargetType.getInstance(isTests()));
    List<ResourceRootDescriptor> resources = target.computeRootDescriptors(model, index, ignoredFileIndex, dataPaths);
    return ContainerUtil.map(resources, descriptor -> new GroovyResourceRootDescriptor(descriptor, CheckResourcesTarget.this));
}
Also used : ResourcesTarget(org.jetbrains.jps.incremental.ResourcesTarget) ResourceRootDescriptor(org.jetbrains.jps.builders.java.ResourceRootDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ResourceRootDescriptor

use of org.jetbrains.jps.builders.java.ResourceRootDescriptor in project intellij-community by JetBrains.

the class ResourcesBuilder method build.

@Override
public void build(@NotNull ResourcesTarget target, @NotNull DirtyFilesHolder<ResourceRootDescriptor, ResourcesTarget> holder, @NotNull final BuildOutputConsumer outputConsumer, @NotNull final CompileContext context) throws ProjectBuildException, IOException {
    if (!isResourceProcessingEnabled(target.getModule())) {
        return;
    }
    try {
        holder.processDirtyFiles(new FileProcessor<ResourceRootDescriptor, ResourcesTarget>() {

            private final Map<ResourceRootDescriptor, Boolean> mySkippedRoots = new HashMap<>();

            public boolean apply(ResourcesTarget target, final File file, final ResourceRootDescriptor sourceRoot) throws IOException {
                Boolean isSkipped = mySkippedRoots.get(sourceRoot);
                if (isSkipped == null) {
                    final File outputDir = target.getOutputDir();
                    isSkipped = Boolean.valueOf(outputDir == null || FileUtil.filesEqual(outputDir, sourceRoot.getRootFile()));
                    mySkippedRoots.put(sourceRoot, isSkipped);
                }
                if (isSkipped.booleanValue()) {
                    return true;
                }
                try {
                    copyResource(context, sourceRoot, file, outputConsumer);
                } catch (IOException e) {
                    LOG.info(e);
                    context.processMessage(new CompilerMessage("resources", BuildMessage.Kind.ERROR, e.getMessage(), FileUtil.toSystemIndependentName(file.getPath())));
                    return false;
                }
                return !context.getCancelStatus().isCanceled();
            }
        });
        context.checkCanceled();
        context.processMessage(new ProgressMessage(""));
    } catch (BuildDataCorruptedException | ProjectBuildException e) {
        throw e;
    } catch (Exception e) {
        throw new ProjectBuildException(e.getMessage(), e);
    }
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) ProgressMessage(org.jetbrains.jps.incremental.messages.ProgressMessage) CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) IOException(java.io.IOException) IOException(java.io.IOException) ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) BuildDataCorruptedException(org.jetbrains.jps.builders.storage.BuildDataCorruptedException) ResourcesTarget(org.jetbrains.jps.incremental.ResourcesTarget) ResourceRootDescriptor(org.jetbrains.jps.builders.java.ResourceRootDescriptor) File(java.io.File)

Aggregations

ResourceRootDescriptor (org.jetbrains.jps.builders.java.ResourceRootDescriptor)4 File (java.io.File)2 NotNull (org.jetbrains.annotations.NotNull)2 FilteredResourceRootDescriptor (org.jetbrains.jps.builders.java.FilteredResourceRootDescriptor)2 ResourcesTarget (org.jetbrains.jps.incremental.ResourcesTarget)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 BuildRootIndex (org.jetbrains.jps.builders.BuildRootIndex)1 ExcludedJavaSourceRootProvider (org.jetbrains.jps.builders.java.ExcludedJavaSourceRootProvider)1 BuildDataCorruptedException (org.jetbrains.jps.builders.storage.BuildDataCorruptedException)1 ProjectBuildException (org.jetbrains.jps.incremental.ProjectBuildException)1 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)1 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)1