private void writeDescriptorFile(TestDescriptor descriptor) throws MojoExecutionException {
        try {
            Path descriptorFile = testClassesDirectory().resolve(TestDescriptor.DEFAULT_FILENAME);
            Files.createDirectories(descriptorFile.getParent());
            Files.write(descriptorFile, descriptor.toJson().getBytes(UTF_8));
        } catch (IOException e) {
            throw new MojoExecutionException("Failed to write test descriptor file: " + e.getMessage(), e);
        }
    }
Generates a test descriptor file based on content of the compiled test classes

@author bjorncs
vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/GenerateTestDescriptorMojo.java