本文整理汇总了Java中com.intellij.openapi.roots.ModifiableRootModel.addLibraryEntry方法的典型用法代码示例。如果您正苦于以下问题:Java ModifiableRootModel.addLibraryEntry方法的具体用法?Java ModifiableRootModel.addLibraryEntry怎么用?Java ModifiableRootModel.addLibraryEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ModifiableRootModel
的用法示例。
在下文中一共展示了ModifiableRootModel.addLibraryEntry方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLibsToModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private void addLibsToModule(
@NotNull final ModifiableRootModel modifiableRootModel,
@NotNull IdeModifiableModelsProvider modifiableModelsProvider,
@NotNull final String libraryName,
final boolean export
) {
Validate.notNull(modifiableRootModel);
final LibraryTable.ModifiableModel libraryTableModifiableModel = modifiableModelsProvider
.getModifiableProjectLibrariesModel();
Library library = libraryTableModifiableModel.getLibraryByName(libraryName);
if (null == library) {
library = libraryTableModifiableModel.createLibrary(libraryName);
}
modifiableRootModel.addLibraryEntry(library);
if (export) {
setLibraryEntryExported(modifiableRootModel, library);
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:23,代码来源:DefaultLibRootsConfigurator.java
示例2: importMissing
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private void importMissing(@NotNull IdeModifiableModelsProvider modelsProvider,
@NotNull Set<LibraryDependencyData> toImport,
@NotNull ModifiableRootModel moduleRootModel,
@NotNull LibraryTable moduleLibraryTable,
@NotNull Module module) {
for (final LibraryDependencyData dependencyData : toImport) {
final LibraryData libraryData = dependencyData.getTarget();
final String libraryName = libraryData.getInternalName();
switch (dependencyData.getLevel()) {
case MODULE:
final Library moduleLib = moduleLibraryTable.createLibrary(libraryName);
syncExistingLibraryDependency(modelsProvider, dependencyData, moduleLib, moduleRootModel, module);
break;
case PROJECT:
final Library projectLib = modelsProvider.getLibraryByName(libraryName);
if (projectLib == null) {
syncExistingLibraryDependency(modelsProvider, dependencyData, moduleLibraryTable.createLibrary(libraryName), moduleRootModel,
module);
break;
}
LibraryOrderEntry orderEntry = moduleRootModel.addLibraryEntry(projectLib);
setLibraryScope(orderEntry, projectLib, module, dependencyData);
}
}
}
示例3: updateProjectStructure
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void updateProjectStructure(
Project project,
BlazeContext context,
WorkspaceRoot workspaceRoot,
ProjectViewSet projectViewSet,
BlazeProjectData blazeProjectData,
@Nullable BlazeProjectData oldBlazeProjectData,
ModuleEditor moduleEditor,
Module workspaceModule,
ModifiableRootModel workspaceModifiableModel) {
if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.JAVASCRIPT)
|| BlazeJavascriptLibrarySource.JS_LIBRARY_KIND == null) {
return;
}
for (Library lib : getJavascriptLibraries(project)) {
if (workspaceModifiableModel.findLibraryOrderEntry(lib) == null) {
workspaceModifiableModel.addLibraryEntry(lib);
}
}
}
示例4: updateProjectStructure
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void updateProjectStructure(
Project project,
BlazeContext context,
WorkspaceRoot workspaceRoot,
ProjectViewSet projectViewSet,
BlazeProjectData blazeProjectData,
@Nullable BlazeProjectData oldBlazeProjectData,
ModuleEditor moduleEditor,
Module workspaceModule,
ModifiableRootModel workspaceModifiableModel) {
if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.TYPESCRIPT)) {
return;
}
Library tsConfigLibrary =
ProjectLibraryTable.getInstance(project).getLibraryByName(TSCONFIG_LIBRARY_NAME);
if (tsConfigLibrary != null) {
if (workspaceModifiableModel.findLibraryOrderEntry(tsConfigLibrary) == null) {
workspaceModifiableModel.addLibraryEntry(tsConfigLibrary);
}
}
}
示例5: updatePythonFacet
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static void updatePythonFacet(
BlazeContext context,
BlazeProjectData blazeProjectData,
Module workspaceModule,
ModifiableRootModel workspaceModifiableModel) {
if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.PYTHON)
|| blazeProjectData.workspaceLanguageSettings.isWorkspaceType(WorkspaceType.PYTHON)) {
removeFacet(workspaceModule);
return;
}
if (ModuleType.get(workspaceModule) instanceof PythonModuleTypeBase) {
return;
}
LibraryContributingFacet<?> pythonFacet = getOrCreatePythonFacet(context, workspaceModule);
if (pythonFacet == null) {
return;
}
Library pythonLib = getFacetLibrary(pythonFacet);
if (pythonLib != null) {
workspaceModifiableModel.addLibraryEntry(pythonLib);
}
}
示例6: updateProjectStructure
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void updateProjectStructure(
Project project,
BlazeContext context,
WorkspaceRoot workspaceRoot,
ProjectViewSet projectViewSet,
BlazeProjectData blazeProjectData,
@Nullable BlazeProjectData oldBlazeProjectData,
ModuleEditor moduleEditor,
Module workspaceModule,
ModifiableRootModel workspaceModifiableModel) {
if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.GO)) {
return;
}
for (Library lib : getGoLibraries(project)) {
if (workspaceModifiableModel.findLibraryOrderEntry(lib) == null) {
workspaceModifiableModel.addLibraryEntry(lib);
}
}
Scope.push(
context,
(childContext) -> {
childContext.push(new TimingScope("BuildGoSymbolicLinks", EventType.Other));
BlazeGoRootsProvider.createGoPathSourceRoot(project);
});
}
示例7: run
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void run() {
if (module.isDisposed() || module.getProject().isDisposed()) {
logger.warn("Either the module '" + module.getName() + "' or project '" + module.getProject().getName() + " has been disposed." +
" Cannot add root '" + jarDirectory.getPath() + " as a project and module dependency.");
return;
}
LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(module.getProject());
LibraryTable.ModifiableModel projectLibraryModel = projectLibraryTable.getModifiableModel();
logger.debug("Adding '" + jarDirectory + "' as a dependency of the project '" + module.getProject().getName() + "'.");
// Create library and add it as a project level dependency.
Library processingLibrary = createProcessingCoreDependencyLibrary(projectLibraryModel);
projectLibraryModel.commit();
logger.debug("Change committed to the project library table.");
logger.debug("Adding '" + jarDirectory + "' as a dependency of the module '" + module.getProject().getName() + "'.");
// Add library as the module level dependency.
ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel();
rootModel.addLibraryEntry(processingLibrary);
rootModel.commit();
logger.debug("Change committed to the module library table.");
}
示例8: customizeModule
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void customizeModule(@NotNull Project project,
@NotNull Module module,
@NotNull IdeModifiableModelsProvider modelsProvider,
@Nullable IdeaJavaProject model) {
if (model != null) {
final ModifiableRootModel moduleModel = modelsProvider.getModifiableRootModel(module);
Map<String, Set<File>> artifactsByConfiguration = model.getArtifactsByConfiguration();
if (artifactsByConfiguration != null) {
for (Map.Entry<String, Set<File>> entry : artifactsByConfiguration.entrySet()) {
Set<File> artifacts = entry.getValue();
if (artifacts != null && !artifacts.isEmpty()) {
for (File artifact : artifacts) {
if (!artifact.isFile() || !endsWithIgnoreCase(artifact.getName(), DOT_JAR)) {
// We only expose artifacts that are jar files.
continue;
}
String libraryName = module.getName() + "." + getNameWithoutExtension(artifact);
Library library = modelsProvider.getLibraryByName(libraryName);
if (library == null) {
// Create library.
library = modelsProvider.createLibrary(libraryName);
Library.ModifiableModel libraryModel = library.getModifiableModel();
String url = pathToUrl(artifact.getPath());
libraryModel.addRoot(url, CLASSES);
LibraryOrderEntry orderEntry = moduleModel.addLibraryEntry(library);
orderEntry.setScope(COMPILE);
orderEntry.setExported(true);
}
}
}
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:ArtifactsByConfigurationModuleCustomizer.java
示例9: tryToSetUpGroovyFacetOnTheFly
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
public static boolean tryToSetUpGroovyFacetOnTheFly(final Module module) {
final Project project = module.getProject();
GroovyConfigUtils utils = GroovyConfigUtils.getInstance();
final Library[] libraries = utils.getAllSDKLibraries(project);
if (libraries.length > 0) {
final Library library = libraries[0];
int result = Messages
.showOkCancelDialog(
GroovyBundle.message("groovy.like.library.found.text", module.getName(), library.getName(), utils.getSDKLibVersion(library)),
GroovyBundle.message("groovy.like.library.found"), JetgroovyIcons.Groovy.Groovy_32x32);
if (result == Messages.OK) {
AccessToken accessToken = WriteAction.start();
try {
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
LibraryOrderEntry entry = model.addLibraryEntry(libraries[0]);
LibrariesUtil.placeEntryToCorrectPlace(model, entry);
model.commit();
return true;
}
finally {
accessToken.finish();
}
}
}
return false;
}
示例10: updateLibraryDependency
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static void updateLibraryDependency(ModifiableRootModel model, LibraryKey libraryKey) {
LibraryTable libraryTable = ProjectLibraryTable.getInstance(model.getProject());
Library library = libraryTable.getLibraryByName(libraryKey.getIntelliJLibraryName());
if (library == null) {
logger.error(
"Library missing: "
+ libraryKey.getIntelliJLibraryName()
+ ". Please resync project to resolve.");
return;
}
model.addLibraryEntry(library);
}
示例11: updateProjectStructure
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void updateProjectStructure(
Project project,
BlazeContext context,
WorkspaceRoot workspaceRoot,
ProjectViewSet projectViewSet,
BlazeProjectData blazeProjectData,
@Nullable BlazeProjectData oldBlazeProjectData,
ModuleEditor moduleEditor,
Module workspaceModule,
ModifiableRootModel workspaceModifiableModel) {
if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.DART)) {
return;
}
Library dartSdkLibrary = DartSdkUtils.findDartLibrary(project);
if (dartSdkLibrary != null) {
if (workspaceModifiableModel.findLibraryOrderEntry(dartSdkLibrary) == null) {
workspaceModifiableModel.addLibraryEntry(dartSdkLibrary);
}
} else {
IssueOutput.error(
"Dart language support is requested, but the Dart SDK was not found. "
+ "You must manually enable Dart support from "
+ "File > Settings > Languages & Frameworks > Dart.")
.submit(context);
}
}
示例12: updateProjectStructure
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
@Override
public void updateProjectStructure(
Project project,
BlazeContext context,
WorkspaceRoot workspaceRoot,
ProjectViewSet projectViewSet,
BlazeProjectData blazeProjectData,
@Nullable BlazeProjectData oldBlazeProjectData,
ModuleEditor moduleEditor,
Module workspaceModule,
ModifiableRootModel workspaceModifiableModel) {
if (!blazeProjectData.workspaceLanguageSettings.isLanguageActive(LanguageClass.KOTLIN)) {
return;
}
Library kotlinJavaRuntimeLibrary = KotlinSdkUtils.findKotlinJavaRuntime(project);
if (kotlinJavaRuntimeLibrary != null) {
if (workspaceModifiableModel.findLibraryOrderEntry(kotlinJavaRuntimeLibrary) == null) {
workspaceModifiableModel.addLibraryEntry(kotlinJavaRuntimeLibrary);
}
} else {
// since the runtime library was not found remove the kotlin-runtime ijar if present -- it
// prevents the kotlin plugin from kicking in and offering to setup the kotlin std library.
removeKotlinRuntimeIjar(project, workspaceModifiableModel);
IssueOutput.error(
"Kotlin JVM runtime libraries not found in workspace libraries, setup the Kotlin "
+ "plugin.")
.submit(context);
}
}
示例13: setupRootModel
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private static void setupRootModel(
ProjectDescriptor projectDescriptor,
final ModuleDescriptor descriptor,
final ModifiableRootModel rootModel,
final Map<LibraryDescriptor, Library> projectLibs) {
final CompilerModuleExtension compilerModuleExtension =
rootModel.getModuleExtension(CompilerModuleExtension.class);
compilerModuleExtension.setExcludeOutput(true);
rootModel.inheritSdk();
//Module root model seems to store .iml files root dependencies. (src, test, lib)
logger.info("Starting setupRootModel in ProjectFromSourcesBuilderImplModified");
final Set<File> contentRoots = descriptor.getContentRoots();
for (File contentRoot : contentRoots) {
final LocalFileSystem lfs = LocalFileSystem.getInstance();
VirtualFile moduleContentRoot =
lfs.refreshAndFindFileByPath(
FileUtil.toSystemIndependentName(contentRoot.getPath()));
if (moduleContentRoot != null) {
final ContentEntry contentEntry = rootModel.addContentEntry(moduleContentRoot);
final Collection<DetectedSourceRoot> sourceRoots =
descriptor.getSourceRoots(contentRoot);
for (DetectedSourceRoot srcRoot : sourceRoots) {
final String srcpath =
FileUtil.toSystemIndependentName(srcRoot.getDirectory().getPath());
final VirtualFile sourceRoot = lfs.refreshAndFindFileByPath(srcpath);
if (sourceRoot != null) {
contentEntry.addSourceFolder(
sourceRoot,
shouldBeTestRoot(srcRoot.getDirectory()),
getPackagePrefix(srcRoot));
}
}
}
}
logger.info("Inherits compiler output path from project");
compilerModuleExtension.inheritCompilerOutputPath(true);
logger.info("Starting to create module level libraries");
final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();
for (LibraryDescriptor libDescriptor :
ModuleInsight.getLibraryDependencies(
descriptor, projectDescriptor.getLibraries())) {
final Library projectLib = projectLibs.get(libDescriptor);
if (projectLib != null) {
rootModel.addLibraryEntry(projectLib);
} else {
// add as module library
final Collection<File> jars = libDescriptor.getJars();
for (File file : jars) {
Library library = moduleLibraryTable.createLibrary();
Library.ModifiableModel modifiableModel = library.getModifiableModel();
modifiableModel.addRoot(
VfsUtil.getUrlForLibraryRoot(file), OrderRootType.CLASSES);
modifiableModel.commit();
}
}
}
logger.info("Ending setupRootModel in ProjectFromSourcesBuilderImplModified");
}
示例14: addSupport
import com.intellij.openapi.roots.ModifiableRootModel; //导入方法依赖的package包/类
private void addSupport(final Module module,
final ModifiableRootModel rootModel,
FrameworkSupportModel frameworkSupportModel,
String sdkPath,
@Nullable PersistenceApi persistenceApi) {
FacetType<AppEngineFacet, AppEngineFacetConfiguration> facetType = AppEngineFacet.getFacetType();
AppEngineFacet appEngineFacet = FacetManager.getInstance(module).addFacet(facetType, facetType.getDefaultFacetName(), null);
AppEngineWebIntegration webIntegration = AppEngineWebIntegration.getInstance();
webIntegration.registerFrameworkInModel(frameworkSupportModel, appEngineFacet);
final AppEngineFacetConfiguration facetConfiguration = appEngineFacet.getConfiguration();
facetConfiguration.setSdkHomePath(sdkPath);
final AppEngineSdk sdk = appEngineFacet.getSdk();
final Artifact webArtifact = findOrCreateWebArtifact(appEngineFacet);
final VirtualFile webDescriptorDir = webIntegration.suggestParentDirectoryForAppEngineWebXml(module, rootModel);
if (webDescriptorDir != null) {
VirtualFile descriptor = createFileFromTemplate(AppEngineTemplateGroupDescriptorFactory.APP_ENGINE_WEB_XML_TEMPLATE, webDescriptorDir,
AppEngineUtil.APP_ENGINE_WEB_XML_NAME);
if (descriptor != null) {
webIntegration.addDescriptor(webArtifact, module.getProject(), descriptor);
}
}
final Project project = module.getProject();
webIntegration.addDevServerToModuleDependencies(rootModel, sdk);
final Library apiJar = addProjectLibrary(module, "AppEngine API", sdk.getUserLibraryPaths(), VirtualFile.EMPTY_ARRAY);
rootModel.addLibraryEntry(apiJar);
webIntegration.addLibraryToArtifact(apiJar, webArtifact, project);
if (persistenceApi != null) {
facetConfiguration.setRunEnhancerOnMake(true);
facetConfiguration.setPersistenceApi(persistenceApi);
facetConfiguration.getFilesToEnhance().addAll(AppEngineUtil.getDefaultSourceRootsToEnhance(rootModel));
try {
final VirtualFile[] sourceRoots = rootModel.getSourceRoots();
final VirtualFile sourceRoot;
if (sourceRoots.length > 0) {
sourceRoot = sourceRoots[0];
}
else {
sourceRoot = findOrCreateChildDirectory(rootModel.getContentRoots()[0], "src");
}
VirtualFile metaInf = findOrCreateChildDirectory(sourceRoot, "META-INF");
if (persistenceApi == PersistenceApi.JDO || persistenceApi == PersistenceApi.JDO3) {
createFileFromTemplate(AppEngineTemplateGroupDescriptorFactory.APP_ENGINE_JDO_CONFIG_TEMPLATE, metaInf, AppEngineUtil.JDO_CONFIG_XML_NAME);
}
else {
final VirtualFile file = createFileFromTemplate(AppEngineTemplateGroupDescriptorFactory.APP_ENGINE_JPA_CONFIG_TEMPLATE, metaInf, AppEngineUtil.JPA_CONFIG_XML_NAME);
if (file != null) {
webIntegration.setupJpaSupport(module, file);
}
}
}
catch (IOException e) {
LOG.error(e);
}
final Library library = addProjectLibrary(module, "AppEngine ORM", Collections.singletonList(sdk.getOrmLibDirectoryPath()), sdk.getOrmLibSources());
rootModel.addLibraryEntry(library);
webIntegration.addLibraryToArtifact(library, webArtifact, project);
}
}