Search in sources :

Example 1 with JvmTestSuiteBinarySpecInternal

use of org.gradle.jvm.test.internal.JvmTestSuiteBinarySpecInternal in project gradle by gradle.

the class JvmTestSuiteBasePlugin method createJvmTestSuiteTasks.

@BinaryTasks
void createJvmTestSuiteTasks(ModelMap<Task> tasks, final JvmTestSuiteBinarySpecInternal binary, @Path("buildDir") final File buildDir) {
    final JvmAssembly jvmAssembly = ((WithJvmAssembly) binary).getAssembly();
    tasks.create(testTaskNameFor(binary), Test.class, new Action<Test>() {

        @Override
        public void execute(final Test test) {
            test.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
            test.setDescription(String.format("Runs %s.", WordUtils.uncapitalize(binary.getDisplayName())));
            test.dependsOn(jvmAssembly);
            test.setTestClassesDir(binary.getClassesDir());
            test.setClasspath(binary.getRuntimeClasspath());
            configureReports((JvmTestSuiteBinarySpecInternal) binary, test);
        }

        private void configureReports(JvmTestSuiteBinarySpecInternal binary, Test test) {
            // todo: improve configuration of reports
            TestTaskReports reports = test.getReports();
            File reportsDirectory = new File(buildDir, "reports");
            File reportsOutputDirectory = binary.getNamingScheme().getOutputDirectory(reportsDirectory);
            File htmlDir = new File(reportsOutputDirectory, "tests");
            File xmlDir = new File(buildDir, "test-results");
            File xmlDirOutputDirectory = binary.getNamingScheme().getOutputDirectory(xmlDir);
            File binDir = new File(xmlDirOutputDirectory, "binary");
            reports.getHtml().setDestination(htmlDir);
            reports.getJunitXml().setDestination(xmlDirOutputDirectory);
            test.setBinResultsDir(binDir);
        }
    });
}
Also used : TestTaskReports(org.gradle.api.tasks.testing.TestTaskReports) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) Test(org.gradle.api.tasks.testing.Test) WithJvmAssembly(org.gradle.jvm.internal.WithJvmAssembly) JvmAssembly(org.gradle.jvm.internal.JvmAssembly) JvmTestSuiteBinarySpecInternal(org.gradle.jvm.test.internal.JvmTestSuiteBinarySpecInternal) File(java.io.File) BinaryTasks(org.gradle.platform.base.BinaryTasks)

Example 2 with JvmTestSuiteBinarySpecInternal

use of org.gradle.jvm.test.internal.JvmTestSuiteBinarySpecInternal in project gradle by gradle.

the class JvmTestSuiteBasePlugin method configureRuntimeClasspath.

@Finalize
public void configureRuntimeClasspath(@Each JvmTestSuiteBinarySpecInternal testBinary, ServiceRegistry serviceRegistry, ModelSchemaStore modelSchemaStore) {
    ArtifactDependencyResolver dependencyResolver = serviceRegistry.get(ArtifactDependencyResolver.class);
    RepositoryHandler repositories = serviceRegistry.get(RepositoryHandler.class);
    List<ResolutionAwareRepository> resolutionAwareRepositories = CollectionUtils.collect(repositories, Transformers.cast(ResolutionAwareRepository.class));
    ModelSchema<? extends JvmTestSuiteBinarySpec> schema = Cast.uncheckedCast(modelSchemaStore.getSchema(((BinarySpecInternal) testBinary).getPublicType()));
    AttributesSchema attributesSchema = serviceRegistry.get(AttributesSchema.class);
    ImmutableModuleIdentifierFactory moduleIdentifierFactory = serviceRegistry.get(ImmutableModuleIdentifierFactory.class);
    ModuleExclusions moduleExclusions = serviceRegistry.get(ModuleExclusions.class);
    BuildOperationProcessor buildOperationProcessor = serviceRegistry.get(BuildOperationProcessor.class);
    testBinary.setRuntimeClasspath(configureRuntimeClasspath(testBinary, dependencyResolver, resolutionAwareRepositories, schema, attributesSchema, moduleIdentifierFactory, moduleExclusions, buildOperationProcessor));
}
Also used : ArtifactDependencyResolver(org.gradle.api.internal.artifacts.ArtifactDependencyResolver) ImmutableModuleIdentifierFactory(org.gradle.api.internal.artifacts.ImmutableModuleIdentifierFactory) ModuleExclusions(org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusions) BinarySpecInternal(org.gradle.platform.base.internal.BinarySpecInternal) JvmBinarySpecInternal(org.gradle.jvm.internal.JvmBinarySpecInternal) JvmTestSuiteBinarySpecInternal(org.gradle.jvm.test.internal.JvmTestSuiteBinarySpecInternal) ResolutionAwareRepository(org.gradle.api.internal.artifacts.repositories.ResolutionAwareRepository) BuildOperationProcessor(org.gradle.internal.operations.BuildOperationProcessor) RepositoryHandler(org.gradle.api.artifacts.dsl.RepositoryHandler) AttributesSchema(org.gradle.api.attributes.AttributesSchema)

Aggregations

JvmTestSuiteBinarySpecInternal (org.gradle.jvm.test.internal.JvmTestSuiteBinarySpecInternal)2 File (java.io.File)1 RepositoryHandler (org.gradle.api.artifacts.dsl.RepositoryHandler)1 AttributesSchema (org.gradle.api.attributes.AttributesSchema)1 ArtifactDependencyResolver (org.gradle.api.internal.artifacts.ArtifactDependencyResolver)1 ImmutableModuleIdentifierFactory (org.gradle.api.internal.artifacts.ImmutableModuleIdentifierFactory)1 ModuleExclusions (org.gradle.api.internal.artifacts.ivyservice.resolveengine.excludes.ModuleExclusions)1 ResolutionAwareRepository (org.gradle.api.internal.artifacts.repositories.ResolutionAwareRepository)1 Test (org.gradle.api.tasks.testing.Test)1 TestTaskReports (org.gradle.api.tasks.testing.TestTaskReports)1 BuildOperationProcessor (org.gradle.internal.operations.BuildOperationProcessor)1 JvmAssembly (org.gradle.jvm.internal.JvmAssembly)1 JvmBinarySpecInternal (org.gradle.jvm.internal.JvmBinarySpecInternal)1 WithJvmAssembly (org.gradle.jvm.internal.WithJvmAssembly)1 BinaryTasks (org.gradle.platform.base.BinaryTasks)1 BinarySpecInternal (org.gradle.platform.base.internal.BinarySpecInternal)1