Search in sources :

Example 1 with JvmTestSuiteTarget

use of org.gradle.api.plugins.jvm.JvmTestSuiteTarget in project gradle by gradle.

the class JacocoPlugin method createCoverageDataVariant.

private void createCoverageDataVariant(Project project, JvmTestSuite suite, JvmTestSuiteTarget target) {
    final Configuration variant = project.getConfigurations().create(COVERAGE_DATA_ELEMENTS_VARIANT_PREFIX + StringUtils.capitalize(target.getName()));
    variant.setDescription("Binary data file containing results of Jacoco test coverage reporting for the " + suite.getName() + " Test Suite's " + target.getName() + " target.");
    variant.setVisible(false);
    variant.setCanBeResolved(false);
    variant.setCanBeConsumed(true);
    variant.extendsFrom(project.getConfigurations().getByName(suite.getSources().getImplementationConfigurationName()), project.getConfigurations().getByName(suite.getSources().getRuntimeOnlyConfigurationName()));
    final ObjectFactory objects = project.getObjects();
    variant.attributes(attributes -> {
        attributes.attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.class, Category.VERIFICATION));
        attributes.attribute(TestSuiteName.TEST_SUITE_NAME_ATTRIBUTE, objects.named(TestSuiteName.class, suite.getName()));
        attributes.attribute(TestSuiteTargetName.TEST_SUITE_TARGET_NAME_ATTRIBUTE, objects.named(TestSuiteTargetName.class, target.getName()));
        attributes.attributeProvider(TestSuiteType.TEST_SUITE_TYPE_ATTRIBUTE, suite.getTestType().map(tt -> objects.named(TestSuiteType.class, tt)));
        attributes.attribute(VerificationType.VERIFICATION_TYPE_ATTRIBUTE, objects.named(VerificationType.class, VerificationType.JACOCO_RESULTS));
    });
    variant.getOutgoing().artifact(target.getTestTask().map(task -> task.getExtensions().getByType(JacocoTaskExtension.class).getDestinationFile()), artifact -> {
        artifact.setType(ArtifactTypeDefinition.BINARY_DATA_TYPE);
        artifact.builtBy(target.getTestTask());
    });
}
Also used : TestSuiteType(org.gradle.api.attributes.TestSuiteType) JacocoCoverageVerification(org.gradle.testing.jacoco.tasks.JacocoCoverageVerification) StringUtils(org.apache.commons.lang.StringUtils) Category(org.gradle.api.attributes.Category) JavaPlugin(org.gradle.api.plugins.JavaPlugin) JvmTestSuite(org.gradle.api.plugins.jvm.JvmTestSuite) Inject(javax.inject.Inject) Configuration(org.gradle.api.artifacts.Configuration) LifecycleBasePlugin(org.gradle.language.base.plugins.LifecycleBasePlugin) Task(org.gradle.api.Task) Provider(org.gradle.api.provider.Provider) TestSuite(org.gradle.testing.base.TestSuite) TaskProvider(org.gradle.api.tasks.TaskProvider) DirectoryProperty(org.gradle.api.file.DirectoryProperty) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ExtensiblePolymorphicDomainObjectContainer(org.gradle.api.ExtensiblePolymorphicDomainObjectContainer) FileOperations(org.gradle.api.internal.file.FileOperations) JacocoReport(org.gradle.testing.jacoco.tasks.JacocoReport) Test(org.gradle.api.tasks.testing.Test) ReportingExtension(org.gradle.api.reporting.ReportingExtension) Project(org.gradle.api.Project) Report(org.gradle.api.reporting.Report) JvmTestSuiteTarget(org.gradle.api.plugins.jvm.JvmTestSuiteTarget) TestSuiteTargetName(org.gradle.api.attributes.TestSuiteTargetName) TestingExtension(org.gradle.testing.base.TestingExtension) SerializableLambdas.action(org.gradle.api.internal.lambdas.SerializableLambdas.action) ReportingBasePlugin(org.gradle.api.plugins.ReportingBasePlugin) File(java.io.File) Instantiator(org.gradle.internal.reflect.Instantiator) VerificationType(org.gradle.api.attributes.VerificationType) ObjectFactory(org.gradle.api.model.ObjectFactory) SingleFileReport(org.gradle.api.reporting.SingleFileReport) ArtifactTypeDefinition(org.gradle.api.artifacts.type.ArtifactTypeDefinition) TestSuiteName(org.gradle.api.attributes.TestSuiteName) JvmTestSuitePlugin(org.gradle.api.plugins.JvmTestSuitePlugin) JacocoBase(org.gradle.testing.jacoco.tasks.JacocoBase) Plugin(org.gradle.api.Plugin) DirectoryReport(org.gradle.api.reporting.DirectoryReport) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) JacocoAgentJar(org.gradle.internal.jacoco.JacocoAgentJar) Category(org.gradle.api.attributes.Category) Configuration(org.gradle.api.artifacts.Configuration) DeprecatableConfiguration(org.gradle.internal.deprecation.DeprecatableConfiguration) ObjectFactory(org.gradle.api.model.ObjectFactory) VerificationType(org.gradle.api.attributes.VerificationType) TestSuiteName(org.gradle.api.attributes.TestSuiteName) TestSuiteTargetName(org.gradle.api.attributes.TestSuiteTargetName)

Aggregations

File (java.io.File)1 Inject (javax.inject.Inject)1 StringUtils (org.apache.commons.lang.StringUtils)1 ExtensiblePolymorphicDomainObjectContainer (org.gradle.api.ExtensiblePolymorphicDomainObjectContainer)1 Plugin (org.gradle.api.Plugin)1 Project (org.gradle.api.Project)1 Task (org.gradle.api.Task)1 Configuration (org.gradle.api.artifacts.Configuration)1 ArtifactTypeDefinition (org.gradle.api.artifacts.type.ArtifactTypeDefinition)1 Category (org.gradle.api.attributes.Category)1 TestSuiteName (org.gradle.api.attributes.TestSuiteName)1 TestSuiteTargetName (org.gradle.api.attributes.TestSuiteTargetName)1 TestSuiteType (org.gradle.api.attributes.TestSuiteType)1 VerificationType (org.gradle.api.attributes.VerificationType)1 DirectoryProperty (org.gradle.api.file.DirectoryProperty)1 FileOperations (org.gradle.api.internal.file.FileOperations)1 SerializableLambdas.action (org.gradle.api.internal.lambdas.SerializableLambdas.action)1 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)1 ObjectFactory (org.gradle.api.model.ObjectFactory)1 JavaPlugin (org.gradle.api.plugins.JavaPlugin)1