Search in sources :

Example 1 with UnknownProjectException

use of org.gradle.api.UnknownProjectException in project atlas by alibaba.

the class DependencyManager method ensureConfigured.

private void ensureConfigured(Configuration config) {
    for (Dependency dependency : config.getAllDependencies()) {
        if (dependency instanceof ProjectDependency) {
            ProjectDependency projectDependency = (ProjectDependency) dependency;
            project.evaluationDependsOn(projectDependency.getDependencyProject().getPath());
            try {
                ensureConfigured(projectDependency.getProjectConfiguration());
            } catch (Throwable e) {
                throw new UnknownProjectException(String.format("Cannot evaluate module %s : %s", projectDependency.getName(), e.getMessage()), e);
            }
        }
    }
}
Also used : ProjectDependency(org.gradle.api.artifacts.ProjectDependency) Dependency(org.gradle.api.artifacts.Dependency) UnknownProjectException(org.gradle.api.UnknownProjectException) ProjectDependency(org.gradle.api.artifacts.ProjectDependency)

Example 2 with UnknownProjectException

use of org.gradle.api.UnknownProjectException in project gradle by gradle.

the class LocalLibraryDependencyResolver method doResolve.

private LibraryResolutionResult doResolve(String selectorProjectPath, String libraryName) {
    try {
        ModelRegistry projectModel = projectModelResolver.resolveProjectModel(selectorProjectPath);
        Collection<VariantComponent> candidates = libraryResolver.resolveCandidates(projectModel, libraryName);
        if (candidates.isEmpty()) {
            return LibraryResolutionResult.emptyResolutionResult(binaryType);
        }
        return LibraryResolutionResult.of(binaryType, candidates, libraryName, binaryPredicate);
    } catch (UnknownProjectException e) {
        return LibraryResolutionResult.projectNotFound(binaryType);
    }
}
Also used : ModelRegistry(org.gradle.model.internal.registry.ModelRegistry) VariantComponent(org.gradle.platform.base.VariantComponent) UnknownProjectException(org.gradle.api.UnknownProjectException)

Example 3 with UnknownProjectException

use of org.gradle.api.UnknownProjectException in project gradle by gradle.

the class DefaultProjectModelResolver method resolveProjectModel.

@Override
public ModelRegistry resolveProjectModel(String path) {
    ProjectInternal projectInternal = delegate.getProject(path);
    if (projectInternal == null) {
        throw new UnknownProjectException("Project with path '" + path + "' not found.");
    }
    // TODO This is a brain-dead way to ensure that the reference project's model is ready to access
    return projectInternal.getOwner().fromMutableState(project -> {
        project.prepareForRuleBasedPlugins();
        project.evaluate();
        project.getTasks().discoverTasks();
        return project.getModelRegistry();
    });
}
Also used : ProjectInternal(org.gradle.api.internal.project.ProjectInternal) UnknownProjectException(org.gradle.api.UnknownProjectException)

Aggregations

UnknownProjectException (org.gradle.api.UnknownProjectException)3 Dependency (org.gradle.api.artifacts.Dependency)1 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 ModelRegistry (org.gradle.model.internal.registry.ModelRegistry)1 VariantComponent (org.gradle.platform.base.VariantComponent)1