use of org.jetbrains.idea.maven.model.MavenPlugin in project intellij-community by JetBrains.
the class MavenUtil method getPhaseVariants.
public static List<LookupElement> getPhaseVariants(MavenProjectsManager manager) {
Set<String> goals = new HashSet<>();
goals.addAll(MavenConstants.PHASES);
for (MavenProject mavenProject : manager.getProjects()) {
for (MavenPlugin plugin : mavenProject.getPlugins()) {
MavenPluginInfo pluginInfo = MavenArtifactUtil.readPluginInfo(manager.getLocalRepository(), plugin.getMavenId());
if (pluginInfo != null) {
for (MavenPluginInfo.Mojo mojo : pluginInfo.getMojos()) {
goals.add(mojo.getDisplayName());
}
}
}
}
List<LookupElement> res = new ArrayList<>(goals.size());
for (String goal : goals) {
res.add(LookupElementBuilder.create(goal).withIcon(MavenIcons.Phase));
}
return res;
}
use of org.jetbrains.idea.maven.model.MavenPlugin in project intellij-community by JetBrains.
the class MavenKeymapExtension method collectGoals.
private static List<String> collectGoals(MavenProject project) {
// may contains similar plugins or somethig
LinkedHashSet<String> result = new LinkedHashSet<>();
result.addAll(MavenConstants.PHASES);
for (MavenPlugin each : project.getDeclaredPlugins()) {
collectGoals(project.getLocalRepository(), each, result);
}
return new ArrayList<>(result);
}
use of org.jetbrains.idea.maven.model.MavenPlugin in project intellij-plugins by JetBrains.
the class OsmorcFacetImporter method reimportFacet.
@Override
protected void reimportFacet(IdeModifiableModelsProvider modelsProvider, Module module, MavenRootModelAdapter mavenRootModelAdapter, OsmorcFacet osmorcFacet, MavenProjectsTree mavenProjectsTree, MavenProject mavenProject, MavenProjectChanges changes, Map<MavenProject, String> mavenProjectStringMap, List<MavenProjectsProcessorTask> mavenProjectsProcessorPostConfigurationTasks) {
OsmorcFacetConfiguration conf = osmorcFacet.getConfiguration();
if (conf.isDoNotSynchronizeWithMaven()) {
return;
}
// first off, we get the defaults
MavenId id = mavenProject.getMavenId();
conf.setBundleSymbolicName(id.getGroupId() + "." + id.getArtifactId());
conf.setBundleVersion(ImporterUtil.cleanupVersion(id.getVersion()));
MavenPlugin plugin = mavenProject.findPlugin(myPluginGroupID, myPluginArtifactID);
if (plugin == null) {
return;
}
// Check if there are any overrides set up in the maven plugin settings
// IDEA-63243
conf.setBundleSymbolicName(computeSymbolicName(mavenProject));
// to preserve the order of elements
Map<String, String> props = ContainerUtil.newLinkedHashMap();
Map<String, String> modelMap = mavenProject.getModelMap();
String description = modelMap.get("description");
if (!StringUtil.isEmptyOrSpaces(description)) {
props.put(Constants.BUNDLE_DESCRIPTION, description);
}
String licenses = modelMap.get("licenses");
if (!StringUtil.isEmptyOrSpaces(licenses)) {
props.put("Bundle-License", licenses);
}
String vendor = modelMap.get("organization.name");
if (!StringUtil.isEmpty(vendor)) {
props.put(Constants.BUNDLE_VENDOR, vendor);
}
String docUrl = modelMap.get("organization.url");
if (!StringUtil.isEmptyOrSpaces(docUrl)) {
props.put(Constants.BUNDLE_DOCURL, docUrl);
}
// load versions if any
Map<String, String> versions = cleanVersions(plugin);
// now find any additional properties that might have been set up:
Element instructionsNode = getConfig(mavenProject, "instructions");
if (instructionsNode != null) {
boolean useExistingManifest = false;
for (Element child : instructionsNode.getChildren()) {
String name = child.getName();
String value = child.getTextTrim();
value = value.replaceAll("\\p{Blank}*[\r\n]\\p{Blank}*", "");
value = substituteVersions(value, versions);
if (INCLUDE_MANIFEST.equals(name)) {
conf.setManifestLocation(value);
conf.setManifestGenerationMode(ManifestGenerationMode.Manually);
conf.setUseProjectDefaultManifestFileLocation(false);
useExistingManifest = true;
} else if (Constants.BUNDLE_VERSION.equals(name)) {
conf.setBundleVersion(value);
} else if (Constants.BUNDLE_ACTIVATOR.equals(name)) {
conf.setBundleActivator(value);
} else if (!StringUtil.isEmpty(value) && !Constants.BUNDLE_SYMBOLICNAME.equals(name)) {
if (StringUtil.startsWithChar(name, '_')) {
// sanitize instructions
name = "-" + name.substring(1);
}
props.put(name, value);
}
}
if (!useExistingManifest) {
conf.setManifestLocation("");
conf.setManifestGenerationMode(ManifestGenerationMode.OsmorcControlled);
conf.setUseProjectDefaultManifestFileLocation(true);
}
}
// check if bundle name exists, if not compute it (IDEA-63244)
if (!props.containsKey(Constants.BUNDLE_NAME)) {
props.put(Constants.BUNDLE_NAME, computeBundleName(mavenProject));
}
// now post-process the settings, to make Embed-Dependency work
ImporterUtil.postProcessAdditionalProperties(props, mavenProject, module.getProject());
// Fix for IDEA-63242 - don't merge it with the existing settings, overwrite them
conf.importAdditionalProperties(props, true);
// Fix for IDEA-66235 - inherit jar filename from maven
String jarFileName = mavenProject.getFinalName() + ".jar";
// FiX for IDEA-67088, preserve existing output path settings on reimport.
switch(conf.getOutputPathType()) {
case OsgiOutputPath:
conf.setJarFileLocation(jarFileName, OutputPathType.OsgiOutputPath);
break;
case SpecificOutputPath:
String path = new File(conf.getJarFilePath(), jarFileName).getPath();
conf.setJarFileLocation(path, OutputPathType.SpecificOutputPath);
break;
default:
conf.setJarFileLocation(jarFileName, OutputPathType.CompilerOutputPath);
}
}
use of org.jetbrains.idea.maven.model.MavenPlugin in project intellij-plugins by JetBrains.
the class FlexmojosImporter method getOutputFilePath.
public static String getOutputFilePath(final MavenProject mavenProject) {
MavenPlugin flexmojosPlugin = mavenProject.findPlugin(FLEXMOJOS_GROUP_ID, FLEXMOJOS_ARTIFACT_ID);
if (flexmojosPlugin == null)
flexmojosPlugin = mavenProject.findPlugin(Flexmojos5Importer.FLEXMOJOS_5_GROUP_ID, FLEXMOJOS_ARTIFACT_ID);
final Element configurationElement = flexmojosPlugin == null ? null : flexmojosPlugin.getConfigurationElement();
final String overriddenTargetFilePath = configurationElement == null || StringUtil.compareVersionNumbers(flexmojosPlugin.getVersion(), "4") >= 0 ? null : configurationElement.getChildTextNormalize("output", configurationElement.getNamespace());
if (overriddenTargetFilePath != null && !overriddenTargetFilePath.isEmpty()) {
return FileUtil.isAbsolute(overriddenTargetFilePath) ? FileUtil.toSystemIndependentName(overriddenTargetFilePath) : FileUtil.toSystemIndependentName(mavenProject.getDirectory() + "/" + overriddenTargetFilePath);
}
final String classifier = configurationElement == null ? null : configurationElement.getChildTextNormalize("classifier", configurationElement.getNamespace());
final String suffix = classifier == null ? "" : "-" + classifier;
final String fileExtension = "swc".equals(mavenProject.getPackaging()) ? "swc" : "swf";
return FileUtil.toSystemIndependentName(mavenProject.getBuildDirectory()) + "/" + mavenProject.getFinalName() + suffix + "." + fileExtension;
}
use of org.jetbrains.idea.maven.model.MavenPlugin in project liferay-ide by liferay.
the class LiferayWorkspaceUtil method isValidMavenWorkspaceLocation.
public static boolean isValidMavenWorkspaceLocation(Project project) {
File pomFile = new File(project.getBasePath(), _BUILD_MAVEN_FILE_NAME);
if (!pomFile.exists()) {
return false;
}
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
VirtualFile virtualPom = fileSystem.findFileByPath(pomFile.getPath());
if (virtualPom.exists()) {
boolean pom = MavenUtil.isPomFile(project, virtualPom);
if (!pom) {
return false;
}
}
try {
MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(project);
MavenProject mavenWorkspaceProject = mavenProjectsManager.findProject(virtualPom);
MavenPlugin liferayWorkspacePlugin = mavenWorkspaceProject.findPlugin("com.liferay", "com.liferay.portal.tools.bundle.support");
if (liferayWorkspacePlugin != null) {
return true;
}
} catch (Exception e) {
return false;
}
return false;
}
Aggregations