Search in sources :

Example 1 with ResourcesTarget

use of org.jetbrains.jps.incremental.ResourcesTarget in project intellij-community by JetBrains.

the class ResourcesTargetType method computeAllTargets.

@NotNull
@Override
public List<ResourcesTarget> computeAllTargets(@NotNull JpsModel model) {
    List<JpsModule> modules = model.getProject().getModules();
    List<ResourcesTarget> targets = new ArrayList<>(modules.size());
    for (JpsModule module : modules) {
        targets.add(new ResourcesTarget(module, this));
    }
    return targets;
}
Also used : JpsModule(org.jetbrains.jps.model.module.JpsModule) ResourcesTarget(org.jetbrains.jps.incremental.ResourcesTarget) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ResourcesTarget

use of org.jetbrains.jps.incremental.ResourcesTarget 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 3 with ResourcesTarget

use of org.jetbrains.jps.incremental.ResourcesTarget 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

ResourcesTarget (org.jetbrains.jps.incremental.ResourcesTarget)3 NotNull (org.jetbrains.annotations.NotNull)2 ResourceRootDescriptor (org.jetbrains.jps.builders.java.ResourceRootDescriptor)2 File (java.io.File)1 IOException (java.io.IOException)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 JpsModule (org.jetbrains.jps.model.module.JpsModule)1