Пример #1
0
        public static void Publish(
            string root,
            PublishOptions publishOptions,
            ProjectPackSubSystem.PackOptions packOptions)
        {
            string src = Path.Combine(root, "build", "module.json");

            ProjectPackSubSystem.Pack(root, packOptions);

            if (!File.Exists(src))
            {
                EventManager <ErrorEvent> .SendEvent(new FileNotFoundEvent( src, false ));

                return;
            }

            ProjectConfig t = ProjectConfig.Load(src);

            Logger.LogMessage(LoggerSystems.ModuleSystem, "Publishing '{0}'", src);

            ProjectResolver.GetManager(publishOptions.Repository).
            AddPackage(
                t,
                Path.Combine(root, "build", "module.zip")
                );
        }
Пример #2
0
        public static void Restore(string projectRoot, string repo)
        {
            string src = Path.Combine(projectRoot, "project.json");

            ProjectConfig t =
                ProjectConfig.Load(src);

            ProjectResolver.GetManager(repo).Restore(t, projectRoot);
        }
        private ProjectConfig ExecuteAndReloadConfig(Task task, string testFolder)
        {
            var expectedFile = Path.Combine(testFolder, ExpectedProjectConfigFileName);

            File.Exists(expectedFile).Should().BeFalse("Test error: output file should not exist before the task is executed");

            var result = task.Execute();

            result.Should().BeTrue("Expecting the task execution to succeed");
            File.Exists(expectedFile).Should().BeTrue("Expected output file was not created by the task. Expected: {0}", expectedFile);
            TestContext.AddResultFile(expectedFile);

            var config = ProjectConfig.Load(expectedFile);

            config.Should().NotBeNull("Not expecting the reloaded project config file to be null");
            return(config);
        }
Пример #4
0
        public static void Clean(string projectRoot)
        {
            string src = Path.Combine(projectRoot, "project.json");

            if (!File.Exists(src))
            {
                EventManager <ErrorEvent> .SendEvent(new ProjectFileNotFoundEvent( projectRoot ));

                return;
            }

            Logger.LogMessage(LoggerSystems.ModuleSystem, "Cleaning '{0}'", src);

            if (Directory.Exists(Path.Combine(projectRoot, "build")))
            {
                Directory.Delete(Path.Combine(projectRoot, "build"), true);
            }

            IEnumerable <string> sourceFiles = Directory.GetFiles(projectRoot, "*.*", SearchOption.AllDirectories).
                                               Select(Path.GetFullPath);

            int fcount = 0;

            foreach (string sourceFile in sourceFiles)
            {
                string ext = Path.GetExtension(sourceFile);

                if (ext == ".vbin" || ext == ".vbin.z" || ext == ".linkertext")
                {
                    fcount++;
                    File.Delete(sourceFile);
                }
            }

            ProjectConfig t = ProjectConfig.Load(Path.Combine(projectRoot, "project.json"));

            foreach (ProjectDependency moduleDependency in t.Dependencies)
            {
                if (Directory.Exists(Path.Combine(projectRoot, moduleDependency.ProjectName)))
                {
                    Directory.Delete(Path.Combine(projectRoot, moduleDependency.ProjectName), true);
                }
            }
        }
Пример #5
0
            public ProjectStructure(Context context, string projectSpecificConfigDir, string projectSpecificOutputDir, bool checkAndLoadConfigFile)
            {
                this.context             = context;
                ProjectSpecificConfigDir = projectSpecificConfigDir;
                ProjectSpecificOutputDir = projectSpecificOutputDir;

                // ProjectInfo.xml should always exist (even for excluded projects) to provide file list for sonar-project.properties
                var projectInfoFile = TryAddToResults(projectSpecificOutputDir, FileConstants.ProjectInfoFileName);

                AssertFileExists(projectInfoFile);
                ProjectInfo = ProjectInfo.Load(projectInfoFile.FullPath);

                if (checkAndLoadConfigFile)
                {
                    var projectConfigFile = TryAddToResults(projectSpecificConfigDir, ExpectedProjectConfigFileName);
                    AssertFileExists(projectConfigFile);
                    ProjectConfig = ProjectConfig.Load(projectConfigFile.FullPath);
                }
            }
        public override void Run(IEnumerable <string> args)
        {
            string[]      a = args.ToArray();
            ProjectConfig t = ProjectConfig.Load(Path.Combine(Path.GetFullPath(a[0]), "project.json"));

            AddDependencyConfig config = new AddDependencyConfig();

            ArgumentSyntaxParser.Parse(a.Skip(1).ToArray(), config);

            t.Dependencies.Add(
                new ProjectDependency
            {
                ProjectName    = config.Name,
                ProjectVersion = config.Version
            }
                );

            ProjectConfig.Save(Path.Combine(Directory.GetCurrentDirectory(), "project.json"), t);
        }
Пример #7
0
        public override void Run(IEnumerable <string> args)
        {
            string[] a = args.ToArray();
            ArgumentSyntaxParser.Parse(a, Logger.s_Settings);
            ProjectResolver.Initialize();
            CommonFiles.GenerateCommonFiles();

            string root = a.Length != 0
                              ? Path.GetFullPath(a[0])
                              : Directory.GetCurrentDirectory();

            string src = Path.Combine(root, "project.json");

            Logger.LogMessage(LoggerSystems.Console, "File: {0}", src);

            ProjectConfig.AddRunner(new BuildJobBuild());
            ProjectConfig.AddRunner(new BuildJobClean());
            ProjectConfig.AddRunner(new BuildJobPublish());
            ProjectConfig.AddRunner(new BuildJobRestore());
            ProjectConfig.AddRunner(new BuildJobExternalBuild());
            ProjectConfig.AddRunner(new BuildJobCombinedJobs());
            ProjectConfig.AddRunner(new BuildJobMoveContent());
            ProjectConfig.AddRunner(new BuildJobCopyContent());
            ProjectConfig.AddRunner(new BuildJobRunJob());
            ProjectConfig.AddRunner(new BuildJobGetDependency());
            ProjectConfig.AddRunner(new BuildJobAddOrigin());
            ProjectConfig.AddRunner(new BuildJobRemoveOrigin());
            ProjectConfig.AddRunner(new BuildJobMergedJobs());
            ProjectConfig.AddRunner(new BuildJobMakeHeader());

            ProjectConfig config = ProjectConfig.Load(src);

            string target = config.DefaultTarget;

            if (a.Length > 1)
            {
                target = a[1];
            }

            config.RunTarget(root, target);
        }
Пример #8
0
        public static void Pack(string projectRoot, PackOptions options)
        {
            string src = Path.Combine(Path.GetFullPath(projectRoot), "project.json");

            ProjectCleanSubSystem.Clean(Path.GetDirectoryName(src));
            Logger.LogMessage(LoggerSystems.ModuleSystem, "Packing '{0}'", src);

            string outDir = Path.Combine(Path.GetDirectoryName(src), "build");

            ProjectConfig t = ProjectConfig.Load(src);

            Version v = Version.Parse(t.ProjectVersion);

            t.ProjectVersion = ChangeVersion(v, options.VersionString).ToString();
            ProjectConfig.Save(src, t);

            string temp = Path.Combine(
                Path.GetDirectoryName(Directory.GetCurrentDirectory()),
                "temp_" + t.ProjectName
                );

            Directory.CreateDirectory(temp);

            CopyTo(Path.GetDirectoryName(src), temp);

            foreach (ProjectDependency moduleDependency in t.Dependencies)
            {
                string p = Path.Combine(temp, moduleDependency.ProjectName);

                if (Directory.Exists(p))
                {
                    Directory.Delete(p, true);
                }
            }

            Directory.CreateDirectory(outDir);
            ZipFile.CreateFromDirectory(temp, Path.Combine(outDir, "module.zip"));
            Directory.Delete(temp, true);
            ProjectConfig.Save(Path.Combine(outDir, "module.json"), t);
        }
Пример #9
0
        public override void RunJob(
            string projectRoot,
            ProjectConfig project,
            ProjectBuildTarget target,
            ProjectBuildJob job)
        {
            string path = job.Arguments["path"];

            string[] projects = path.Split(';');
            job.Arguments.TryGetValue("target", out string externalTarget);

            foreach (string projJson in projects)
            {
                if (string.IsNullOrWhiteSpace(projJson))
                {
                    continue;
                }

                string        projectPath = Path.GetFullPath(projJson);
                ProjectConfig external    = ProjectConfig.Load(projectPath);
                external.RunTarget(Path.GetDirectoryName(projectPath), externalTarget);
            }
        }