use of com.intellij.openapi.roots.CompilerModuleExtension in project intellij-plugins by StepicOrg.
the class AbstractModuleBuilder method setupRootModel.
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class);
compilerModuleExtension.setExcludeOutput(true);
if (this.myJdk != null) {
rootModel.setSdk(this.myJdk);
} else {
rootModel.inheritSdk();
}
compilerModuleExtension.inheritCompilerOutputPath(true);
doAddContentEntry(rootModel);
}
use of com.intellij.openapi.roots.CompilerModuleExtension in project intellij-community by JetBrains.
the class ExcludeCompilerOutputPolicy method getExcludeRootsForModule.
@NotNull
@Override
public VirtualFilePointer[] getExcludeRootsForModule(@NotNull final ModuleRootModel rootModel) {
ArrayList<VirtualFilePointer> result = new ArrayList<>();
final CompilerModuleExtension extension = rootModel.getModuleExtension(CompilerModuleExtension.class);
if (extension == null) {
return VirtualFilePointer.EMPTY_ARRAY;
}
if (extension.isCompilerOutputPathInherited()) {
ContainerUtil.addIfNotNull(result, CompilerProjectExtension.getInstance(myProject).getCompilerOutputPointer());
} else {
if (!extension.isExcludeOutput())
return VirtualFilePointer.EMPTY_ARRAY;
ContainerUtil.addIfNotNull(result, extension.getCompilerOutputPointer());
ContainerUtil.addIfNotNull(result, extension.getCompilerOutputForTestsPointer());
}
return result.isEmpty() ? VirtualFilePointer.EMPTY_ARRAY : result.toArray(new VirtualFilePointer[result.size()]);
}
use of com.intellij.openapi.roots.CompilerModuleExtension in project intellij-community by JetBrains.
the class JaCoCoCoverageRunner method loadExecutionData.
private static void loadExecutionData(@NotNull final File sessionDataFile, ProjectData data, @NotNull Project project) throws IOException {
final ExecutionDataStore executionDataStore = new ExecutionDataStore();
FileInputStream fis = null;
try {
fis = new FileInputStream(sessionDataFile);
final ExecutionDataReader executionDataReader = new ExecutionDataReader(fis);
executionDataReader.setExecutionDataVisitor(executionDataStore);
executionDataReader.setSessionInfoVisitor(new ISessionInfoVisitor() {
public void visitSessionInfo(SessionInfo info) {
System.out.println(info.toString());
}
});
while (executionDataReader.read()) {
}
} finally {
if (fis != null) {
fis.close();
}
}
final CoverageBuilder coverageBuilder = new CoverageBuilder();
final Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
final Module[] modules = ModuleManager.getInstance(project).getModules();
for (Module module : modules) {
final CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module);
if (compilerModuleExtension != null) {
final VirtualFile[] roots = compilerModuleExtension.getOutputRoots(true);
for (VirtualFile root : roots) {
analyzer.analyzeAll(VfsUtil.virtualToIoFile(root));
}
}
}
for (IClassCoverage classCoverage : coverageBuilder.getClasses()) {
String className = classCoverage.getName();
className = className.replace('\\', '.').replace('/', '.');
final ClassData classData = data.getOrCreateClassData(className);
final Collection<IMethodCoverage> methods = classCoverage.getMethods();
LineData[] lines = new LineData[classCoverage.getLastLine() + 1];
for (IMethodCoverage method : methods) {
final String desc = method.getName() + method.getDesc();
// Line numbers are 1-based here.
final int firstLine = method.getFirstLine();
final int lastLine = method.getLastLine();
for (int i = firstLine; i <= lastLine; i++) {
final ILine methodLine = method.getLine(i);
final int methodLineStatus = methodLine.getStatus();
if (methodLineStatus == ICounter.EMPTY)
continue;
final LineData lineData = new LineData(i, desc) {
@Override
public int getStatus() {
switch(methodLineStatus) {
case ICounter.FULLY_COVERED:
return LineCoverage.FULL;
case ICounter.PARTLY_COVERED:
return LineCoverage.PARTIAL;
default:
return LineCoverage.NONE;
}
}
};
lineData.setHits(methodLineStatus == ICounter.FULLY_COVERED || methodLineStatus == ICounter.PARTLY_COVERED ? 1 : 0);
lines[i] = lineData;
}
}
classData.setLines(lines);
}
}
use of com.intellij.openapi.roots.CompilerModuleExtension in project intellij-community by JetBrains.
the class GradleResourceCompilerConfigurationGenerator method generateAffectedGradleModulesConfiguration.
@NotNull
private Map<String, GradleModuleResourceConfiguration> generateAffectedGradleModulesConfiguration(@NotNull CompileContext context) {
final Map<String, GradleModuleResourceConfiguration> affectedGradleModuleConfigurations = ContainerUtil.newTroveMap();
//noinspection MismatchedQueryAndUpdateOfCollection
final Map<String, ExternalProject> lazyExternalProjectMap = new FactoryMap<String, ExternalProject>() {
@Nullable
@Override
protected ExternalProject create(String gradleProjectPath) {
return externalProjectDataCache.getRootExternalProject(GradleConstants.SYSTEM_ID, new File(gradleProjectPath));
}
};
for (Module module : context.getCompileScope().getAffectedModules()) {
if (!ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, module))
continue;
final String gradleProjectPath = ExternalSystemApiUtil.getExternalRootProjectPath(module);
assert gradleProjectPath != null;
if (shouldBeBuiltByExternalSystem(module))
continue;
final ExternalProject externalRootProject = lazyExternalProjectMap.get(gradleProjectPath);
if (externalRootProject == null) {
context.addMessage(CompilerMessageCategory.ERROR, String.format("Unable to make the module: %s, related gradle configuration was not found. " + "Please, re-import the Gradle project and try again.", module.getName()), VfsUtilCore.pathToUrl(gradleProjectPath), -1, -1);
continue;
}
Map<String, ExternalSourceSet> externalSourceSets = externalProjectDataCache.findExternalProject(externalRootProject, module);
if (externalSourceSets.isEmpty()) {
LOG.debug("Unable to find source sets config for module: " + module.getName());
continue;
}
GradleModuleResourceConfiguration resourceConfig = new GradleModuleResourceConfiguration();
resourceConfig.id = new ModuleVersion(ExternalSystemApiUtil.getExternalProjectGroup(module), ExternalSystemApiUtil.getExternalProjectId(module), ExternalSystemApiUtil.getExternalProjectVersion(module));
for (ExternalSourceSet sourceSet : externalSourceSets.values()) {
addResources(resourceConfig.resources, sourceSet.getSources().get(ExternalSystemSourceType.RESOURCE), sourceSet.getSources().get(ExternalSystemSourceType.SOURCE));
addResources(resourceConfig.testResources, sourceSet.getSources().get(ExternalSystemSourceType.TEST_RESOURCE), sourceSet.getSources().get(ExternalSystemSourceType.TEST));
}
final CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module);
if (compilerModuleExtension != null && compilerModuleExtension.isCompilerOutputPathInherited()) {
String outputPath = VfsUtilCore.urlToPath(compilerModuleExtension.getCompilerOutputUrl());
for (ResourceRootConfiguration resource : resourceConfig.resources) {
resource.targetPath = outputPath;
}
String testOutputPath = VfsUtilCore.urlToPath(compilerModuleExtension.getCompilerOutputUrlForTests());
for (ResourceRootConfiguration resource : resourceConfig.testResources) {
resource.targetPath = testOutputPath;
}
}
affectedGradleModuleConfigurations.put(module.getName(), resourceConfig);
}
return affectedGradleModuleConfigurations;
}
use of com.intellij.openapi.roots.CompilerModuleExtension in project android by JetBrains.
the class ExcludedRoots method addFolderPathsFromExcludedModules.
private void addFolderPathsFromExcludedModules() {
for (Module module : myExcludedModules) {
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
for (ContentEntry entry : rootManager.getContentEntries()) {
for (SourceFolder sourceFolder : entry.getSourceFolders()) {
myExcludedRoots.add(urlToFilePath(sourceFolder.getUrl()));
}
CompilerModuleExtension compiler = rootManager.getModuleExtension(CompilerModuleExtension.class);
String url = compiler.getCompilerOutputUrl();
if (isNotEmpty(url)) {
myExcludedRoots.add(urlToFilePath(url));
}
}
AndroidModuleModel androidModuleModel = AndroidModuleModel.get(module);
if (androidModuleModel != null) {
myExcludedRoots.add(androidModuleModel.getMainArtifact().getJavaResourcesFolder());
}
}
}
Aggregations