code: protected ModuleSpec createModuleSpec(ScriptArchive archive,
              ModuleIdentifier moduleId,
              Map<ModuleId, ModuleIdentifier> moduleIdMap,
              Path moduleCompilationRoot) throws ModuleLoadException {
          ScriptModuleSpec archiveSpec = archive.getModuleSpec();
          // create the jboss module pre-cursor artifact
          ModuleSpec.Builder moduleSpecBuilder = ModuleSpec.build(moduleId);
  
          JBossModuleUtils.populateModuleSpecWithResources(moduleSpecBuilder, archive);
          JBossModuleUtils.populateModuleSpecWithCoreDependencies(moduleSpecBuilder, archive);
          JBossModuleUtils.populateModuleSpecWithAppImports(moduleSpecBuilder,
                  appClassLoader, archiveSpec.getAppImportFilterPaths() == null ? appPackagePaths : archiveSpec.getAppImportFilterPaths());
          // Allow compiled class files to fetched as resources later on.
          JBossModuleUtils.populateModuleSpecWithCompilationRoot(moduleSpecBuilder, moduleCompilationRoot);
  
          // Populate the modulespec with the scriptArchive dependencies
          for (ModuleId dependencyModuleId : archiveSpec.getModuleDependencies()) {
              ScriptModule dependencyModule = getScriptModule(dependencyModuleId);
              Set<String> exportPaths = dependencyModule.getSourceArchive().getModuleSpec().getModuleExportFilterPaths();
  
              JBossModuleUtils.populateModuleSpecWithModuleDependency(moduleSpecBuilder,
                  archiveSpec.getModuleImportFilterPaths(), exportPaths, moduleIdMap.get(dependencyModuleId));
          }
  
          return moduleSpecBuilder.create();
      }
docs: Create a JBoss module spec for an about to be created script module.
  @param archive the script archive being converted to a module.
  @param moduleId the JBoss module identifier.
  @param moduleIdMap a map of loaded script module IDs to jboss module identifiers
  @param moduleCompilationRoot a path to a directory that will hold compiled classes for this module.
  @throws ModuleLoadException