Esempio n. 1
0
        public bool TestIsValidConfiguration(string filePath)
        {
            try
            {
                BuildConfigurationType buildConfig = DeserializeBuildConfigInternal(filePath);
                if (buildConfig == null)
                {
                    _logger?.LogError($"The provided configuration {filePath} is empty.");
                    return(false);
                }

                string versionMatch = ConfigurationUtility.IsVersionMatch(buildConfig.ConfigVersion, Version)
                    ? "[MATCH]"
                    : "[MISSMATCH]";
                string msg = $"{versionMatch} The provided configuration {filePath} is a valid configuration file." +
                             $"\n\tConfiguration version:\t{buildConfig.ConfigVersion}" +
                             $"\n\tParser version:       \t{Version}";
                // [gruenwaldlu, 2020-07-14-14:14:39+2]: Required for user feedback. Depending on the configuration, the logger may not print to the console out.
                Console.Out.Write(msg);
                _logger?.LogInformation(msg);
                return(true);
            }
            catch (Exception e)
            {
                StringBuilder builder = new StringBuilder();
                string        msg     = BuildErrorMessage(builder, e);
                // [gruenwaldlu, 2020-07-27-13:45:55+2]: Required for user feedback. Depending on the configuration, the logger may not print to the console out.
                Console.Out.Write(msg);
                _logger?.LogWarning(msg);
                return(false);
            }
        }
Esempio n. 2
0
        private IProject GetProjectFromConfig(BuildConfigurationType buildConfig, ProjectType buildConfigProject)
        {
            IProject project = _factory.MakeProject();

            project.Name = buildConfigProject.Id;
            AddJobsToProject(buildConfig, buildConfigProject, project);

            return(project);
        }
Esempio n. 3
0
        private BuildConfigurationType DeserializeBuildConfigInternal(string filePath)
        {
            XmlSerializer     xmlDataSerializer = new XmlSerializer(typeof(BuildConfigurationType));
            XmlReaderSettings settings          = GetXmlReaderSettings();

            using Stream stream    = _fileSystem.File.OpenRead(filePath);
            using XmlReader reader = XmlReader.Create(stream, settings);
            BuildConfigurationType buildConfig = (BuildConfigurationType)xmlDataSerializer.Deserialize(reader);

            return(buildConfig);
        }
Esempio n. 4
0
        private static object GetBuildConfigTaskFromTaskListItem(BuildConfigurationType buildConfig,
                                                                 object taskListItem)
        {
            object buildConfigTask = taskListItem;

            if (taskListItem is TaskReferenceType taskRef)
            {
                buildConfigTask = GetMatchingGlobalTask(buildConfig, taskRef);
            }

            return(buildConfigTask);
        }
Esempio n. 5
0
        public IEnumerable <IProject> Parse(string filePath)
        {
            BuildConfigurationType buildConfig = DeserializeBuildConfigInternal(filePath);

            IProject[] projects = new IProject[buildConfig.Projects.Length];
            for (int i = 0; i < buildConfig.Projects.Length; i++)
            {
                ProjectType buildConfigProject = buildConfig.Projects[i];
                projects[i] = GetProjectFromConfig(buildConfig, buildConfigProject);
            }

            return(projects);
        }
Esempio n. 6
0
 private void AddJobsToProject(BuildConfigurationType buildConfig, ProjectType buildConfigProject,
                               IProject project)
 {
     if (buildConfigProject.Jobs.Length == 0)
     {
         return;
     }
     foreach (JobType buildConfigJob in buildConfigProject.Jobs)
     {
         IJob job = _factory.MakeJob(buildConfigJob.Name);
         AddTasksToJob(buildConfig, job, buildConfigJob);
         project.AddJob(job);
     }
 }
Esempio n. 7
0
        private static object GetMatchingGlobalTask(BuildConfigurationType buildConfig, TaskReferenceType taskRef)
        {
            object buildConfigTask = null;

            foreach (AbstractTaskType globalTask in buildConfig.GlobalTasks)
            {
                if (!globalTask.Id.Equals(taskRef.ReferenceId))
                {
                    continue;
                }
                buildConfigTask = globalTask;
            }

            return(buildConfigTask);
        }
Esempio n. 8
0
        private void AddTasksToJob(BuildConfigurationType buildConfig, IJob job, JobType buildConfigJob)
        {
            TasksType taskList = (TasksType)buildConfigJob.Item;

            if (taskList.Items == null)
            {
                return;
            }

            foreach (object taskListItem in taskList.Items)
            {
                object buildConfigTask = GetBuildConfigTaskFromTaskListItem(buildConfig, taskListItem);

                ITask task = MakeTask(buildConfigTask);
                job.AddTask(task);
            }
        }