Search in sources :

Example 56 with MavenId

use of org.jetbrains.idea.maven.model.MavenId in project android by JetBrains.

the class AndroidFacetImporterBase method resolve.

@Override
public void resolve(final Project project, MavenProject mavenProject, NativeMavenProjectHolder nativeMavenProject, MavenEmbedderWrapper embedder, ResolveContext context) throws MavenProcessCanceledException {
    final AndroidExternalApklibDependenciesManager adm = AndroidExternalApklibDependenciesManager.getInstance(project);
    for (MavenArtifact depArtifact : mavenProject.getDependencies()) {
        final MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(project);
        if (AndroidMavenUtil.APKLIB_DEPENDENCY_AND_PACKAGING_TYPE.equals(depArtifact.getType()) && mavenProjectsManager.findProject(depArtifact) == null && MavenConstants.SCOPE_COMPILE.equals(depArtifact.getScope())) {
            Set<MavenId> resolvedArtifacts = context.getUserData(RESOLVED_APKLIB_ARTIFACTS_KEY);
            if (resolvedArtifacts == null) {
                resolvedArtifacts = new HashSet<MavenId>();
                context.putUserData(RESOLVED_APKLIB_ARTIFACTS_KEY, resolvedArtifacts);
            }
            if (resolvedArtifacts.add(depArtifact.getMavenId())) {
                doResolveApklibArtifact(project, depArtifact, embedder, mavenProjectsManager, mavenProject.getName(), adm, context);
            }
        }
    }
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenArtifact(org.jetbrains.idea.maven.model.MavenArtifact)

Example 57 with MavenId

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

the class Flexmojos3Configurator method ensureSdkHasRequiredAdditionalJarPaths.

private void ensureSdkHasRequiredAdditionalJarPaths(@NotNull final Sdk sdk) {
    assert sdk.getSdkType() instanceof FlexmojosSdkType;
    final FlexmojosSdkAdditionalData additionalData = ((FlexmojosSdkAdditionalData) sdk.getSdkAdditionalData());
    assert additionalData != null;
    for (MavenId dependency : myFlexmojosPlugin.getDependencies()) {
        if (StringUtil.isEmpty(dependency.getArtifactId()))
            continue;
        for (Pattern jarNamePattern : ADDITIONAL_JAR_NAME_PATTERNS_TO_INCLUDE_IN_FLEXMOJOS_SDK_CLASSPATH) {
            if (jarNamePattern.matcher(dependency.getArtifactId()).matches()) {
                final String jarFilePath = getArtifactFilePath(myMavenProject, dependency, MavenConstants.TYPE_JAR);
                additionalData.addFlexCompilerClasspathEntryIfNotPresentAndRemoveDifferentVersionOfThisJar(jarNamePattern, jarFilePath);
                break;
            }
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) MavenId(org.jetbrains.idea.maven.model.MavenId) FlexmojosSdkAdditionalData(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkAdditionalData) FlexmojosSdkType(com.intellij.lang.javascript.flex.sdk.FlexmojosSdkType)

Example 58 with MavenId

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

the class Flexmojos4GenerateConfigTask method writeWorkspaceMap.

private void writeWorkspaceMap(final Collection<MavenProject> mavenProjects) throws IOException {
    int actualLength = 0;
    for (MavenProject mavenProject : mavenProjects) {
        if (ArrayUtil.contains(mavenProject.getPackaging(), FlexmojosImporter.SUPPORTED_PACKAGINGS)) {
            actualLength++;
        }
    }
    out.writeShort(actualLength);
    @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") ObjectOutputStream objectOutputStream = new ObjectOutputStream(out);
    for (MavenProject mavenProject : mavenProjects) {
        if (!ArrayUtil.contains(mavenProject.getPackaging(), FlexmojosImporter.SUPPORTED_PACKAGINGS)) {
            continue;
        }
        final MavenId mavenId = mavenProject.getMavenId();
        objectOutputStream.writeObject(mavenId.getGroupId());
        objectOutputStream.writeObject(mavenId.getArtifactId());
        objectOutputStream.writeObject(mavenId.getVersion());
        objectOutputStream.writeObject(mavenProject.getFile().getPath());
    }
    objectOutputStream.flush();
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId)

Example 59 with MavenId

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

the class OsmorcFacetImporter method computeSymbolicName.

/**
   * Computes the Bundle-SymbolicName value from the data given in the maven project.
   */
@NotNull
private String computeSymbolicName(MavenProject mavenProject) {
    String bundleSymbolicName = findConfigValue(mavenProject, "instructions." + Constants.BUNDLE_SYMBOLICNAME);
    if (!StringUtil.isEmpty(bundleSymbolicName)) {
        return bundleSymbolicName;
    }
    MavenId mavenId = mavenProject.getMavenId();
    String groupId = mavenId.getGroupId();
    String artifactId = mavenId.getArtifactId();
    if (groupId == null || artifactId == null) {
        return "";
    }
    // if artifactId is equal to last section of groupId then groupId is returned (org.apache.maven:maven -> org.apache.maven)
    String lastSectionOfGroupId = groupId.substring(groupId.lastIndexOf(".") + 1);
    if (lastSectionOfGroupId.endsWith(artifactId)) {
        return groupId;
    }
    // if artifactId starts with last section of groupId that portion is removed (org.apache.maven:maven-core -> org.apache.maven.core)
    String doubledNamePart = lastSectionOfGroupId + "-";
    if (artifactId.startsWith(doubledNamePart) && artifactId.length() > doubledNamePart.length()) {
        return groupId + "." + artifactId.substring(doubledNamePart.length());
    }
    return groupId + "." + artifactId;
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) NotNull(org.jetbrains.annotations.NotNull)

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