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);
}
});
}
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));
}
Aggregations