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