public static void main(String[] args) throws Exception {

    //		ProfileParser pp = new ProfileParser();
    //		pp.parseSingleProfile(new
    // File("../hapi-tinder-test/src/test/resources/profile/patient.xml"), "http://foo");

    ValueSetGenerator vsp = new ValueSetGenerator("dstu2");
    //		 vsp.setResourceValueSetFiles(theResourceValueSetFiles);Directory("src/main/resources/vs/");
    vsp.parse();

    DatatypeGeneratorUsingSpreadsheet dtp = new DatatypeGeneratorUsingSpreadsheet("dstu2", ".");
    dtp.parse();
    dtp.markResourcesForImports();
    dtp.bindValueSets(vsp);
    Map<String, String> datatypeLocalImports = dtp.getLocalImports();

    String dtOutputDir = "target/generated-sources/tinder/ca/uhn/fhir/model/dev/composite";

    ResourceGeneratorUsingSpreadsheet rp = new ResourceGeneratorUsingSpreadsheet("dstu2", ".");
    rp.setBaseResourceNames(
        Arrays.asList(
            "bundle"
            //				//, "contract"
            //				"valueset", "organization", "location"
            //				, "observation", "conformance"
            //				//, "referralrequest"
            //				, "patient","practitioner","encounter",
            //				"organization","location","relatedperson","appointment","slot","order"
            //				//,"availability"
            //				,"device", "valueset"
            ));
    rp.parse();
    rp.bindValueSets(vsp);
    rp.markResourcesForImports();

    rp.bindValueSets(vsp);

    String rpOutputDir = "target/generated-sources/tinder/ca/uhn/fhir/model/dev/resource";
    String rpSOutputDir = "target/generated-resources/tinder/ca/uhn/fhir/model/dev";

    dtp.combineContentMaps(rp);
    rp.combineContentMaps(dtp);
    rp.getLocalImports().putAll(datatypeLocalImports);
    datatypeLocalImports.putAll(rp.getLocalImports());

    dtp.writeAll(new File(dtOutputDir), null, "ca.uhn.fhir.model.dev");
    rp.writeAll(new File(rpOutputDir), new File(rpSOutputDir), "ca.uhn.fhir.model.dev");

    String vsOutputDir = "target/generated-sources/tinder/ca/uhn/fhir/model/dev/valueset";
    vsp.writeMarkedValueSets(new File(vsOutputDir), "ca.uhn.fhir.model.dev");
  }
  @Override
  public void execute() throws MojoExecutionException, MojoFailureException {
    if (StringUtils.isBlank(packageName)) {
      throw new MojoFailureException("Package not specified");
    }
    if (packageName.contains("..") || packageName.endsWith(".")) {
      throw new MojoFailureException("Invalid package specified");
    }

    ourLog.info("Beginning HAPI-FHIR Tinder Code Generation...");

    ourLog.info(" * Output Package: " + packageName);

    File resDirectoryBase =
        new File(new File(targetResourceDirectory), packageName.replace('.', File.separatorChar));
    resDirectoryBase.mkdirs();
    ourLog.info(" * Output Resource Directory: " + resDirectoryBase.getAbsolutePath());

    File directoryBase =
        new File(new File(targetDirectory), packageName.replace('.', File.separatorChar));
    directoryBase.mkdirs();
    ourLog.info(" * Output Source Directory: " + directoryBase.getAbsolutePath());

    ValueSetGenerator vsp = new ValueSetGenerator(version);
    vsp.setResourceValueSetFiles(resourceValueSetFiles);
    try {
      vsp.parse();
    } catch (Exception e) {
      throw new MojoFailureException("Failed to load valuesets", e);
    }

    /*
     * A few enums are not found by default because none of the generated classes
     * refer to them, but we still want them.
     */
    vsp.getClassForValueSetIdAndMarkAsNeeded("NarrativeStatus");

    ourLog.info("Loading Datatypes...");

    Map<String, String> datatypeLocalImports = new HashMap<String, String>();
    DatatypeGeneratorUsingSpreadsheet dtp = new DatatypeGeneratorUsingSpreadsheet(version, baseDir);
    if (buildDatatypes) {
      try {
        dtp.parse();
        dtp.markResourcesForImports();
      } catch (Exception e) {
        throw new MojoFailureException("Failed to load datatypes", e);
      }
      dtp.bindValueSets(vsp);

      datatypeLocalImports = dtp.getLocalImports();
    }

    ResourceGeneratorUsingSpreadsheet rp = new ResourceGeneratorUsingSpreadsheet(version, baseDir);
    if (baseResourceNames != null && baseResourceNames.size() > 0) {
      ourLog.info("Loading Resources...");
      try {
        rp.setBaseResourceNames(baseResourceNames);
        rp.parse();
        rp.markResourcesForImports();
      } catch (Exception e) {
        throw new MojoFailureException("Failed to load resources", e);
      }

      rp.bindValueSets(vsp);
      rp.getLocalImports().putAll(datatypeLocalImports);
      datatypeLocalImports.putAll(rp.getLocalImports());

      File resSubDirectoryBase = new File(directoryBase, "resource");
      ourLog.info("Writing Resources to directory: {}", resSubDirectoryBase.getAbsolutePath());

      rp.combineContentMaps(dtp);
      rp.writeAll(resSubDirectoryBase, resDirectoryBase, packageName);
    }

    ProfileParser pp = new ProfileParser(version, baseDir);
    if (resourceProfileFiles != null) {
      ourLog.info("Loading profiles...");
      for (ProfileFileDefinition next : resourceProfileFiles) {
        ourLog.info("Parsing file: {}", next.profileFile);
        pp.parseSingleProfile(new File(next.profileFile), next.profileSourceUrl);
      }

      pp.bindValueSets(vsp);
      pp.markResourcesForImports();
      pp.getLocalImports().putAll(datatypeLocalImports);
      datatypeLocalImports.putAll(pp.getLocalImports());

      pp.combineContentMaps(rp);
      pp.combineContentMaps(dtp);
      pp.writeAll(new File(directoryBase, "resource"), resDirectoryBase, packageName);
    }

    if (dtp != null) {
      ourLog.info("Writing Composite Datatypes...");

      dtp.combineContentMaps(pp);
      dtp.combineContentMaps(rp);
      dtp.writeAll(new File(directoryBase, "composite"), resDirectoryBase, packageName);
    }

    ourLog.info("Writing ValueSet Enums...");
    vsp.writeMarkedValueSets(new File(directoryBase, "valueset"), packageName);

    myProject.addCompileSourceRoot(targetDirectory);
  }