Search in sources :

Example 1 with JpsTypedLibrary

use of org.jetbrains.jps.model.library.JpsTypedLibrary in project intellij-community by JetBrains.

the class DependencyResolvingBuilder method getRepositoryLibraries.

@NotNull
private static Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> getRepositoryLibraries(ModuleChunk chunk) {
    final Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> result = new SmartHashSet<>();
    for (JpsModule module : chunk.getModules()) {
        for (JpsDependencyElement dep : module.getDependenciesList().getDependencies()) {
            if (dep instanceof JpsLibraryDependency) {
                final JpsLibrary _lib = ((JpsLibraryDependency) dep).getLibrary();
                final JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>> lib = _lib != null ? _lib.asTyped(JpsMavenRepositoryLibraryType.INSTANCE) : null;
                if (lib != null) {
                    result.add(lib);
                }
            }
        }
    }
    return result;
}
Also used : JpsLibraryDependency(org.jetbrains.jps.model.module.JpsLibraryDependency) SmartHashSet(com.intellij.util.containers.SmartHashSet) JpsModule(org.jetbrains.jps.model.module.JpsModule) JpsTypedLibrary(org.jetbrains.jps.model.library.JpsTypedLibrary) JpsDependencyElement(org.jetbrains.jps.model.module.JpsDependencyElement) RepositoryLibraryDescriptor(org.jetbrains.jps.maven.model.RepositoryLibraryDescriptor) JpsSimpleElement(org.jetbrains.jps.model.JpsSimpleElement) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JpsTypedLibrary

use of org.jetbrains.jps.model.library.JpsTypedLibrary 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

RepositoryLibraryDescriptor (org.jetbrains.jps.maven.model.RepositoryLibraryDescriptor)2 JpsSimpleElement (org.jetbrains.jps.model.JpsSimpleElement)2 JpsTypedLibrary (org.jetbrains.jps.model.library.JpsTypedLibrary)2 SmartHashSet (com.intellij.util.containers.SmartHashSet)1 File (java.io.File)1 NotNull (org.jetbrains.annotations.NotNull)1 ArtifactRepositoryManager (org.jetbrains.idea.maven.aether.ArtifactRepositoryManager)1 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)1 JpsDependencyElement (org.jetbrains.jps.model.module.JpsDependencyElement)1 JpsLibraryDependency (org.jetbrains.jps.model.module.JpsLibraryDependency)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1