use of org.gradle.internal.build.IncludedBuildState in project gradle by gradle.
the class DefaultIncludedBuildRegistry method registerBuild.
private IncludedBuildState registerBuild(BuildDefinition buildDefinition, boolean isImplicit) {
// TODO: synchronization
File buildDir = buildDefinition.getBuildRootDir();
if (buildDir == null) {
throw new IllegalArgumentException("Included build must have a root directory defined");
}
IncludedBuildState includedBuild = includedBuildsByRootDir.get(buildDir);
if (includedBuild == null) {
if (rootBuild == null) {
throw new IllegalStateException("No root build attached yet.");
}
String buildName = buildDefinition.getName();
if (buildName == null) {
throw new IllegalStateException("build name is required");
}
validateNameIsNotBuildSrc(buildName, buildDir);
Path idPath = assignPath(rootBuild, buildDefinition.getName(), buildDir);
BuildIdentifier buildIdentifier = idFor(buildName);
includedBuild = includedBuildFactory.createBuild(buildIdentifier, idPath, buildDefinition, isImplicit, rootBuild);
includedBuildsByRootDir.put(buildDir, includedBuild);
pendingIncludedBuilds.add(includedBuild);
addBuild(includedBuild);
} else {
if (includedBuild.isImplicitBuild() != isImplicit) {
throw new IllegalStateException("Unexpected state for build.");
}
// TODO: verify that the build definition is the same
}
return includedBuild;
}
use of org.gradle.internal.build.IncludedBuildState in project gradle by gradle.
the class DefaultBuildIncluder method includeBuild.
@Override
public IncludedBuildState includeBuild(IncludedBuildSpec includedBuildSpec) {
BuildDefinition buildDefinition = toBuildDefinition(includedBuildSpec, gradle);
IncludedBuildState build = buildRegistry.addIncludedBuild(buildDefinition);
coordinator.prepareForInclusion(build, buildDefinition.isPluginBuild());
return build;
}
use of org.gradle.internal.build.IncludedBuildState in project gradle by gradle.
the class VcsDependencyResolver method resolve.
@Override
public void resolve(DependencyMetadata dependency, VersionSelector acceptor, VersionSelector rejector, BuildableComponentIdResolveResult result) {
if (dependency.getSelector() instanceof ModuleComponentSelector) {
final ModuleComponentSelector depSelector = (ModuleComponentSelector) dependency.getSelector();
VersionControlSpec spec = vcsResolver.locateVcsFor(depSelector);
// TODO: Need failure handling, e.g., cannot clone repository
if (spec != null) {
VersionControlRepositoryConnection repository = versionControlSystemFactory.create(spec);
File dependencyWorkingDir;
try {
dependencyWorkingDir = workingDirResolver.selectVersion(depSelector, repository);
} catch (ModuleVersionResolveException e) {
result.failed(e);
return;
}
if (dependencyWorkingDir == null) {
result.failed(new ModuleVersionNotFoundException(depSelector, Collections.singleton(spec.getDisplayName())));
return;
}
File buildRootDir = new File(dependencyWorkingDir, spec.getRootDir());
BuildDefinition buildDefinition = toBuildDefinition((AbstractVersionControlSpec) spec, buildRootDir);
IncludedBuildState includedBuild = buildRegistry.addImplicitIncludedBuild(buildDefinition);
Collection<Pair<ModuleVersionIdentifier, ProjectComponentIdentifier>> moduleToProject = includedBuild.getAvailableModules();
Pair<ModuleVersionIdentifier, ProjectComponentIdentifier> entry = CollectionUtils.findFirst(moduleToProject, new Spec<Pair<ModuleVersionIdentifier, ProjectComponentIdentifier>>() {
@Override
public boolean isSatisfiedBy(Pair<ModuleVersionIdentifier, ProjectComponentIdentifier> entry) {
ModuleVersionIdentifier possibleMatch = entry.left;
return depSelector.getGroup().equals(possibleMatch.getGroup()) && depSelector.getModule().equals(possibleMatch.getName());
}
});
if (entry == null) {
result.failed(new ModuleVersionResolveException(depSelector, () -> spec.getDisplayName() + " did not contain a project publishing the specified dependency."));
} else {
LocalComponentMetadata componentMetaData = localComponentRegistry.getComponent(entry.right);
result.resolved(componentMetaData);
}
}
}
}
use of org.gradle.internal.build.IncludedBuildState in project gradle by gradle.
the class GradleBuildBuilder method addIncludedBuilds.
private void addIncludedBuilds(GradleInternal gradle, DefaultGradleBuild model, Map<BuildState, DefaultGradleBuild> all) {
for (IncludedBuildInternal reference : gradle.includedBuilds()) {
BuildState target = reference.getTarget();
if (target instanceof IncludedBuildState) {
IncludedBuildState includedBuildState = (IncludedBuildState) target;
DefaultGradleBuild convertedIncludedBuild = convert(includedBuildState, all);
model.addIncludedBuild(convertedIncludedBuild);
} else if (target instanceof RootBuildState) {
DefaultGradleBuild rootBuild = convert(target, all);
model.addIncludedBuild(rootBuild);
} else {
throw new IllegalStateException("Unknown build type: " + reference.getClass().getName());
}
}
}
use of org.gradle.internal.build.IncludedBuildState in project gradle by gradle.
the class IdeaModelBuilder method applyIdeaPlugin.
private void applyIdeaPlugin(ProjectInternal root, List<GradleInternal> alreadyProcessed) {
Set<Project> allProjects = root.getAllprojects();
for (Project p : allProjects) {
p.getPluginManager().apply(IdeaPlugin.class);
}
for (IncludedBuildInternal reference : root.getGradle().includedBuilds()) {
BuildState target = reference.getTarget();
if (target instanceof IncludedBuildState) {
target.ensureProjectsConfigured();
GradleInternal build = target.getMutableModel();
if (!alreadyProcessed.contains(build)) {
alreadyProcessed.add(build);
applyIdeaPlugin(build.getRootProject(), alreadyProcessed);
}
}
}
}
Aggregations