public Result generateCode() throws JsonIOException, IOException {

    if (moduleManager == null) {
      loadModulesFromKmdFiles();
    }

    if (internalTemplates != null) {
      templatesDir = getInternalTemplatesDir(internalTemplates);
    }

    if (templatesDir != null) {
      Path configFile = templatesDir.resolve(CONFIG_FILE_NAME);
      if (Files.exists(configFile)) {
        JsonObject internalConfig = loadConfigFile(configFile);
        overrideConfig(internalConfig, config);
        config = internalConfig;
      }
    }

    try {

      if (deleteGenDir) {
        PathUtils.delete(codegenDir, loadNoDeleteFiles(config));
      }

      if (codegenDir != null && !Files.exists(codegenDir)) {
        Files.createDirectories(codegenDir);
      }

      CodeGen codeGen = new CodeGen(templatesDir, codegenDir, verbose, listGeneratedFiles,
          overwrite, config);

      for (ModuleDefinition module : moduleManager.getModules()) {
        if (config.has("expandMethodsWithOpsParams")
            && config.get("expandMethodsWithOpsParams").getAsBoolean()) {
          module.expandMethodsWithOpsParams();
        }

        if (templatesDir != null && codegenDir != null) {
          codeGen.generateCode(module);
        }

        if (outputModuleFile != null) {
          JsonModuleSaverLoader.getInstance().writeToFile(module,
              new File(outputModuleFile.toFile(), module.getName() + ".kmd.json"));
        }

        if (generateMavenPom) {
          codeGen.setTemplatesDir(getInternalTemplatesDir("maven"));
          codeGen.generateMavenPom(module, searchFiles(this.kmdFilesToGen, "pom.xml"));
        }

        if (generateNpmPackage) {
          codeGen.setTemplatesDir(getInternalTemplatesDir("npm"));
          codeGen.generateNpmPackage(module, searchFiles(this.kmdFilesToGen, "package.json"),
              searchFiles(this.kmdFilesToGen, "bower.json"));
        }
      }

      return new Result();

    } catch (KurentoModuleCreatorException e) {
      return new Result(new Error("Error: " + e.getMessage()));
    } catch (Exception e) {
      e.printStackTrace();
      return new Result(
          new Error("Unexpected error: " + e.getClass().getName() + " " + e.getMessage()));
    }
  }
public Result generateCode ( ) throws JsonIOException , IOException { if ( moduleManager == null ) { loadModulesFromKmdFiles ( ) ; } if ( internalTemplates != null ) { templatesDir = getInternalTemplatesDir ( internalTemplates ) ; } if ( templatesDir != null ) { Path configFile = templatesDir . resolve ( CONFIG_FILE_NAME ) ; if ( Files . exists ( configFile ) ) { JsonObject internalConfig = loadConfigFile ( configFile ) ; overrideConfig ( internalConfig , config ) ; config = internalConfig ; } } try { if ( deleteGenDir ) { PathUtils . delete ( codegenDir , loadNoDeleteFiles ( config ) ) ; } if ( codegenDir != null && ! Files . exists ( codegenDir ) ) { Files . createDirectories ( codegenDir ) ; } CodeGen codeGen = new CodeGen ( templatesDir , codegenDir , verbose , listGeneratedFiles , overwrite , config ) ; for ( ModuleDefinition module : moduleManager . getModules ( ) ) { if ( config . has ( "expandMethodsWithOpsParams" ) && config . get ( "expandMethodsWithOpsParams" ) . getAsBoolean ( ) ) { module . expandMethodsWithOpsParams ( ) ; } if ( templatesDir != null && codegenDir != null ) { codeGen . generateCode ( module ) ; } if ( outputModuleFile != null ) { JsonModuleSaverLoader . getInstance ( ) . writeToFile ( module , new File ( outputModuleFile . toFile ( ) , module . getName ( ) + ".kmd.json" ) ) ; } if ( generateMavenPom ) { codeGen . setTemplatesDir ( getInternalTemplatesDir ( "maven" ) ) ; codeGen . generateMavenPom ( module , searchFiles ( this . kmdFilesToGen , "pom.xml" ) ) ; } if ( generateNpmPackage ) { codeGen . setTemplatesDir ( getInternalTemplatesDir ( "npm" ) ) ; codeGen . generateNpmPackage ( module , searchFiles ( this . kmdFilesToGen , "package.json" ) , searchFiles ( this . kmdFilesToGen , "bower.json" ) ) ; } } return new Result ( ) ; } catch ( KurentoModuleCreatorException e ) { return new Result ( new Error ( "Error: " + e . getMessage ( ) ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return new Result ( new Error ( "Unexpected error: " + e . getClass ( ) . getName ( ) + " " + e . getMessage ( ) ) ) ; } }
Genarates the code.

@return The result of the code generation
@throws JsonIOException
if there is an error parsing kmd's
@throws IOException
if there is an error reading kmd's