Exemplo n.º 1
0
        private void ValidateExternalModules()
        {
            foreach (ExternalModule externalModule in _externalModules.Items)
            {
                if (!_repository.IsItUsed(externalModule))
                {
                    ValidationError error = new ValidationError(
                        externalModule,
                        "The external module is not used",
                        externalModule.ToString(), ErrorLevel.Info);

                    ExternalModule module = externalModule;
                    DelegatedFix   fix    = new DelegatedFix
                    {
                        ShouldBeConfirmed = true,
                        Title             = "Delete external module",
                        DelegatedAction   = () =>
                        {
                            _externalModules.Remove(module);
                            _externalModules.AllModules.Save();
                        }
                    };
                    error.AddFix(fix);
                    ValidationErrors.Add(error);
                }
            }
        }
Exemplo n.º 2
0
        private void ValidateModules()
        {
            foreach (Project project in _repository.AllProjects)
            {
                string baseDir = Path.GetDirectoryName(project.FullPath);
                if (baseDir == null)
                {
                    continue;
                }
                foreach (var module in project.AllModules)
                {
                    string moduleFolderPath = Path.Combine(baseDir, module.Path);
                    if (!Directory.Exists(moduleFolderPath))
                    {
                        string details = string.Format("Project contains a module '{0}' but corresponding folder doesn't exist.", module.Path);
                        ValidationErrors.Add(new ValidationError(project, "Module folder doesn't exists", details, ErrorLevel.Error));
                        continue;
                    }

                    string moduleProjectPath = Path.GetFullPath(Path.Combine(moduleFolderPath, ProjectsRepository.ProjectFilePattern));
                    if (!File.Exists(moduleProjectPath))
                    {
                        string details = string.Format("Project contains a module '{0}' but the folder doesn't contain a pom.xml.", module.Path);
                        ValidationErrors.Add(new ValidationError(project, "Module project doesn't exists", details, ErrorLevel.Error));
                        continue;
                    }

                    if (_repository.AllProjects.FirstOrDefault(p => PathOperations.ArePathesEqual(moduleProjectPath, p.FullPath)) == null)
                    {
                        string details = string.Format("Project contains a module '{0}', but corresponding project hasn't been loaded", module.Path);
                        var    fix     = new DelegatedFix
                        {
                            Title           = "Try to load the module",
                            DelegatedAction = () => _repository.LoadOneProject(moduleProjectPath)
                        };
                        var error = new ValidationError(project, "Module hasn't been loaded", details, ErrorLevel.Error);
                        error.AddFix(fix);
                        ValidationErrors.Add(error);
                        continue;
                    }
                }
            }
        }