Search in sources :

Example 1 with MavenWorkspaceMap

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

the class CustomMaven3ArtifactResolver method resolveAsModule.

private boolean resolveAsModule(Artifact a) {
    // method is called from different threads, so we have to copy the reference so ensure there is no race conditions.
    MavenWorkspaceMap map = myWorkspaceMap;
    if (map == null)
        return false;
    MavenWorkspaceMap.Data resolved = map.findFileAndOriginalId(MavenModelConverter.createMavenId(a));
    if (resolved == null)
        return false;
    a.setResolved(true);
    a.setFile(resolved.getFile(a.getType()));
    a.selectVersion(resolved.originalId.getVersion());
    return true;
}
Also used : MavenWorkspaceMap(org.jetbrains.idea.maven.model.MavenWorkspaceMap)

Example 2 with MavenWorkspaceMap

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

the class CustomArtifactResolver method resolveAsModule.

private boolean resolveAsModule(Artifact a) {
    // method is called from different threads, so we have to copy the reference so ensure there is no race conditions.
    MavenWorkspaceMap map = myWorkspaceMap;
    if (map == null)
        return false;
    MavenWorkspaceMap.Data resolved = map.findFileAndOriginalId(Maven2ModelConverter.createMavenId(a));
    if (resolved == null)
        return false;
    a.setResolved(true);
    a.setFile(resolved.getFile(a.getType()));
    a.selectVersion(resolved.originalId.getVersion());
    return true;
}
Also used : MavenWorkspaceMap(org.jetbrains.idea.maven.model.MavenWorkspaceMap)

Example 3 with MavenWorkspaceMap

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

the class CustomMaven30ArtifactResolver method resolveAsModule.

private boolean resolveAsModule(Artifact a) {
    // method is called from different threads, so we have to copy the reference so ensure there is no race conditions.
    MavenWorkspaceMap map = myWorkspaceMap;
    if (map == null)
        return false;
    MavenWorkspaceMap.Data resolved = map.findFileAndOriginalId(MavenModelConverter.createMavenId(a));
    if (resolved == null)
        return false;
    a.setResolved(true);
    a.setFile(resolved.getFile(a.getType()));
    a.selectVersion(resolved.originalId.getVersion());
    return true;
}
Also used : MavenWorkspaceMap(org.jetbrains.idea.maven.model.MavenWorkspaceMap)

Example 4 with MavenWorkspaceMap

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

the class Flexmojos3GenerateConfigTask method perform.

public void perform(final Project project, final MavenEmbeddersManager embeddersManager, final MavenConsole console, final MavenProgressIndicator indicator) throws MavenProcessCanceledException {
    if (myModule.isDisposed())
        return;
    indicator.setText(FlexBundle.message("generating.flex.config.for", myMavenProject.getDisplayName()));
    final MavenProjectsTree.EmbedderTask task = new MavenProjectsTree.EmbedderTask() {

        public void run(MavenEmbedderWrapper embedder) throws MavenProcessCanceledException {
            List<VirtualFile> temporaryFiles = null;
            final IgnoredFileBean[] filesToIgnoreOriginal = ChangeListManager.getInstance(project).getFilesToIgnore();
            try {
                MavenWorkspaceMap workspaceMap = new MavenWorkspaceMap();
                temporaryFiles = mavenIdToOutputFileMapping(workspaceMap, project, myTree.getProjects());
                embedder.customizeForStrictResolve(workspaceMap, console, indicator);
                final String generateConfigGoal = FlexmojosImporter.FLEXMOJOS_GROUP_ID + ":" + FlexmojosImporter.FLEXMOJOS_ARTIFACT_ID + ":generate-config-" + myMavenProject.getPackaging();
                final MavenExplicitProfiles profilesIds = myMavenProject.getActivatedProfilesIds();
                MavenServerExecutionResult result = embedder.execute(myMavenProject.getFile(), profilesIds.getEnabledProfiles(), profilesIds.getDisabledProfiles(), Collections.singletonList(generateConfigGoal));
                if (result.projectData == null) {
                    myFlexConfigInformer.showFlexConfigWarningIfNeeded(project);
                }
                MavenUtil.invokeAndWaitWriteAction(project, () -> {
                    // need to refresh externally created file
                    final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(myConfigFilePath);
                    if (file != null) {
                        file.refresh(false, false);
                        updateMainClass(myModule, file);
                    }
                });
            } catch (MavenProcessCanceledException e) {
                throw e;
            } catch (Exception e) {
                myFlexConfigInformer.showFlexConfigWarningIfNeeded(project);
                console.printException(e);
                MavenLog.LOG.warn(e);
            } finally {
                ChangeListManager.getInstance(project).setFilesToIgnore(filesToIgnoreOriginal);
                if (temporaryFiles != null && !temporaryFiles.isEmpty()) {
                    removeTemporaryFiles(project, temporaryFiles);
                }
            }
        }
    };
    myTree.executeWithEmbedder(myMavenProject, embeddersManager, MavenEmbeddersManager.FOR_POST_PROCESSING, console, indicator, task);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) MavenExplicitProfiles(org.jetbrains.idea.maven.model.MavenExplicitProfiles) MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper) MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) IOException(java.io.IOException) ConfigurationException(com.intellij.openapi.options.ConfigurationException) MavenServerExecutionResult(org.jetbrains.idea.maven.server.MavenServerExecutionResult) IgnoredFileBean(com.intellij.openapi.vcs.changes.IgnoredFileBean) MavenWorkspaceMap(org.jetbrains.idea.maven.model.MavenWorkspaceMap)

Example 5 with MavenWorkspaceMap

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

the class CustomMaven3RepositoryMetadataManager method resolve.

@Override
public void resolve(RepositoryMetadata metadata, RepositoryRequest request) throws RepositoryMetadataResolutionException {
    super.resolve(metadata, request);
    MavenWorkspaceMap map = myWorkspaceMap;
    if (map == null)
        return;
    Metadata data = metadata.getMetadata();
    Versioning versioning = data.getVersioning();
    if (versioning == null) {
        data.setVersioning(versioning = new Versioning());
    }
    for (MavenId each : map.getAvailableIds()) {
        if (each.equals(data.getGroupId(), data.getArtifactId())) {
            versioning.addVersion(each.getVersion());
        }
    }
}
Also used : MavenId(org.jetbrains.idea.maven.model.MavenId) MavenWorkspaceMap(org.jetbrains.idea.maven.model.MavenWorkspaceMap)

Aggregations

MavenWorkspaceMap (org.jetbrains.idea.maven.model.MavenWorkspaceMap)6 MavenId (org.jetbrains.idea.maven.model.MavenId)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 IgnoredFileBean (com.intellij.openapi.vcs.changes.IgnoredFileBean)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 IOException (java.io.IOException)1 MavenExplicitProfiles (org.jetbrains.idea.maven.model.MavenExplicitProfiles)1 MavenEmbedderWrapper (org.jetbrains.idea.maven.server.MavenEmbedderWrapper)1 MavenServerExecutionResult (org.jetbrains.idea.maven.server.MavenServerExecutionResult)1 MavenProcessCanceledException (org.jetbrains.idea.maven.utils.MavenProcessCanceledException)1