Search in sources :

Example 1 with ProjectTestFixtures

use of org.gradle.internal.component.external.model.ProjectTestFixtures in project gradle by gradle.

the class DefaultDependencyHandler method testFixtures.

@Override
public Dependency testFixtures(Object notation) {
    Dependency testFixturesDependency = create(notation);
    if (testFixturesDependency instanceof ProjectDependency) {
        ProjectDependency projectDependency = (ProjectDependency) testFixturesDependency;
        projectDependency.capabilities(new ProjectTestFixtures(projectDependency.getDependencyProject()));
    } else if (testFixturesDependency instanceof ModuleDependency) {
        ModuleDependency moduleDependency = (ModuleDependency) testFixturesDependency;
        moduleDependency.capabilities(capabilities -> capabilities.requireCapability(new ImmutableCapability(moduleDependency.getGroup(), moduleDependency.getName() + TEST_FIXTURES_CAPABILITY_APPENDIX, null)));
    }
    return testFixturesDependency;
}
Also used : ComponentModuleMetadataHandler(org.gradle.api.artifacts.dsl.ComponentModuleMetadataHandler) ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency) ARTIFACT_TYPE_ATTRIBUTE(org.gradle.api.artifacts.type.ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE) ListProperty(org.gradle.api.provider.ListProperty) Closure(groovy.lang.Closure) ExternalModuleDependencyVariantSpec(org.gradle.api.artifacts.dsl.ExternalModuleDependencyVariantSpec) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) ConfigureUtil(org.gradle.util.internal.ConfigureUtil) AttributesSchema(org.gradle.api.attributes.AttributesSchema) Provider(org.gradle.api.provider.Provider) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) Map(java.util.Map) DeprecationLogger(org.gradle.internal.deprecation.DeprecationLogger) Transformer(org.gradle.api.Transformer) ImmutableCapability(org.gradle.internal.component.external.model.ImmutableCapability) TEST_FIXTURES_CAPABILITY_APPENDIX(org.gradle.internal.component.external.model.TestFixturesSupport.TEST_FIXTURES_CAPABILITY_APPENDIX) MethodMixIn(org.gradle.internal.metaobject.MethodMixIn) MinimalExternalModuleDependency(org.gradle.api.artifacts.MinimalExternalModuleDependency) MethodAccess(org.gradle.internal.metaobject.MethodAccess) ProjectTestFixtures(org.gradle.internal.component.external.model.ProjectTestFixtures) ModuleDependencyCapabilitiesHandler(org.gradle.api.artifacts.ModuleDependencyCapabilitiesHandler) Collectors(java.util.stream.Collectors) TransformParameters(org.gradle.api.artifacts.transform.TransformParameters) List(java.util.List) Factory(org.gradle.internal.Factory) TransformAction(org.gradle.api.artifacts.transform.TransformAction) Category(org.gradle.api.attributes.Category) DefaultValueSourceProviderFactory(org.gradle.api.internal.provider.DefaultValueSourceProviderFactory) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) AttributeContainer(org.gradle.api.attributes.AttributeContainer) ArtifactResolutionQuery(org.gradle.api.artifacts.query.ArtifactResolutionQuery) HasConfigurableAttributes(org.gradle.api.attributes.HasConfigurableAttributes) ArtifactResolutionQueryFactory(org.gradle.api.internal.artifacts.query.ArtifactResolutionQueryFactory) Nullable(javax.annotation.Nullable) Action(org.gradle.api.Action) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) VariantTransformRegistry(org.gradle.api.internal.artifacts.VariantTransformRegistry) DependencyConstraintHandler(org.gradle.api.artifacts.dsl.DependencyConstraintHandler) DefaultMinimalDependencyVariant(org.gradle.api.internal.artifacts.dependencies.DefaultMinimalDependencyVariant) Cast(org.gradle.internal.Cast) DependencyBundleValueSource(org.gradle.api.internal.catalog.DependencyBundleValueSource) ComponentMetadataHandler(org.gradle.api.artifacts.dsl.ComponentMetadataHandler) ProviderConvertible(org.gradle.api.provider.ProviderConvertible) ObjectFactory(org.gradle.api.model.ObjectFactory) ValueSource(org.gradle.api.provider.ValueSource) ArtifactTypeContainer(org.gradle.api.artifacts.type.ArtifactTypeContainer) InvalidUserDataException(org.gradle.api.InvalidUserDataException) Dependency(org.gradle.api.artifacts.Dependency) TransformSpec(org.gradle.api.artifacts.transform.TransformSpec) Actions(org.gradle.internal.Actions) ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) MinimalExternalModuleDependency(org.gradle.api.artifacts.MinimalExternalModuleDependency) ExternalModuleDependency(org.gradle.api.artifacts.ExternalModuleDependency) ModuleDependency(org.gradle.api.artifacts.ModuleDependency) MinimalExternalModuleDependency(org.gradle.api.artifacts.MinimalExternalModuleDependency) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) Dependency(org.gradle.api.artifacts.Dependency) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) ImmutableCapability(org.gradle.internal.component.external.model.ImmutableCapability) ProjectTestFixtures(org.gradle.internal.component.external.model.ProjectTestFixtures)

Example 2 with ProjectTestFixtures

use of org.gradle.internal.component.external.model.ProjectTestFixtures in project gradle by gradle.

the class JavaTestFixturesPlugin method createImplicitTestFixturesDependencies.

private void createImplicitTestFixturesDependencies(Project project, JavaPluginExtension extension) {
    DependencyHandler dependencies = project.getDependencies();
    dependencies.add(TEST_FIXTURES_API, dependencies.create(project));
    SourceSet testSourceSet = findTestSourceSet(extension);
    ProjectDependency testDependency = (ProjectDependency) dependencies.add(testSourceSet.getImplementationConfigurationName(), dependencies.create(project));
    testDependency.capabilities(new ProjectTestFixtures(project));
    // Overwrite what the Java plugin defines for test, in order to avoid duplicate classes
    // see gradle/gradle#10872
    ConfigurationContainer configurations = project.getConfigurations();
    testSourceSet.setCompileClasspath(project.getObjects().fileCollection().from(configurations.getByName(TEST_COMPILE_CLASSPATH_CONFIGURATION_NAME)));
    testSourceSet.setRuntimeClasspath(project.getObjects().fileCollection().from(testSourceSet.getOutput(), configurations.getByName(TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME)));
}
Also used : DependencyHandler(org.gradle.api.artifacts.dsl.DependencyHandler) SourceSet(org.gradle.api.tasks.SourceSet) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) ProjectDependency(org.gradle.api.artifacts.ProjectDependency) ProjectTestFixtures(org.gradle.internal.component.external.model.ProjectTestFixtures)

Aggregations

ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)2 ProjectDependency (org.gradle.api.artifacts.ProjectDependency)2 DependencyHandler (org.gradle.api.artifacts.dsl.DependencyHandler)2 Closure (groovy.lang.Closure)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 Action (org.gradle.api.Action)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 Transformer (org.gradle.api.Transformer)1 Configuration (org.gradle.api.artifacts.Configuration)1 Dependency (org.gradle.api.artifacts.Dependency)1 ExternalModuleDependency (org.gradle.api.artifacts.ExternalModuleDependency)1 MinimalExternalModuleDependency (org.gradle.api.artifacts.MinimalExternalModuleDependency)1 ModuleDependency (org.gradle.api.artifacts.ModuleDependency)1 ModuleDependencyCapabilitiesHandler (org.gradle.api.artifacts.ModuleDependencyCapabilitiesHandler)1 ComponentMetadataHandler (org.gradle.api.artifacts.dsl.ComponentMetadataHandler)1 ComponentModuleMetadataHandler (org.gradle.api.artifacts.dsl.ComponentModuleMetadataHandler)1