Search in sources :

Example 1 with ArtifactRepositoryManager

use of org.jetbrains.idea.maven.aether.ArtifactRepositoryManager in project intellij-community by JetBrains.

the class DependencyResolvingBuilder method getRepositoryManager.

private static ArtifactRepositoryManager getRepositoryManager(final CompileContext context) {
    ArtifactRepositoryManager manager = MANAGER_KEY.get(context);
    if (manager == null) {
        manager = new ArtifactRepositoryManager(getLocalRepoDir(context), new ProgressConsumer() {

            public void consume(String message) {
                context.processMessage(new ProgressMessage(message));
            }
        });
        // further init manager here
        MANAGER_KEY.set(context, manager);
    }
    return manager;
}
Also used : ProgressConsumer(org.jetbrains.idea.maven.aether.ProgressConsumer) ProgressMessage(org.jetbrains.jps.incremental.messages.ProgressMessage) ArtifactRepositoryManager(org.jetbrains.idea.maven.aether.ArtifactRepositoryManager)

Example 2 with ArtifactRepositoryManager

use of org.jetbrains.idea.maven.aether.ArtifactRepositoryManager in project intellij-community by JetBrains.

the class DependencyResolvingBuilder method checkDependencies.

private static void checkDependencies(CompileContext context, ModuleChunk chunk) throws Exception {
    final Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> libs = getRepositoryLibraries(chunk);
    if (!libs.isEmpty()) {
        final ArtifactRepositoryManager repoManager = getRepositoryManager(context);
        for (JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>> lib : libs) {
            final RepositoryLibraryDescriptor descriptor = lib.getProperties().getData();
            final ResourceGuard guard = ResourceGuard.get(context, descriptor);
            if (guard.requestProcessing(context.getCancelStatus())) {
                try {
                    final Collection<File> required = lib.getFiles(JpsOrderRootType.COMPILED);
                    for (Iterator<File> it = required.iterator(); it.hasNext(); ) {
                        if (it.next().exists()) {
                            // leaving only non-existing stuff requiring synchronization
                            it.remove();
                        }
                    }
                    if (!required.isEmpty()) {
                        final Collection<File> resolved = repoManager.resolveDependency(descriptor.getGroupId(), descriptor.getArtifactId(), descriptor.getVersion());
                        if (!resolved.isEmpty()) {
                            syncPaths(required, resolved);
                        } else {
                            LOG.info("No artifacts were resolved for repository dependency " + descriptor.getMavenId());
                        }
                    }
                } finally {
                    guard.finish();
                }
            }
        }
    }
}
Also used : JpsTypedLibrary(org.jetbrains.jps.model.library.JpsTypedLibrary) ArtifactRepositoryManager(org.jetbrains.idea.maven.aether.ArtifactRepositoryManager) RepositoryLibraryDescriptor(org.jetbrains.jps.maven.model.RepositoryLibraryDescriptor) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) File(java.io.File)

Aggregations

ArtifactRepositoryManager (org.jetbrains.idea.maven.aether.ArtifactRepositoryManager)2 File (java.io.File)1 ProgressConsumer (org.jetbrains.idea.maven.aether.ProgressConsumer)1 ProgressMessage (org.jetbrains.jps.incremental.messages.ProgressMessage)1 RepositoryLibraryDescriptor (org.jetbrains.jps.maven.model.RepositoryLibraryDescriptor)1 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)1 JpsTypedLibrary (org.jetbrains.jps.model.library.JpsTypedLibrary)1