Search in sources :

Example 1 with DefaultGradleApiSourcesResolver

use of org.gradle.plugins.ide.internal.resolver.DefaultGradleApiSourcesResolver in project gradle by gradle.

the class EclipseClasspath method resolveDependencies.

/**
 * Calculates, resolves and returns dependency entries of this classpath.
 */
public List<ClasspathEntry> resolveDependencies() {
    ProjectInternal projectInternal = (ProjectInternal) this.project;
    IdeArtifactRegistry ideArtifactRegistry = projectInternal.getServices().get(IdeArtifactRegistry.class);
    boolean inferModulePath = false;
    Task javaCompileTask = project.getTasks().findByName(JavaPlugin.COMPILE_JAVA_TASK_NAME);
    if (javaCompileTask instanceof JavaCompile) {
        JavaCompile javaCompile = (JavaCompile) javaCompileTask;
        inferModulePath = javaCompile.getModularity().getInferModulePath().get();
        if (inferModulePath) {
            List<File> sourceRoots = CompilationSourceDirs.inferSourceRoots((FileTreeInternal) javaCompile.getSource());
            inferModulePath = JavaModuleDetector.isModuleSource(true, sourceRoots);
        }
    }
    ClasspathFactory classpathFactory = new ClasspathFactory(this, ideArtifactRegistry, new DefaultGradleApiSourcesResolver(projectInternal.newDetachedResolver()), inferModulePath);
    return classpathFactory.createEntries();
}
Also used : Task(org.gradle.api.Task) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) IdeArtifactRegistry(org.gradle.plugins.ide.internal.IdeArtifactRegistry) JavaCompile(org.gradle.api.tasks.compile.JavaCompile) File(java.io.File) DefaultGradleApiSourcesResolver(org.gradle.plugins.ide.internal.resolver.DefaultGradleApiSourcesResolver) ClasspathFactory(org.gradle.plugins.ide.eclipse.model.internal.ClasspathFactory)

Example 2 with DefaultGradleApiSourcesResolver

use of org.gradle.plugins.ide.internal.resolver.DefaultGradleApiSourcesResolver in project gradle by gradle.

the class IdeaModule method resolveDependencies.

/**
 * Resolves and returns the module's dependencies.
 *
 * @return dependencies
 */
public Set<Dependency> resolveDependencies() {
    ProjectInternal projectInternal = (ProjectInternal) project;
    IdeArtifactRegistry ideArtifactRegistry = projectInternal.getServices().get(IdeArtifactRegistry.class);
    IdeaDependenciesProvider ideaDependenciesProvider = new IdeaDependenciesProvider(projectInternal, ideArtifactRegistry, new DefaultGradleApiSourcesResolver(projectInternal.newDetachedResolver()));
    return ideaDependenciesProvider.provide(this);
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal) IdeArtifactRegistry(org.gradle.plugins.ide.internal.IdeArtifactRegistry) IdeaDependenciesProvider(org.gradle.plugins.ide.idea.model.internal.IdeaDependenciesProvider) DefaultGradleApiSourcesResolver(org.gradle.plugins.ide.internal.resolver.DefaultGradleApiSourcesResolver)

Aggregations

ProjectInternal (org.gradle.api.internal.project.ProjectInternal)2 IdeArtifactRegistry (org.gradle.plugins.ide.internal.IdeArtifactRegistry)2 DefaultGradleApiSourcesResolver (org.gradle.plugins.ide.internal.resolver.DefaultGradleApiSourcesResolver)2 File (java.io.File)1 Task (org.gradle.api.Task)1 JavaCompile (org.gradle.api.tasks.compile.JavaCompile)1 ClasspathFactory (org.gradle.plugins.ide.eclipse.model.internal.ClasspathFactory)1 IdeaDependenciesProvider (org.gradle.plugins.ide.idea.model.internal.IdeaDependenciesProvider)1