code: private void setupTaskDefaults(Project project, CpdExtension extension) {
          project.getTasks().withType(Cpd.class).configureEach(task -> {
              ConventionMapping taskMapping = task.getConventionMapping();
              taskMapping.map("encoding", extension::getEncoding);
              taskMapping.map("ignoreAnnotations", extension::isIgnoreAnnotations);
              taskMapping.map("ignoreIdentifiers", extension::isIgnoreIdentifiers);
              taskMapping.map("ignoreFailures", extension::isIgnoreFailures);
              taskMapping.map("ignoreLiterals", extension::isIgnoreLiterals);
              taskMapping.map("language", extension::getLanguage);
              taskMapping.map("minimumTokenCount", extension::getMinimumTokenCount);
              taskMapping.map("pmdClasspath", () -> project.getConfigurations().findByName("cpd"));
              taskMapping.map("skipDuplicateFiles", extension::isSkipDuplicateFiles);
              taskMapping.map("skipLexicalErrors", extension::isSkipLexicalErrors);
              taskMapping.map("skipBlocks", extension::isSkipBlocks);
              taskMapping.map("skipBlocksPattern", extension::getSkipBlocksPattern);
  
              ConventionMapping extensionMapping = ((IConventionAware) extension).getConventionMapping();
              extensionMapping.map("reportsDir", () -> project.getExtensions().getByType(ReportingExtension.class).file("cpd"));
  
              task.getReports().all(report -> {
                  ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();
                  reportMapping.map("enabled", () -> "xml".equals(report.getName()));
                  reportMapping.map("destination", () -> new File(extension.getReportsDir(), task.getName() + "." + report.getName()));
              });
          });
      }
docs: Set up task defaults for every created {@link Cpd} task.