当前位置: 首页>>代码示例>>Java>>正文


Java ContentEntry.addSourceFolder方法代码示例

本文整理汇总了Java中com.intellij.openapi.roots.ContentEntry.addSourceFolder方法的典型用法代码示例。如果您正苦于以下问题:Java ContentEntry.addSourceFolder方法的具体用法?Java ContentEntry.addSourceFolder怎么用?Java ContentEntry.addSourceFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.roots.ContentEntry的用法示例。


在下文中一共展示了ContentEntry.addSourceFolder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureBackOfficeRoots

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
protected void configureBackOfficeRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final ContentEntry contentEntry
) {
    Validate.notNull(moduleDescriptor);
    Validate.notNull(contentEntry);

    final File backOfficeModuleDirectory = new File(
        moduleDescriptor.getRootDirectory(), BACK_OFFICE_MODULE_DIRECTORY
    );

    final File backOfficeSrcDirectory = new File(backOfficeModuleDirectory, SRC_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(backOfficeSrcDirectory.getAbsolutePath()),
        JavaSourceRootType.SOURCE
    );

    addTestSourceRoots(contentEntry, backOfficeModuleDirectory);

    final File hmcResourcesDirectory = new File(backOfficeModuleDirectory, RESOURCES_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(hmcResourcesDirectory.getAbsolutePath()),
        JavaResourceRootType.RESOURCE
    );
    excludeDirectory(contentEntry, new File(backOfficeModuleDirectory, CLASSES_DIRECTORY));
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:RegularContentRootConfigurator.java

示例2: configurePlatformRoots

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
protected void configurePlatformRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final ContentEntry contentEntry
) {
    Validate.notNull(moduleDescriptor);
    Validate.notNull(contentEntry);

    if (!HybrisConstants.PLATFORM_EXTENSION_NAME.equalsIgnoreCase(moduleDescriptor.getName())) {
        return;
    }
    final File rootDirectory = moduleDescriptor.getRootDirectory();
    final File platformBootstrapDirectory = new File(rootDirectory, PLATFORM_BOOTSTRAP_DIRECTORY);

    if (!moduleDescriptor.getRootProjectDescriptor().isImportOotbModulesInReadOnlyMode()) {

        final File platformBootstrapResourcesDirectory = new File(platformBootstrapDirectory, RESOURCES_DIRECTORY);
        contentEntry.addSourceFolder(
            VfsUtil.pathToUrl(platformBootstrapResourcesDirectory.getAbsolutePath()),
            JavaResourceRootType.RESOURCE
        );
    }

    excludeDirectory(contentEntry, new File(platformBootstrapDirectory, PLATFORM_MODEL_CLASSES_DIRECTORY));
    excludeDirectory(contentEntry, new File(rootDirectory, PLATFORM_TOMCAT_DIRECTORY));
    contentEntry.addExcludePattern("apache-ant-*");
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:RegularContentRootConfigurator.java

示例3: setupRootModel

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
@Override
public void setupRootModel(@NotNull final ModifiableRootModel rootModel) throws ConfigurationException {
    if (mySdk == null) {
        rootModel.inheritSdk();
    } else {
        rootModel.setSdk(mySdk);
    }

    // Make the entire module directory a source root.
    ContentEntry contentEntry = doAddContentEntry(rootModel);
    if (contentEntry != null) {
        final VirtualFile file = contentEntry.getFile();
        if (file != null && file.isDirectory())
            contentEntry.addSourceFolder(file, false);
    }
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:17,代码来源:LuaModuleBuilder.java

示例4: setupRootModel

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
@Override
public void setupRootModel(ModifiableRootModel rootModel) throws ConfigurationException {
	ContentEntry contentEntry = doAddContentEntry(rootModel);
	if (contentEntry != null) {
		final List<Pair<String, String>> sourcePaths = getSourcePaths();

		if (sourcePaths != null) {
			for (final Pair<String, String> sourcePath : sourcePaths) {
				String first = sourcePath.first;
				new File(first).mkdirs();
				final VirtualFile sourceRoot = LocalFileSystem.getInstance().refreshAndFindFileByPath(FileUtil.toSystemIndependentName(first));
				if (sourceRoot != null) {
					contentEntry.addSourceFolder(sourceRoot, false, sourcePath.second);
				}
			}
		}
	}
}
 
开发者ID:kayler-renslow,项目名称:arma-intellij-plugin,代码行数:19,代码来源:ArmaModuleBuilder.java

示例5: setSourceFolderForLocation

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
@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;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:21,代码来源:JavaSourceFolderProvider.java

示例6: configureCommonRoots

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
protected void configureCommonRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final ContentEntry contentEntry
) {
    Validate.notNull(moduleDescriptor);
    Validate.notNull(contentEntry);

    // https://hybris-integration.atlassian.net/browse/IIP-354
    // Do not register acceleratorstorefrontcommons/src as source root because it references not existent class
    // GeneratedAcceleratorstorefrontcommonsConstants and it breaks compilation from Intellij
    if (!ACCELERATOR_STOREFRONT_COMMONS_EXTENSION_NAME.equals(moduleDescriptor.getName())) {
        final File srcDirectory = new File(moduleDescriptor.getRootDirectory(), SRC_DIRECTORY);
        contentEntry.addSourceFolder(
            VfsUtil.pathToUrl(srcDirectory.getAbsolutePath()),
            JavaSourceRootType.SOURCE
        );
    }

    final File genSrcDirectory = new File(moduleDescriptor.getRootDirectory(), GEN_SRC_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(genSrcDirectory.getAbsolutePath()),
        JavaSourceRootType.SOURCE,
        JpsJavaExtensionService.getInstance().createSourceRootProperties("", true)
    );

    addTestSourceRoots(contentEntry, moduleDescriptor.getRootDirectory());

    final File resourcesDirectory = new File(moduleDescriptor.getRootDirectory(), RESOURCES_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(resourcesDirectory.getAbsolutePath()),
        JavaResourceRootType.RESOURCE
    );

    excludeCommonNeedlessDirs(contentEntry, moduleDescriptor);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:36,代码来源:RegularContentRootConfigurator.java

示例7: configureAdditionalRoots

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
protected void configureAdditionalRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final String directoryName,
    @NotNull final ContentEntry contentEntry,
    @NotNull final File parentDirectory
) {
    Validate.notNull(moduleDescriptor);
    Validate.notNull(directoryName);
    Validate.notNull(contentEntry);
    Validate.notNull(parentDirectory);

    final File additionalModuleDirectory = new File(parentDirectory, directoryName);
    if (!additionalModuleDirectory.exists() || additionalModuleDirectory.isFile()) {
        return;
    }

    final File additionalSrcDirectory = new File(additionalModuleDirectory, SRC_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(additionalSrcDirectory.getAbsolutePath()),
        JavaSourceRootType.SOURCE
    );

    final File additionalResourcesDirectory = new File(additionalModuleDirectory, RESOURCES_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(additionalResourcesDirectory.getAbsolutePath()),
        JavaResourceRootType.RESOURCE
    );
    excludeDirectory(contentEntry, new File(additionalModuleDirectory, CLASSES_DIRECTORY));
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:30,代码来源:RegularContentRootConfigurator.java

示例8: configureWebModuleRoots

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
protected void configureWebModuleRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    final @NotNull ContentEntry contentEntry,
    final File webModuleDirectory
) {
    Validate.notNull(moduleDescriptor);

    final File webSrcDirectory = new File(webModuleDirectory, SRC_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(webSrcDirectory.getAbsolutePath()),
        JavaSourceRootType.SOURCE
    );

    final File webGenSrcDirectory = new File(webModuleDirectory, GEN_SRC_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(webGenSrcDirectory.getAbsolutePath()),
        JavaSourceRootType.SOURCE,
        JpsJavaExtensionService.getInstance().createSourceRootProperties("", true)
    );

    addTestSourceRoots(contentEntry, webModuleDirectory);

    excludeSubDirectories(contentEntry, webModuleDirectory, Arrays.asList(
        ADDON_SRC_DIRECTORY, TEST_CLASSES_DIRECTORY, COMMON_WEB_SRC_DIRECTORY
    ));

    configureWebInf(contentEntry, moduleDescriptor, webModuleDirectory);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:29,代码来源:RegularContentRootConfigurator.java

示例9: addTestSourceRoots

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static void addTestSourceRoots(final @NotNull ContentEntry contentEntry, @NotNull final File dir) {
    for (String testSrcDirName : TEST_SRC_DIR_NAMES) {
        contentEntry.addSourceFolder(
            VfsUtil.pathToUrl(new File(dir, testSrcDirName).getAbsolutePath()),
            JavaSourceRootType.TEST_SOURCE
        );
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:9,代码来源:RegularContentRootConfigurator.java

示例10: setupRootModel

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
@Override
public void setupRootModel(final ModifiableRootModel modifiableRootModel) throws ConfigurationException {
    super.setupRootModel(modifiableRootModel);

    String contentEntryPath = getContentEntryPath();
    if (StringUtil.isEmpty(contentEntryPath)) {
        throw new ConfigurationException("There is no valid content entry path associated with the module. Unable to generate template directory structure.");
    }

    LocalFileSystem fileSystem = getInstance();
    VirtualFile modelContentRootDir = fileSystem.refreshAndFindFileByIoFile(new File(contentEntryPath));

    if (modelContentRootDir == null) {
        throw new ConfigurationException("Model content root directory '" + contentEntryPath + "' could not be found. Unable to generate template directory structure.");
    }

    ContentEntry content = modifiableRootModel.addContentEntry(modelContentRootDir);

    try {
        VirtualFile sourceCodeDir = VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/java");
        VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/java/com/processing/sketch");

        VirtualFile resources = VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/resources");

        content.addSourceFolder(sourceCodeDir, false);
        content.addSourceFolder(resources, JavaResourceRootType.RESOURCE, JavaResourceRootType.RESOURCE.createDefaultProperties());
    } catch (IOException io) {
        logger.error("Unable to generate template directory structure:", io);
        throw new ConfigurationException("Unable to generate template directory structure.");
    }

    VirtualFile sketchPackagePointer = getInstance().refreshAndFindFileByPath(getContentEntryPath() + "/src/main/java/com/processing/sketch");

    if (generateTemplateSketchClass) {
        ApplicationManager.getApplication().runWriteAction(new CreateSketchTemplateFile(sketchPackagePointer));
    }
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:38,代码来源:ProcessingModuleBuilder.java

示例11: createSourceRootIfAbsent

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static void createSourceRootIfAbsent(
  @NotNull ContentEntry entry, @NotNull final SourceRoot root, @NotNull String moduleName,
  @NotNull JpsModuleSourceRootType<?> sourceRootType, boolean generated, boolean createEmptyContentRootDirectories) {
  List<SourceFolder> folders = entry.getSourceFolders(sourceRootType);
  for (SourceFolder folder : folders) {
    VirtualFile file = folder.getFile();
    if (file == null) {
      continue;
    }
    if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(root.getPath())) {
      return;
    }
  }
  LOG.debug(String.format("Importing %s for content root '%s' of module '%s'", root, entry.getUrl(), moduleName));
  SourceFolder sourceFolder = entry.addSourceFolder(toVfsUrl(root.getPath()), sourceRootType);
  if (!StringUtil.isEmpty(root.getPackagePrefix())) {
    sourceFolder.setPackagePrefix(root.getPackagePrefix());
  }
  if (generated) {
    JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
    if(properties != null) {
      properties.setForGeneratedSources(true);
    }
  }
  if(createEmptyContentRootDirectories) {
    ExternalSystemApiUtil.doWriteAction(new Runnable() {
      @Override
      public void run() {
        try {
          VfsUtil.createDirectoryIfMissing(root.getPath());
        }
        catch (IOException e) {
          LOG.warn(String.format("Unable to create directory for the path: %s", root.getPath()), e);
        }
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:ContentRootDataService.java

示例12: initModule

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
protected void initModule(Module module) {
    final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
    final ModifiableRootModel rootModel = rootManager.getModifiableModel();

    for (String contentRoot : myContentRoots) {
      final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(contentRoot);
      Assert.assertNotNull("cannot find content root: " + contentRoot, virtualFile);
      final ContentEntry contentEntry = rootModel.addContentEntry(virtualFile);

      for (String sourceRoot: mySourceRoots) {
        String s = contentRoot + "/" + sourceRoot;
        VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByPath(s);
        if (vf == null) {
          final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(sourceRoot);
          if (file != null && VfsUtilCore.isAncestor(virtualFile, file, false)) vf = file;
        }
//        assert vf != null : "cannot find source root: " + sourceRoot;
        if (vf != null) {
          contentEntry.addSourceFolder(vf, false);
        }
        else {
          // files are not created yet
          contentEntry.addSourceFolder(VfsUtilCore.pathToUrl(s), false);
        }
      }
    }
    setupRootModel(rootModel);
    rootModel.commit();
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ModuleFixtureBuilderImpl.java

示例13: addSourceFolder

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
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);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:AbstractContentRootModuleCustomizer.java

示例14: setupRootModel

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
public void setupRootModel(final ModifiableRootModel rootModel) throws ConfigurationException {
  super.setupRootModel(rootModel);
  String contentEntryPath = getContentEntryPath();
  if (contentEntryPath == null) return;

  String resourceRootPath = contentEntryPath + "/resources";
  VirtualFile contentRoot = LocalFileSystem.getInstance().findFileByPath(contentEntryPath);
  if (contentRoot == null) return;

  ContentEntry contentEntry = MarkRootActionBase.findContentEntry(rootModel, contentRoot);
  if (contentEntry != null) {
    contentEntry.addSourceFolder(VfsUtilCore.pathToUrl(resourceRootPath), JavaResourceRootType.RESOURCE);
  }

  final String defaultPluginXMLLocation = resourceRootPath + "/META-INF/plugin.xml";
  final Module module = rootModel.getModule();
  final Project project = module.getProject();
  StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
    public void run() {
      final PluginBuildConfiguration buildConfiguration = PluginBuildConfiguration.getInstance(module);
      if (buildConfiguration != null) {
        buildConfiguration.setPluginXmlPathAndCreateDescriptorIfDoesntExist(defaultPluginXMLLocation);
      }

      VirtualFile file = LocalFileSystem.getInstance().findFileByPath(defaultPluginXMLLocation);
      if (file != null) {
        FileEditorManager.getInstance(project).openFile(file, true);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:PluginModuleBuilder.java

示例15: addSourceFolderToContentEntry

import com.intellij.openapi.roots.ContentEntry; //导入方法依赖的package包/类
private static SourceFolder addSourceFolderToContentEntry(
    ContentEntry contentEntry, BlazeSourceDirectory sourceDirectory) {
  File sourceDir = sourceDirectory.getDirectory();

  // Create the source folder
  SourceFolder sourceFolder;
  if (sourceDirectory.getIsResource()) {
    sourceFolder =
        contentEntry.addSourceFolder(
            UrlUtil.pathToUrl(sourceDir.getPath()), JavaResourceRootType.RESOURCE);
  } else {
    sourceFolder = contentEntry.addSourceFolder(UrlUtil.pathToUrl(sourceDir.getPath()), false);
  }
  JpsModuleSourceRoot sourceRoot = sourceFolder.getJpsElement();
  JpsElement properties = sourceRoot.getProperties();
  if (properties instanceof JavaSourceRootProperties) {
    JavaSourceRootProperties rootProperties = (JavaSourceRootProperties) properties;
    if (sourceDirectory.getIsGenerated()) {
      rootProperties.setForGeneratedSources(true);
    }
  }
  String packagePrefix = sourceDirectory.getPackagePrefix();
  if (!Strings.isNullOrEmpty(packagePrefix)) {
    sourceFolder.setPackagePrefix(packagePrefix);
  }
  return sourceFolder;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:28,代码来源:JavaSourceFolderProvider.java


注:本文中的com.intellij.openapi.roots.ContentEntry.addSourceFolder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。