Search in sources :

Example 1 with BuildIdentifier

use of org.gradle.api.artifacts.component.BuildIdentifier in project gradle by gradle.

the class DefaultIncludedBuildExecuter method checkNoCycles.

private void checkNoCycles(BuildRequest buildRequest, BuildIdentifier target, List<BuildIdentifier> candidateCycle) {
    candidateCycle.add(target);
    for (BuildRequest executingBuild : executingBuilds) {
        if (executingBuild.requestingBuild.equals(target)) {
            BuildIdentifier nextTarget = executingBuild.targetBuild;
            if (nextTarget.equals(buildRequest.requestingBuild)) {
                candidateCycle.add(nextTarget);
                ProjectComponentSelector selector = DefaultProjectComponentSelector.newSelector(buildRequest.targetBuild, ":");
                throw new ModuleVersionResolveException(selector, "Included build dependency cycle: " + reportCycle(candidateCycle));
            }
            checkNoCycles(buildRequest, nextTarget, candidateCycle);
        }
    }
    candidateCycle.remove(target);
}
Also used : ProjectComponentSelector(org.gradle.api.artifacts.component.ProjectComponentSelector) DefaultProjectComponentSelector(org.gradle.internal.component.local.model.DefaultProjectComponentSelector) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) ModuleVersionResolveException(org.gradle.internal.resolve.ModuleVersionResolveException)

Example 2 with BuildIdentifier

use of org.gradle.api.artifacts.component.BuildIdentifier in project gradle by gradle.

the class ComponentIdentifierSerializer method write.

public void write(Encoder encoder, ComponentIdentifier value) throws IOException {
    if (value == null) {
        throw new IllegalArgumentException("Provided component identifier may not be null");
    }
    Implementation implementation = resolveImplementation(value);
    encoder.writeByte(implementation.getId());
    if (implementation == Implementation.MODULE) {
        ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier) value;
        encoder.writeString(moduleComponentIdentifier.getGroup());
        encoder.writeString(moduleComponentIdentifier.getModule());
        encoder.writeString(moduleComponentIdentifier.getVersion());
    } else if (implementation == Implementation.BUILD) {
        ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier) value;
        BuildIdentifier build = projectComponentIdentifier.getBuild();
        buildIdentifierSerializer.write(encoder, build);
        encoder.writeString(projectComponentIdentifier.getProjectPath());
    } else if (implementation == Implementation.LIBRARY) {
        LibraryBinaryIdentifier libraryIdentifier = (LibraryBinaryIdentifier) value;
        encoder.writeString(libraryIdentifier.getProjectPath());
        encoder.writeString(libraryIdentifier.getLibraryName());
        encoder.writeString(libraryIdentifier.getVariant());
    } else {
        throw new IllegalStateException("Unsupported implementation type: " + implementation);
    }
}
Also used : ModuleComponentIdentifier(org.gradle.api.artifacts.component.ModuleComponentIdentifier) DefaultModuleComponentIdentifier(org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) LibraryBinaryIdentifier(org.gradle.api.artifacts.component.LibraryBinaryIdentifier) DefaultLibraryBinaryIdentifier(org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier) ProjectComponentIdentifier(org.gradle.api.artifacts.component.ProjectComponentIdentifier) DefaultProjectComponentIdentifier(org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)

Example 3 with BuildIdentifier

use of org.gradle.api.artifacts.component.BuildIdentifier in project gradle by gradle.

the class CompositeBuildTaskDelegate method executeTasksInOtherBuild.

@TaskAction
public void executeTasksInOtherBuild() {
    IncludedBuilds includedBuilds = getServices().get(IncludedBuilds.class);
    IncludedBuildExecuter builder = getServices().get(IncludedBuildExecuter.class);
    IncludedBuild includedBuild = includedBuilds.getBuild(build);
    BuildIdentifier buildId = new DefaultBuildIdentifier(includedBuild.getName());
    // sourceBuild is currently always root build in a composite
    builder.execute(new DefaultBuildIdentifier(":", true), buildId, tasks);
}
Also used : DefaultBuildIdentifier(org.gradle.api.internal.artifacts.component.DefaultBuildIdentifier) BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier) DefaultBuildIdentifier(org.gradle.api.internal.artifacts.component.DefaultBuildIdentifier) IncludedBuildExecuter(org.gradle.initialization.IncludedBuildExecuter) IncludedBuilds(org.gradle.initialization.IncludedBuilds) IncludedBuild(org.gradle.api.initialization.IncludedBuild) TaskAction(org.gradle.api.tasks.TaskAction)

Example 4 with BuildIdentifier

use of org.gradle.api.artifacts.component.BuildIdentifier in project gradle by gradle.

the class DefaultIncludedBuildExecuter method reportCycle.

private String reportCycle(List<BuildIdentifier> cycle) {
    StringBuilder cycleReport = new StringBuilder();
    for (BuildIdentifier buildIdentifier : cycle) {
        cycleReport.append(buildIdentifier);
        cycleReport.append(" -> ");
    }
    cycleReport.append(cycle.get(0));
    return cycleReport.toString();
}
Also used : BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier)

Example 5 with BuildIdentifier

use of org.gradle.api.artifacts.component.BuildIdentifier in project gradle by gradle.

the class IncludedBuildArtifactBuilder method willBuild.

public void willBuild(ComponentArtifactMetadata artifact) {
    if (artifact instanceof CompositeProjectComponentArtifactMetadata) {
        CompositeProjectComponentArtifactMetadata compositeBuildArtifact = (CompositeProjectComponentArtifactMetadata) artifact;
        BuildIdentifier buildId = getBuildIdentifier(compositeBuildArtifact);
        addTasksForBuild(buildId, compositeBuildArtifact);
    }
}
Also used : BuildIdentifier(org.gradle.api.artifacts.component.BuildIdentifier)

Aggregations

BuildIdentifier (org.gradle.api.artifacts.component.BuildIdentifier)6 LibraryBinaryIdentifier (org.gradle.api.artifacts.component.LibraryBinaryIdentifier)1 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)1 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 ProjectComponentSelector (org.gradle.api.artifacts.component.ProjectComponentSelector)1 IncludedBuild (org.gradle.api.initialization.IncludedBuild)1 DefaultBuildIdentifier (org.gradle.api.internal.artifacts.component.DefaultBuildIdentifier)1 TaskAction (org.gradle.api.tasks.TaskAction)1 IncludedBuildExecuter (org.gradle.initialization.IncludedBuildExecuter)1 IncludedBuilds (org.gradle.initialization.IncludedBuilds)1 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)1 DefaultLibraryBinaryIdentifier (org.gradle.internal.component.local.model.DefaultLibraryBinaryIdentifier)1 DefaultProjectComponentIdentifier (org.gradle.internal.component.local.model.DefaultProjectComponentIdentifier)1 DefaultProjectComponentSelector (org.gradle.internal.component.local.model.DefaultProjectComponentSelector)1 ModuleVersionResolveException (org.gradle.internal.resolve.ModuleVersionResolveException)1