Exemple #1
0
        static int Main(string[] args)
        {
            var consoleParams = new ConsoleParameters(args);
            if (consoleParams.VerboseOutput)
                EnableConsoleDebugLog();

            var root = Kernel.Root;

            // Binding UI interfaces
            root.Bind<IUserOutput>().To<ConsoleUserInterface>().InSingletonScope();
            root.Bind<IParameters>().ToConstant(consoleParams).InSingletonScope();

            // Binding special directories
            var suiteRoot = new LocalFileSystemDirectory(Environment.CurrentDirectory);
            root.Bind<IFileSystemDirectory>()
                .ToConstant(suiteRoot)
                .WhenTargetHas<SuiteRootAttribute>();
            root.Bind<IFileSystemDirectory>()
                .ToConstant(suiteRoot.GetChildDirectory("target", createIfMissing: true))
                .WhenTargetHas<TargetRootAttribute>();

            // Binding core services
            Kernel.RegisterCoreBindings();

            // Binding default cache
            var cacheDir = suiteRoot.GetChildDirectory("cache", createIfMissing: true)
                                    .GetChildDirectory(consoleParams.Goal, createIfMissing: true);
            root.Bind<IFileSystemDirectory>()
                .ToConstant(cacheDir)
                .WhenTargetHas<CacheRootAttribute>();
            root.Bind<IBuildCache>().To<FileBuildCache>();            

            // Loading fix plugins
            root.Load(GetOrderedModuleList(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bari.Plugins.*.dll"));

            // Initializing the cache cleaner
            root.Bind<ICleanExtension>().ToConstant(new CacheCleaner(cacheDir, root.Get<IBuilderEnumerator>()));

            var process = root.Get<MainProcess>();
            try
            {
                if (process.Run())
                    return 0;
                else
                    return 1;
            }
            catch (Exception ex)
            {
                System.Console.ForegroundColor = ConsoleColor.Red;
                System.Console.WriteLine(ex.ToString());
                System.Console.ForegroundColor = ConsoleColor.Gray;

                return 2;
            }
        }
Exemple #2
0
        private ISet <TargetRelativePath> DeployDirectoryContents(IFileSystemDirectory depDir, string directoryPath, string subDir)
        {
            var result = new HashSet <TargetRelativePath>();

            //Files
            foreach (var file in repository.ListFiles(directoryPath))
            {
                var fileName = Path.GetFileName(file);
                repository.Copy(file, depDir, Path.Combine(subDir, fileName));
                result.Add(new TargetRelativePath(targetRoot.GetRelativePath(depDir), Path.Combine(subDir, fileName)));
            }

            //Child directories
            var directory = new LocalFileSystemDirectory(directoryPath);

            foreach (var childDirectory in directory.ChildDirectories)
            {
                var dir         = directory.GetChildDirectory(childDirectory);
                var dirContents = DeployDirectoryContents(depDir, dir.ToString(), Path.Combine(subDir, childDirectory));
                foreach (var path in dirContents)
                {
                    result.Add(path);
                }
            }

            return(result);
        }
Exemple #3
0
        public void GetChildDirectoryForNonExistingDirectoryReturnsNull()
        {
            using (var tmp = new TempDirectory())
            {
                var dir    = new LocalFileSystemDirectory(tmp);
                var subdir = dir.GetChildDirectory("dir1");

                subdir.Should().BeNull();
            }
        }
Exemple #4
0
        public void GetChildDirectoryWorks()
        {
            using (var tmp = new TempDirectory())
            {
                Directory.CreateDirectory(Path.Combine(tmp, "dir1"));
                var dir    = new LocalFileSystemDirectory(tmp);
                var subdir = dir.GetChildDirectory("dir1");

                subdir.Should().NotBeNull();
            }
        }
Exemple #5
0
        public void GetRelativePathWorks()
        {
            using (var tmp = new TempDirectory())
            {
                Directory.CreateDirectory(Path.Combine(tmp, "dir1"));
                Directory.CreateDirectory(Path.Combine(tmp, "dir1", "dir2"));

                var dir  = new LocalFileSystemDirectory(tmp);
                var dir1 = dir.GetChildDirectory("dir1");
                var dir2 = dir1.GetChildDirectory("dir2");

                dir1.Should().NotBeNull();
                dir2.Should().NotBeNull();

                dir.GetRelativePath(dir1).Should().Be("dir1");
                dir.GetRelativePath(dir2).Should().Be(Path.Combine("dir1", "dir2"));
            }
        }
        public void GetRelativePathWorks()
        {
            using (var tmp = new TempDirectory())
            {
                Directory.CreateDirectory(Path.Combine(tmp, "dir1"));
                Directory.CreateDirectory(Path.Combine(tmp, "dir1", "dir2"));

                var dir = new LocalFileSystemDirectory(tmp);
                var dir1 = dir.GetChildDirectory("dir1");
                var dir2 = dir1.GetChildDirectory("dir2");

                dir1.Should().NotBeNull();
                dir2.Should().NotBeNull();

                dir.GetRelativePath(dir1).Should().Be("dir1");
                dir.GetRelativePath(dir2).Should().Be(Path.Combine("dir1", "dir2"));
            }
        }
        public void GetChildDirectoryWorks()
        {
            using (var tmp = new TempDirectory())
            {
                Directory.CreateDirectory(Path.Combine(tmp, "dir1"));
                var dir = new LocalFileSystemDirectory(tmp);
                var subdir = dir.GetChildDirectory("dir1");

                subdir.Should().NotBeNull();
            }
        }
        public void GetChildDirectoryForNonExistingDirectoryReturnsNull()
        {
            using (var tmp = new TempDirectory())
            {
                var dir = new LocalFileSystemDirectory(tmp);
                var subdir = dir.GetChildDirectory("dir1");

                subdir.Should().BeNull();
            }
        }
Exemple #9
0
        static int Main(string[] args)
        {
            var consoleParams = new ConsoleParameters(args);

            if (consoleParams.VerboseOutput)
            {
                EnableConsoleDebugLog();
            }

            var root = Kernel.Root;

            // Binding UI interfaces
            root.Bind <IUserOutput>().To <ConsoleUserInterface>().InSingletonScope();
            root.Bind <IParameters>().ToConstant(consoleParams).InSingletonScope();

            // Binding special directories
            var suiteRoot = new LocalFileSystemDirectory(Environment.CurrentDirectory);

            root.Bind <IFileSystemDirectory>()
            .ToConstant(suiteRoot)
            .WhenTargetHas <SuiteRootAttribute>();
            root.Bind <IFileSystemDirectory>()
            .ToConstant(suiteRoot.GetChildDirectory("target", createIfMissing: true))
            .WhenTargetHas <TargetRootAttribute>();

            // Binding core services
            Kernel.RegisterCoreBindings();

            // Binding default cache
            var cacheDir = suiteRoot.GetChildDirectory("cache", createIfMissing: true)
                           .GetChildDirectory(consoleParams.Goal, createIfMissing: true);

            root.Bind <IFileSystemDirectory>()
            .ToConstant(cacheDir)
            .WhenTargetHas <CacheRootAttribute>();
            root.Bind <IBuildCache>().To <FileBuildCache>();

            // Loading fix plugins
            root.Load(GetOrderedModuleList(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bari.Plugins.*.dll"));

            // Initializing the cache cleaner
            root.Bind <ICleanExtension>().ToConstant(new CacheCleaner(cacheDir, root.Get <IBuilderEnumerator>()));

            var process = root.Get <MainProcess>();

            try
            {
                if (process.Run())
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            catch (Exception ex)
            {
                System.Console.ForegroundColor = ConsoleColor.Red;
                System.Console.WriteLine(ex.ToString());
                System.Console.ForegroundColor = ConsoleColor.Gray;

                return(2);
            }
        }
Exemple #10
0
        static int Main(string[] args)
        {
            var consoleParams = new ConsoleParameters(args);
            if (consoleParams.VerboseOutput)
                EnableConsoleDebugLog();

            var root = Kernel.Root;

            // Binding UI interfaces
            root.Bind<IUserOutput>().To<ConsoleUserInterface>().InSingletonScope();
            root.Bind<IParameters>().ToConstant(consoleParams).InSingletonScope();

            // Binding special directories
            var suiteRoot = new LocalFileSystemDirectory(Environment.CurrentDirectory);
            root.Bind<IFileSystemDirectory>()
                .ToConstant(suiteRoot)
                .WhenTargetHas<SuiteRootAttribute>();
            root.Bind<IFileSystemDirectory>()
                .ToConstant(suiteRoot.GetChildDirectory("target", createIfMissing: true))
                .WhenTargetHas<TargetRootAttribute>();

            // Binding core services
            Kernel.RegisterCoreBindings();

            // Binding default cache
            var cacheDir = new Lazy<IFileSystemDirectory>(() =>
                suiteRoot.GetChildDirectory("cache", createIfMissing: true)
                         .GetChildDirectory(root.Get<Suite>().ActiveGoal.Name, createIfMissing: true));
            root.Bind<Lazy<IFileSystemDirectory>>()
                .ToConstant(cacheDir)
                .WhenTargetHas<CacheRootAttribute>();
            root.Bind<IBuildCache>().To<FileBuildCache>();

            // Loading fix plugins
            var pluginLoader = root.Get<IPluginLoader>();
            foreach (var module in GetOrderedModuleList(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bari.Plugins.*.dll"))
                pluginLoader.Load(module);

            // Initializing builder store
            Kernel.InitializeBuilderStore();

            // Initializing the cache cleaner
            root.Bind<ICleanExtension>().ToConstant(new CacheCleaner(cacheDir, root.Get<IBuilderEnumerator>(), () => root.Get<ISoftCleanPredicates>()));

            var process = root.Get<MainProcess>();
            try
            {
                if (process.Run())
                    return 0;
                else
                    return 1;
            }
            catch (Exception ex)
            {
                var output = root.Get<IUserOutput>();
                output.Error(ex.ToString());

                return 2;
            }
        }
Exemple #11
0
        static int Main(string[] args)
        {
            var consoleParams = new ConsoleParameters(args);

            if (consoleParams.VerboseOutput)
            {
                EnableConsoleDebugLog();
            }

            var root = Kernel.Root;

            // Binding UI interfaces
            root.Bind <IUserOutput>().To <ConsoleUserInterface>().InSingletonScope();
            root.Bind <IParameters>().ToConstant(consoleParams).InSingletonScope();

            // Binding special directories
            var suiteRoot = new LocalFileSystemDirectory(Environment.CurrentDirectory);

            root.Bind <IFileSystemDirectory>()
            .ToConstant(suiteRoot)
            .WhenTargetHas <SuiteRootAttribute>();
            root.Bind <IFileSystemDirectory>()
            .ToConstant(suiteRoot.GetChildDirectory("target", createIfMissing: true))
            .WhenTargetHas <TargetRootAttribute>();

            // Binding core services
            Kernel.RegisterCoreBindings();

            // Binding default cache
            var cacheDir = new Lazy <IFileSystemDirectory>(() =>
                                                           suiteRoot.GetChildDirectory("cache", createIfMissing: true)
                                                           .GetChildDirectory(root.Get <Suite>().ActiveGoal.Name, createIfMissing: true));

            root.Bind <Lazy <IFileSystemDirectory> >()
            .ToConstant(cacheDir)
            .WhenTargetHas <CacheRootAttribute>();
            root.Bind <IBuildCache>().To <FileBuildCache>();

            // Loading fix plugins
            var pluginLoader = root.Get <IPluginLoader>();

            foreach (var module in GetOrderedModuleList(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Bari.Plugins.*.dll"))
            {
                pluginLoader.Load(module);
            }

            // Initializing builder store
            Kernel.InitializeBuilderStore();

            // Initializing the cache cleaner
            root.Bind <ICleanExtension>().ToConstant(new CacheCleaner(cacheDir, root.Get <IBuilderEnumerator>(), () => root.Get <ISoftCleanPredicates>()));

            var process = root.Get <MainProcess>();

            try
            {
                if (process.Run())
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            catch (Exception ex)
            {
                var output = root.Get <IUserOutput>();
                output.Error(ex.ToString());

                return(2);
            }
        }