Search in sources :

Example 1 with JavaResourceRootType

use of org.jetbrains.jps.model.java.JavaResourceRootType in project intellij by bazelbuild.

the class JavaSourceFolderProvider method setSourceFolderForLocation.

@Override
public SourceFolder setSourceFolderForLocation(ContentEntry contentEntry, SourceFolder parentFolder, File file, boolean isTestSource) {
    SourceFolder sourceFolder;
    if (isResource(parentFolder)) {
        JavaResourceRootType resourceRootType = isTestSource ? JavaResourceRootType.TEST_RESOURCE : JavaResourceRootType.RESOURCE;
        sourceFolder = contentEntry.addSourceFolder(UrlUtil.pathToUrl(file.getPath()), resourceRootType);
    } else {
        sourceFolder = contentEntry.addSourceFolder(UrlUtil.pathToUrl(file.getPath()), isTestSource);
    }
    sourceFolder.setPackagePrefix(derivePackagePrefix(file, parentFolder));
    JpsModuleSourceRoot sourceRoot = sourceFolder.getJpsElement();
    JpsElement properties = sourceRoot.getProperties();
    if (properties instanceof JavaSourceRootProperties) {
        ((JavaSourceRootProperties) properties).setForGeneratedSources(isGenerated(parentFolder));
    }
    return sourceFolder;
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) JpsElement(org.jetbrains.jps.model.JpsElement) JavaResourceRootType(org.jetbrains.jps.model.java.JavaResourceRootType) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties)

Aggregations

SourceFolder (com.intellij.openapi.roots.SourceFolder)1 JpsElement (org.jetbrains.jps.model.JpsElement)1 JavaResourceRootType (org.jetbrains.jps.model.java.JavaResourceRootType)1 JavaSourceRootProperties (org.jetbrains.jps.model.java.JavaSourceRootProperties)1 JpsModuleSourceRoot (org.jetbrains.jps.model.module.JpsModuleSourceRoot)1