Search in sources :

Example 16 with MavenId

use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.

the class MavenArtifactCoordinatesConverter method fromString.

public String fromString(@Nullable @NonNls String s, ConvertContext context) {
    if (s == null)
        return null;
    MavenId id = MavenArtifactCoordinatesHelper.getId(context);
    MavenProjectIndicesManager manager = MavenProjectIndicesManager.getInstance(context.getProject());
    return selectStrategy(context).isValid(id, manager, context) ? s : null;
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenProjectIndicesManager(org.jetbrains.idea.maven.indices.MavenProjectIndicesManager)

Example 17 with MavenId

use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.

the class DependenciesImportingTest method testInterModuleDependenciesWithReleaseVersion.

public void testInterModuleDependenciesWithReleaseVersion() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<packaging>pom</packaging>" + "<version>1</version>" + "<modules>" + "  <module>m1</module>" + "  <module>m2</module>" + "</modules>");
    createModulePom("m1", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>" + "<dependencies>" + "  <dependency>" + "    <groupId>test</groupId>" + "    <artifactId>m2</artifactId>" + "    <version>RELEASE</version>" + "  </dependency>" + "</dependencies>");
    createModulePom("m2", "<groupId>test</groupId>" + "<artifactId>m2</artifactId>" + "<version>1</version>");
    importProject();
    assertModules("project", "m1", "m2");
    assertModuleModuleDeps("m1", "m2");
    assertModuleLibDeps("m1");
    MavenProject p = myProjectsTree.findProject(new MavenId("test", "m1", "1"));
    assertEquals(new MavenId("test", "m2", "1"), p.getDependencies().get(0).getMavenId());
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 18 with MavenId

use of org.jetbrains.idea.maven.model.MavenId in project intellij-community by JetBrains.

the class DependenciesImportingTest method testInterModuleDependenciesWithLatestVersion.

public void testInterModuleDependenciesWithLatestVersion() throws Exception {
    createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + "<packaging>pom</packaging>" + "<version>1</version>" + "<modules>" + "  <module>m1</module>" + "  <module>m2</module>" + "</modules>");
    createModulePom("m1", "<groupId>test</groupId>" + "<artifactId>m1</artifactId>" + "<version>1</version>" + "<dependencies>" + "  <dependency>" + "    <groupId>test</groupId>" + "    <artifactId>m2</artifactId>" + "    <version>LATEST</version>" + "  </dependency>" + "</dependencies>");
    createModulePom("m2", "<groupId>test</groupId>" + "<artifactId>m2</artifactId>" + "<version>1</version>");
    importProject();
    assertModules("project", "m1", "m2");
    assertModuleModuleDeps("m1", "m2");
    assertModuleLibDeps("m1");
    MavenProject p = myProjectsTree.findProject(new MavenId("test", "m1", "1"));
    assertEquals(new MavenId("test", "m2", "1"), p.getDependencies().get(0).getMavenId());
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenProject(org.jetbrains.idea.maven.project.MavenProject)

Example 19 with MavenId

use of org.jetbrains.idea.maven.model.MavenId 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);
    }
}
Also used : OsmorcFacetConfiguration(org.osmorc.facet.OsmorcFacetConfiguration) MavenId(org.jetbrains.idea.maven.model.MavenId) MavenPlugin(org.jetbrains.idea.maven.model.MavenPlugin) Element(org.jdom.Element) File(java.io.File)

Example 20 with MavenId

use of org.jetbrains.idea.maven.model.MavenId in project intellij-plugins by JetBrains.

the class Flexmojos3Configurator method getFlexCompilerMavenId.

private MavenId getFlexCompilerMavenId() {
    for (final MavenId mavenId : myFlexmojosPlugin.getDependencies()) {
        if (FLEX_COMPILER_ARTIFACT_ID.equals(mavenId.getArtifactId()) && (FLEX_COMPILER_ADOBE_GROUP_ID.equals(mavenId.getGroupId()) || FLEX_COMPILER_APACHE_GROUP_ID.equals(mavenId.getGroupId()))) {
            return mavenId;
        }
    }
    for (final MavenArtifact mavenArtifact : myMavenProject.getDependencies()) {
        if ("com.adobe.flex".equals(mavenArtifact.getGroupId()) && "framework".equals(mavenArtifact.getArtifactId()) || "com.adobe.flex.framework".equals(mavenArtifact.getGroupId()) && ("flex-framework".equals(mavenArtifact.getArtifactId()) || "air-framework".equals(mavenArtifact.getArtifactId()))) {
            return new MavenId(FLEX_COMPILER_ADOBE_GROUP_ID, FLEX_COMPILER_ARTIFACT_ID, mavenArtifact.getVersion());
        }
        if ("org.apache.flex".equals(mavenArtifact.getGroupId()) && "framework".equals(mavenArtifact.getArtifactId()) || "org.apache.flex.framework".equals(mavenArtifact.getGroupId()) && ("flex-framework".equals(mavenArtifact.getArtifactId()) || "common-framework".equals(mavenArtifact.getArtifactId()))) {
            return new MavenId(FLEX_COMPILER_APACHE_GROUP_ID, FLEX_COMPILER_ARTIFACT_ID, mavenArtifact.getVersion());
        }
    }
    // correct flexmojos-maven-plugin resolving and taking version from 'flex.sdk.version' property value is rather expensive, so version is hardcoded
    final String version;
    final String pluginVersion = myFlexmojosPlugin.getVersion();
    if (StringUtil.compareVersionNumbers(pluginVersion, "5") >= 0) {
        version = "4.6.0.23201";
    } else if (StringUtil.compareVersionNumbers(pluginVersion, "4.1") >= 0 || pluginVersion != null && pluginVersion.startsWith("4.0-RC")) {
        version = "4.5.1.21328";
    } else if (StringUtil.compareVersionNumbers(pluginVersion, "4") >= 0) {
        version = "4.5.0.18623";
    } else {
        version = "3.2.0.3958";
    }
    return new MavenId(FLEX_COMPILER_ADOBE_GROUP_ID, FLEX_COMPILER_ARTIFACT_ID, version);
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact)

Aggregations

MavenId (org.jetbrains.idea.maven.model.MavenId)59 MavenProject (org.jetbrains.idea.maven.project.MavenProject)16 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 Module (com.intellij.openapi.module.Module)5 NotNull (org.jetbrains.annotations.NotNull)5 Nullable (org.jetbrains.annotations.Nullable)5 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)4 IOException (java.io.IOException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 RemoteException (java.rmi.RemoteException)4 ArchetypeDataSourceException (org.apache.maven.archetype.source.ArchetypeDataSourceException)4 SoutMavenConsole (org.jetbrains.idea.maven.execution.SoutMavenConsole)4 MavenArtifact (org.jetbrains.idea.maven.model.MavenArtifact)4 MavenServerExecutionResult (org.jetbrains.idea.maven.server.MavenServerExecutionResult)4 Project (com.intellij.openapi.project.Project)3 File (java.io.File)3 MavenArchetype (org.jetbrains.idea.maven.model.MavenArchetype)3 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)2 Result (com.intellij.openapi.application.Result)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2