private AProject makeProject() throws ProjectException {
   AProject project = new AProject(new MockFolder(PROJECT_NAME));
   AProjectFolder folder1 = project.addFolder(FOLDER1);
   folder1.addResource(FILE1_1, new ByteArrayInputStream(new byte[10]));
   folder1.addResource(FILE1_2, new ByteArrayInputStream(new byte[20]));
   project.addFolder(FOLDER2);
   return project;
 }
  private synchronized void initDependencyLoaders() {
    if (projectDescriptors == null && dependencyLoaders == null) {
      dependencyLoaders = new ArrayList<IDependencyLoader>();
      projectDescriptors = new ArrayList<ProjectDescriptor>();
      dependencyNames = new HashSet<String>();
      Collection<Deployment> deployments = ruleServiceLoader.getDeployments();
      for (Deployment deployment : deployments) {
        String deploymentName = deployment.getDeploymentName();
        CommonVersion deploymentVersion = deployment.getCommonVersion();
        if (deploymentDescription.getName().equals(deploymentName)
            && deploymentDescription.getVersion().equals(deploymentVersion)) {
          for (AProject project : deployment.getProjects()) {
            String projectName = project.getName();
            try {
              Collection<Module> modulesOfProject =
                  ruleServiceLoader.resolveModulesForProject(
                      deploymentName, deploymentVersion, projectName);
              ProjectDescriptor projectDescriptor = null;
              Set<String> wildcardPatterns = new HashSet<String>();
              if (!modulesOfProject.isEmpty()) {
                Module firstModule = modulesOfProject.iterator().next();
                projectDescriptor = firstModule.getProject();

                InputStream content = null;
                RulesDeploy rulesDeploy = null;
                try {
                  AProjectArtefact artifact =
                      project.getArtefact(LastVersionProjectsServiceConfigurer.RULES_DEPLOY_XML);
                  if (artifact instanceof AProjectResource) {
                    AProjectResource resource = (AProjectResource) artifact;
                    content = resource.getContent();
                    rulesDeploy = getRulesDeploySerializer().deserialize(content);
                    RulesDeploy.WildcardPattern[] compilationPatterns =
                        rulesDeploy.getLazyModulesForCompilationPatterns();
                    if (compilationPatterns != null) {
                      for (RulesDeploy.WildcardPattern wp : compilationPatterns) {
                        wildcardPatterns.add(wp.getValue());
                      }
                    }
                  }
                } catch (ProjectException e) {
                } finally {
                  if (content != null) {
                    try {
                      content.close();
                    } catch (IOException e) {
                      log.error(e.getMessage(), e);
                    }
                  }
                }

                for (Module m : modulesOfProject) {
                  IDependencyLoader moduleLoader;
                  String moduleName = m.getName();
                  List<Module> module = Arrays.asList(m);
                  if (isLazy()) {
                    boolean compileAfterLazyCompilation =
                        compilationAfterLazyCompilationRequred(wildcardPatterns, moduleName);
                    moduleLoader =
                        new LazyRuleServiceDependencyLoader(
                            deploymentDescription, moduleName, module, compileAfterLazyCompilation);
                  } else {
                    moduleLoader = new RuleServiceDependencyLoader(moduleName, module);
                  }
                  dependencyLoaders.add(moduleLoader);
                  dependencyNames.add(moduleName);
                }
              }
              if (projectDescriptor != null) {
                IDependencyLoader projectLoader;
                if (isLazy()) {
                  projectLoader =
                      new LazyRuleServiceDependencyLoader(
                          deploymentDescription,
                          ProjectExternalDependenciesHelper.buildDependencyNameForProjectName(
                              projectDescriptor.getName()),
                          projectDescriptor.getModules(),
                          false);
                } else {
                  projectLoader =
                      new RuleServiceDependencyLoader(
                          ProjectExternalDependenciesHelper.buildDependencyNameForProjectName(
                              projectDescriptor.getName()),
                          projectDescriptor.getModules());
                }
                projectDescriptors.add(projectDescriptor);
                dependencyLoaders.add(projectLoader);
              }
            } catch (Exception e) {
              log.error(
                  "Build dependency manager loaders for project \"{}\" from deployment \"{}\" was failed!",
                  projectName,
                  deploymentName,
                  e);
            }
          }
        }
      }
    }
  }