private void extractSchema(File schemaOutputDirectory, Artifact artifact, File artifactFile)
     throws IOException {
   if (description.isExtractSchemas() && schemaOutputDirectory != null) {
     String groupId = artifact.getGACE().getGroupId();
     // extract schemas, if any
     if (description.getExtractSchemasGroups().contains(groupId)) {
       logger.debugf("extracting schemas for artifact: '%s'", artifact);
       FileUtils.extractSchemas(artifactFile, schemaOutputDirectory);
     }
   }
 }
  public void build() {
    final ServerProvisioning serverProvisioning = new ServerProvisioning(description);
    final List<String> errors = new ArrayList<>();
    try {
      // create the feature packs
      for (ServerProvisioningDescription.FeaturePack serverProvisioningFeaturePackDescription :
          description.getFeaturePacks()) {
        final FeaturePack featurePack =
            FeaturePackFactory.createPack(
                serverProvisioningFeaturePackDescription.getArtifact(),
                artifactFileResolver,
                versionOverrideArtifactResolver);
        serverProvisioning
            .getFeaturePacks()
            .add(
                new ServerProvisioningFeaturePack(
                    serverProvisioningFeaturePackDescription, featurePack, artifactFileResolver));
      }
      // create output dir
      FileUtils.deleteRecursive(outputDirectory);
      outputDirectory.mkdirs();
      // create schema output dir if needed
      final File schemaOutputDirectory;
      if (description.isExtractSchemas()) {
        schemaOutputDirectory = new File(outputDirectory, SUBSYSTEM_SCHEMA_TARGET_DIRECTORY);
        if (!schemaOutputDirectory.exists()) {
          schemaOutputDirectory.mkdirs();
        }
      } else {
        schemaOutputDirectory = null;
      }
      final Set<String> filesProcessed = new HashSet<>();
      // process server provisioning copy-artifacts
      processCopyArtifacts(
          serverProvisioning.getDescription().getCopyArtifacts(),
          versionOverrideArtifactResolver,
          outputDirectory,
          filesProcessed,
          artifactFileResolver,
          schemaOutputDirectory);
      // process modules (needs to be done for all feature packs before any config is processed, due
      // to subsystem template gathering)
      processModules(
          serverProvisioning,
          outputDirectory,
          filesProcessed,
          artifactFileResolver,
          schemaOutputDirectory);

      // process everything else for each feature pack
      for (ServerProvisioningFeaturePack provisioningFeaturePack :
          serverProvisioning.getFeaturePacks()) {
        processSubsystemConfigInFeaturePack(
            provisioningFeaturePack, serverProvisioning, artifactFileResolver);
        processFeaturePackCopyArtifacts(
            provisioningFeaturePack.getFeaturePack(),
            outputDirectory,
            filesProcessed,
            artifactFileResolver,
            schemaOutputDirectory,
            description.isExcludeDependencies());
        processProvisioningFeaturePackContents(
            provisioningFeaturePack,
            outputDirectory,
            filesProcessed,
            description.isExcludeDependencies());
        processFeaturePackFilePermissions(
            provisioningFeaturePack.getFeaturePack(),
            outputDirectory,
            description.isExcludeDependencies());
      }
      // process the server config
      processConfig(serverProvisioning, outputDirectory, filesProcessed);
    } catch (Throwable e) {
      throw new RuntimeException(e);
    } finally {
      if (!errors.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        sb.append("Some errors were encountered creating the feature pack\n");
        for (String error : errors) {
          sb.append(error);
          sb.append("\n");
        }
        throw new RuntimeException(sb.toString());
      }
    }
  }