本文整理汇总了Java中org.jetbrains.idea.maven.project.MavenProject类的典型用法代码示例。如果您正苦于以下问题:Java MavenProject类的具体用法?Java MavenProject怎么用?Java MavenProject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MavenProject类属于org.jetbrains.idea.maven.project包,在下文中一共展示了MavenProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collectComponentsToScan
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
@Override
protected Components collectComponentsToScan(@Nullable DataNode<ProjectData> externalProject) {
Components components = ComponentsFactory.create();
// This set is used to make sure the artifacts added are unique
Set<String> added = Sets.newHashSet();
for (MavenProject mavenProject : MavenProjectsManager.getInstance(project).getProjects()) {
for (MavenArtifactNode mavenArtifactNode : mavenProject.getDependencyTree()) {
if (added.add(mavenArtifactNode.getArtifact().getDisplayStringForLibraryName())) {
addArtifact(components, mavenArtifactNode.getArtifact());
for (MavenArtifactNode artifactNode : mavenArtifactNode.getDependencies()) {
addArtifact(components, artifactNode.getArtifact());
}
}
}
}
return components;
}
示例2: testCreatingFromArchetype
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
public void testCreatingFromArchetype() throws Exception {
if (!hasMavenInstallation()) return;
setArchetype(new MavenArchetype("org.apache.maven.archetypes", "maven-archetype-quickstart", "1.0", null, null));
MavenId id = new MavenId("org.foo", "module", "1.0");
createNewModule(id);
List<MavenProject> projects = MavenProjectsManager.getInstance(myProject).getProjects();
assertEquals(1, projects.size());
MavenProject project = projects.get(0);
assertEquals(id, project.getMavenId());
assertNotNull(myProjectRoot.findFileByRelativePath("src/main/java/org/foo/App.java"));
assertNotNull(myProjectRoot.findFileByRelativePath("src/test/java/org/foo/AppTest.java"));
assertSources("module", "src/main/java");
assertTestSources("module", "src/test/java");
}
示例3: testUnresolvedPlugins
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
public void testUnresolvedPlugins() throws Exception {
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<build>" +
" <plugins>" +
" <plugin>" +
" <groupId>xxx</groupId>" +
" <artifactId>yyy</artifactId>" +
" <version>1</version>" +
" </plugin>" +
" </plugins>" +
"</build>");
MavenProject root = getRootProjects().get(0);
assertProblems(root, "Unresolved plugin: 'xxx:yyy:1'");
}
示例4: isMavenAarDependency
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
public static boolean isMavenAarDependency(@NotNull Module module, @NotNull OrderEntry entry) {
if (ApplicationManager.getApplication().isUnitTestMode() && entry.getPresentableName().equals("maven_aar_dependency")) {
return true;
}
if (!(entry instanceof LibraryOrderEntry) || !isMavenizedModule(module)) {
return false;
}
final Library library = ((LibraryOrderEntry)entry).getLibrary();
if (library == null) {
return false;
}
final MavenProject mavenProject = MavenProjectsManager.getInstance(module.getProject()).findProject(module);
if (mavenProject == null) {
return false;
}
final MavenArtifact artifact = MavenRootModelAdapter.findArtifact(mavenProject, library);
return artifact != null && AAR_DEPENDENCY_AND_PACKAGING_TYPE.equals(artifact.getType());
}
示例5: checkOrPerform
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
private static boolean checkOrPerform(DataContext context, boolean perform) {
final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
if (goals == null || goals.isEmpty()) return false;
final Project project = MavenActionUtil.getProject(context);
if(project == null) return false;
final MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
if (mavenProject == null) return false;
if (!perform) return true;
final MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
if(projectsManager == null) return false;
MavenExplicitProfiles explicitProfiles = projectsManager.getExplicitProfiles();
final MavenRunnerParameters params = new MavenRunnerParameters(true,
mavenProject.getDirectory(),
goals,
explicitProfiles.getEnabledProfiles(),
explicitProfiles.getDisabledProfiles());
MavenRunConfigurationType.runConfiguration(project, params, null);
return true;
}
示例6: isAvailable
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
@Override
protected boolean isAvailable(AnActionEvent e) {
if (!super.isAvailable(e)) return false;
final DataContext context = e.getDataContext();
MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
if(projectsManager == null) return false;
List<MavenProject> projects = MavenActionUtil.getMavenProjects(context);
if (projects == null || projects.isEmpty()) return false;
int ignoredStatesCount = 0;
int ignoredCount = 0;
for (MavenProject each : projects) {
if (projectsManager.getIgnoredState(each)) {
ignoredStatesCount++;
}
if (projectsManager.isIgnored(each)) {
ignoredCount++;
}
}
return (ignoredCount == 0 || ignoredCount == projects.size()) &&
(ignoredStatesCount == 0 || ignoredStatesCount == projects.size());
}
示例7: process
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
@Override
public void process(IdeModifiableModelsProvider modifiableModelsProvider,
Module module,
MavenRootModelAdapter rootModel,
MavenProjectsTree mavenModel,
MavenProject mavenProject,
MavenProjectChanges changes,
Map<MavenProject, String> mavenProjectToModuleName,
List<MavenProjectsProcessorTask> postTasks) {
FACET_TYPE f = findFacet(modifiableModelsProvider.getModifiableFacetModel(module));
if (f == null) return; // facet may has been removed between preProcess and process calls
if (!isFacetDetectionDisabled(module.getProject())) {
reimportFacet(modifiableModelsProvider, module, rootModel, f, mavenModel, mavenProject, changes, mavenProjectToModuleName, postTasks);
}
}
示例8: actionPerformed
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final DataContext context = e.getDataContext();
MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
if(projectsManager == null) return;
List<MavenProject> projects = MavenActionUtil.getMavenProjects(context);
final Project project = MavenActionUtil.getProject(context);
if(project == null) return;
if (isIgnoredInSettings(projectsManager, projects)) {
ShowSettingsUtil.getInstance()
.editConfigurable(project, new MavenIgnoredFilesConfigurable(project));
}
else {
projectsManager.setIgnoredState(projects, !isIgnored(projectsManager, projects));
}
}
示例9: MavenModuleBuilderHelper
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
public MavenModuleBuilderHelper(@NotNull MavenId projectId,
MavenProject aggregatorProject,
MavenProject parentProject,
boolean inheritGroupId,
boolean inheritVersion,
MavenArchetype archetype,
Map<String, String> propertiesToCreateByArtifact,
String commaneName) {
myProjectId = projectId;
myAggregatorProject = aggregatorProject;
myParentProject = parentProject;
myInheritGroupId = inheritGroupId;
myInheritVersion = inheritVersion;
myArchetype = archetype;
myPropertiesToCreateByArtifact = propertiesToCreateByArtifact;
myCommandName = commaneName;
}
示例10: testDoNotFailIfRepositoryHasEmptyLayout
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
public void testDoNotFailIfRepositoryHasEmptyLayout() throws Exception {
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<repositories>" +
" <repository>" +
" <id>foo1</id>" +
" <url>bar1</url>" +
" <layout/>" +
" </repository>" +
"</repositories>" +
"<pluginRepositories>" +
" <pluginRepository>" +
" <id>foo2</id>" +
" <url>bar2</url>" +
" <layout/>" +
" </pluginRepository>" +
"</pluginRepositories>");
MavenProject root = getRootProjects().get(0);
assertProblems(root);
}
示例11: doIsValid
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
@Override
protected boolean doIsValid(MavenId id, MavenProjectIndicesManager manager, ConvertContext context) {
if (StringUtil.isEmpty(id.getGroupId())) return false;
if (manager.hasGroupId(id.getGroupId())) return true;
// Check if artifact was found on importing.
MavenProject mavenProject = findMavenProject(context);
if (mavenProject != null) {
for (MavenArtifact artifact : mavenProject.findDependencies(id.getGroupId(), id.getArtifactId())) {
if (artifact.isResolved()) {
return true;
}
}
}
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MavenArtifactCoordinatesGroupIdConverter.java
示例12: getDescription
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
public String getDescription(MavenProject project, String goal) {
List<String> result = new ArrayList<String>();
MavenCompilerTask compilerTask = new MavenCompilerTask(project.getPath(), goal);
synchronized (this) {
for (Phase phase : Phase.values()) {
if (myState.getTasks(phase).contains(compilerTask)) {
result.add(TasksBundle.message(phase.myMessageKey));
}
}
}
RunManagerEx runManager = RunManagerEx.getInstanceEx(myProject);
for (MavenBeforeRunTask each : runManager.getBeforeRunTasks(MavenBeforeRunTasksProvider.ID)) {
if (each.isFor(project, goal)) {
result.add(TasksBundle.message("maven.tasks.goal.before.run"));
break;
}
}
return StringUtil.join(result, ", ");
}
示例13: testUnresolvedParent
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
public void testUnresolvedParent() throws Exception {
importProject("<groupId>test</groupId>" +
"<artifactId>project</artifactId>" +
"<version>1</version>" +
"<parent>" +
" <groupId>test</groupId>" +
" <artifactId>parent</artifactId>" +
" <version>1</version>" +
"</parent>");
assertModules("project");
MavenProject root = getRootProjects().get(0);
assertProblems(root, "Parent 'test:parent:1' not found");
}
示例14: allGroupsEqual
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
private static boolean allGroupsEqual(Collection<MavenProject> mavenProjects) {
Iterator<MavenProject> itr = mavenProjects.iterator();
if (!itr.hasNext()) return true;
String groupId = itr.next().getMavenId().getGroupId();
while (itr.hasNext()) {
MavenProject mavenProject = itr.next();
if (!Comparing.equal(groupId, mavenProject.getMavenId().getGroupId())) {
return false;
}
}
return true;
}
示例15: configure
import org.jetbrains.idea.maven.project.MavenProject; //导入依赖的package包/类
@Override
public void configure(@NotNull MavenProject mavenProject, @NotNull Project project, @Nullable Module module) {
if (module == null) return;
CompilerConfiguration configuration = CompilerConfiguration.getInstance(project);
if (!Boolean.TRUE.equals(module.getUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY))) {
String targetLevel = mavenProject.getTargetLevel();
// default source and target settings of maven-compiler-plugin is 1.5, see details at http://maven.apache.org/plugins/maven-compiler-plugin
configuration.setBytecodeTargetLevel(module, ObjectUtils.notNull(targetLevel, "1.5"));
}
module.putUserData(IGNORE_MAVEN_COMPILER_TARGET_KEY, Boolean.FALSE);
// Exclude src/main/archetype-resources
VirtualFile dir = VfsUtil.findRelativeFile(mavenProject.getDirectoryFile(), "src", "main", "resources", "archetype-resources");
if (dir != null && !configuration.isExcludedFromCompilation(dir)) {
ExcludesConfiguration cfg = configuration.getExcludedEntriesConfiguration();
cfg.addExcludeEntryDescription(new ExcludeEntryDescription(dir, true, false, project));
}
}