use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.
the class JpsContentEntry method addSourceFolder.
@NotNull
@Override
public <P extends JpsElement> SourceFolder addSourceFolder(@NotNull VirtualFile file, @NotNull JpsModuleSourceRootType<P> type, @NotNull P properties) {
final JpsModuleSourceRoot sourceRoot = myModule.addSourceRoot(file.getUrl(), type, properties);
final JpsSourceFolder sourceFolder = new JpsSourceFolder(sourceRoot, this);
mySourceFolders.add(sourceFolder);
return sourceFolder;
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.
the class JpsIdeaSpecificSettings method readContentEntry.
@Override
public void readContentEntry(Element root, String contentUrl, JpsModule model) {
for (Object o : root.getChildren(IdeaXml.TEST_FOLDER_TAG)) {
final String url = ((Element) o).getAttributeValue(IdeaXml.URL_ATTR);
JpsModuleSourceRoot folderToBeTest = null;
for (JpsModuleSourceRoot folder : model.getSourceRoots()) {
if (Comparing.strEqual(folder.getUrl(), url)) {
folderToBeTest = folder;
break;
}
}
if (folderToBeTest != null) {
model.removeSourceRoot(folderToBeTest.getUrl(), JavaSourceRootType.SOURCE);
}
model.addSourceRoot(url, JavaSourceRootType.TEST_SOURCE);
}
for (Object o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) {
final String excludeUrl = ((Element) o).getAttributeValue(IdeaXml.URL_ATTR);
if (FileUtil.isAncestor(new File(contentUrl), new File(excludeUrl), false)) {
model.getExcludeRootsList().addUrl(excludeUrl);
}
}
for (Object o : root.getChildren(IdeaXml.PACKAGE_PREFIX_TAG)) {
Element ppElement = (Element) o;
final String prefix = ppElement.getAttributeValue(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR);
final String url = ppElement.getAttributeValue(IdeaXml.URL_ATTR);
for (JpsModuleSourceRoot sourceRoot : model.getSourceRoots()) {
if (Comparing.strEqual(sourceRoot.getUrl(), url)) {
JpsElement properties = sourceRoot.getProperties();
if (properties instanceof JavaSourceRootProperties) {
((JavaSourceRootProperties) properties).setPackagePrefix(prefix);
}
break;
}
}
}
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.
the class IdeaJdk method setupSdkPathsFromIDEAProject.
private static void setupSdkPathsFromIDEAProject(Sdk sdk, SdkModificator sdkModificator, SdkModel sdkModel) throws IOException {
ProgressIndicator indicator = ObjectUtils.assertNotNull(ProgressManager.getInstance().getProgressIndicator());
String sdkHome = ObjectUtils.notNull(sdk.getHomePath());
JpsModel model = JpsSerializationManager.getInstance().loadModel(sdkHome, PathManager.getOptionsPath());
JpsSdkReference<JpsDummyElement> sdkRef = model.getProject().getSdkReferencesTable().getSdkReference(JpsJavaSdkType.INSTANCE);
String sdkName = sdkRef == null ? null : sdkRef.getSdkName();
Sdk internalJava = sdkModel.findSdk(sdkName);
if (internalJava != null && isValidInternalJdk(sdk, internalJava)) {
setInternalJdk(sdk, sdkModificator, internalJava);
}
Set<VirtualFile> addedRoots = ContainerUtil.newTroveSet();
VirtualFileManager vfsManager = VirtualFileManager.getInstance();
JpsJavaExtensionService javaService = JpsJavaExtensionService.getInstance();
boolean isUltimate = vfsManager.findFileByUrl(VfsUtilCore.pathToUrl(sdkHome + "/ultimate/ultimate-resources")) != null;
Set<String> suppressedModules = ContainerUtil.newTroveSet("jps-plugin-system");
Set<String> ultimateModules = ContainerUtil.newTroveSet("platform-ultimate", "ultimate-resources", "ultimate-verifier", "diagram-api", "diagram-impl", "uml-plugin");
List<JpsModule> modules = JBIterable.from(model.getProject().getModules()).filter(o -> {
if (suppressedModules.contains(o.getName()))
return false;
if (o.getName().endsWith("-ide"))
return false;
String contentUrl = ContainerUtil.getFirstItem(o.getContentRootsList().getUrls());
if (contentUrl == null)
return true;
return !isUltimate || contentUrl.contains("/community/") || ultimateModules.contains(o.getName());
}).toList();
indicator.setIndeterminate(false);
double delta = 1 / (2 * Math.max(0.5, modules.size()));
for (JpsModule o : modules) {
indicator.setFraction(indicator.getFraction() + delta);
for (JpsDependencyElement dep : o.getDependenciesList().getDependencies()) {
ProgressManager.checkCanceled();
JpsLibrary library = dep instanceof JpsLibraryDependency ? ((JpsLibraryDependency) dep).getLibrary() : null;
JpsLibraryType<?> libraryType = library == null ? null : library.getType();
if (!(libraryType instanceof JpsJavaLibraryType))
continue;
JpsJavaDependencyExtension extension = javaService.getDependencyExtension(dep);
if (extension == null)
continue;
// do not check extension.getScope(), plugin projects need tests too
for (JpsLibraryRoot jps : library.getRoots(JpsOrderRootType.COMPILED)) {
VirtualFile root = vfsManager.findFileByUrl(jps.getUrl());
if (root == null || !addedRoots.add(root))
continue;
sdkModificator.addRoot(root, OrderRootType.CLASSES);
}
for (JpsLibraryRoot jps : library.getRoots(JpsOrderRootType.SOURCES)) {
VirtualFile root = vfsManager.findFileByUrl(jps.getUrl());
if (root == null || !addedRoots.add(root))
continue;
sdkModificator.addRoot(root, OrderRootType.SOURCES);
}
}
}
for (JpsModule o : modules) {
indicator.setFraction(indicator.getFraction() + delta);
String outputUrl = javaService.getOutputUrl(o, false);
VirtualFile outputRoot = outputUrl == null ? null : vfsManager.findFileByUrl(outputUrl);
if (outputRoot == null)
continue;
sdkModificator.addRoot(outputRoot, OrderRootType.CLASSES);
for (JpsModuleSourceRoot jps : o.getSourceRoots()) {
ProgressManager.checkCanceled();
VirtualFile root = vfsManager.findFileByUrl(jps.getUrl());
if (root == null || !addedRoots.add(root))
continue;
sdkModificator.addRoot(root, OrderRootType.SOURCES);
}
}
indicator.setFraction(1.0);
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project android by JetBrains.
the class ContentEntriesSetup method addSourceFolder.
private static void addSourceFolder(@NotNull ContentEntry contentEntry, @NotNull File folderPath, @NotNull JpsModuleSourceRootType type, boolean generated) {
String url = pathToIdeaUrl(folderPath);
SourceFolder sourceFolder = contentEntry.addSourceFolder(url, type);
if (generated) {
JpsModuleSourceRoot sourceRoot = sourceFolder.getJpsElement();
JpsElement properties = sourceRoot.getProperties();
if (properties instanceof JavaSourceRootProperties) {
((JavaSourceRootProperties) properties).setForGeneratedSources(true);
}
}
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-plugins by JetBrains.
the class FlexBuildTarget method computeRootDescriptors.
@Override
@NotNull
public List<BuildRootDescriptor> computeRootDescriptors(final JpsModel model, final ModuleExcludeIndex index, final IgnoredFileIndex ignoredFileIndex, final BuildDataPaths dataPaths) {
final List<BuildRootDescriptor> result = new ArrayList<>();
final Collection<File> srcRoots = new ArrayList<>();
for (JpsModuleSourceRoot sourceRoot : myBC.getModule().getSourceRoots(JavaSourceRootType.SOURCE)) {
final File root = JpsPathUtil.urlToFile(sourceRoot.getUrl());
result.add(new FlexSourceRootDescriptor(this, root));
srcRoots.add(root);
}
if (FlexCommonUtils.isFlexUnitBC(myBC)) {
for (JpsModuleSourceRoot sourceRoot : myBC.getModule().getSourceRoots(JavaSourceRootType.TEST_SOURCE)) {
final File root = JpsPathUtil.urlToFile(sourceRoot.getUrl());
result.add(new FlexSourceRootDescriptor(this, root));
srcRoots.add(root);
}
}
for (final JpsFlexDependencyEntry entry : myBC.getDependencies().getEntries()) {
if (entry instanceof JpsFlexBCDependencyEntry) {
final JpsFlexBuildConfiguration dependencyBC = ((JpsFlexBCDependencyEntry) entry).getBC();
if (dependencyBC != null) {
result.add(new FlexSourceRootDescriptor(this, new File(dependencyBC.getActualOutputFilePath())));
}
} else if (entry instanceof JpsLibraryDependencyEntry) {
final JpsLibrary library = ((JpsLibraryDependencyEntry) entry).getLibrary();
if (library != null) {
for (String rootUrl : library.getRootUrls(JpsOrderRootType.COMPILED)) {
result.add(new FlexSourceRootDescriptor(this, JpsPathUtil.urlToFile(rootUrl)));
}
}
}
}
final BuildConfigurationNature nature = myBC.getNature();
if (nature.isWebPlatform() && nature.isApp() && myBC.isUseHtmlWrapper() && !myBC.getWrapperTemplatePath().isEmpty()) {
addIfNotUnderRoot(result, new File(myBC.getWrapperTemplatePath()), srcRoots);
}
if (FlexCommonUtils.canHaveRLMsAndRuntimeStylesheets(myBC)) {
for (String cssPath : myBC.getCssFilesToCompile()) {
if (!cssPath.isEmpty()) {
addIfNotUnderRoot(result, new File(cssPath), srcRoots);
}
}
}
if (!myBC.getCompilerOptions().getAdditionalConfigFilePath().isEmpty()) {
addIfNotUnderRoot(result, new File(myBC.getCompilerOptions().getAdditionalConfigFilePath()), srcRoots);
}
if (nature.isApp()) {
if (nature.isDesktopPlatform()) {
addAirDescriptorPathIfCustom(result, myBC.getAirDesktopPackagingOptions(), srcRoots);
} else if (nature.isMobilePlatform()) {
if (myBC.getAndroidPackagingOptions().isEnabled()) {
addAirDescriptorPathIfCustom(result, myBC.getAndroidPackagingOptions(), srcRoots);
}
if (myBC.getIosPackagingOptions().isEnabled()) {
addAirDescriptorPathIfCustom(result, myBC.getIosPackagingOptions(), srcRoots);
}
}
}
return result;
}
Aggregations