private void AddDependencies(ITargetInternal target, List <ITargetInternal> targets) { foreach (var dependency in target.Dependencies) { var dependantTarget = _targetTree.GetTarget(dependency.TargetName); targets.Add(dependantTarget); AddDependencies(dependantTarget, targets); } }
public ITargetInternal AddTarget(ITargetInternal target) { if (_targets.ContainsKey(target.TargetName)) { throw new ArgumentException($"Target with the name '{target.TargetName}' already exists"); } _targets.Add(target.TargetName, target); return(target); }
public async Task RunTargetAsync(ITaskContextInternal taskContext, string targetName) { if (!_targets.ContainsKey(targetName)) { throw new ArgumentException($"The target '{targetName}' does not exist"); } ITargetInternal target = _targets[targetName]; await target.ExecuteVoidAsync(taskContext); }
public ITarget GetTargetFluentInterface(ITargetInternal target, ITaskContextInternal taskContext) { ITarget t = _sp.GetRequiredService <ITarget>(); TargetFluentInterface targetFluent = (TargetFluentInterface)t; targetFluent.Target = target; targetFluent.Context = taskContext; targetFluent.CoreTaskFluent = GetCoreTaskFluentInterface(taskContext); targetFluent.TaskFluent = GetTaskFluentInterface(taskContext); return(targetFluent); }
public void ConfigureSimpleTarget() { ITaskSession session = _sp.GetRequiredService <ITaskSession>(); SimpleBuildScript bs = new SimpleBuildScript(); bs.Run(session); Assert.True(session.TargetTree.HasAllTargets(new List <string>() { "test" }, out _)); Assert.True(session.TargetTree.HasAllTargets(new List <string>() { "test1" }, out _)); ITargetInternal t = session.TargetTree.GetTarget("test"); ITargetInternal t1 = session.TargetTree.GetTarget("test1"); Assert.Equal(t.TargetName, t1.Dependencies.FirstOrDefault().Key); }
public void EnsureDependenciesExecuted(ITaskContextInternal taskContext, string targetName) { if (_args.NoDependencies) { taskContext.LogInfo("Skipping target dependencies."); return; } ITargetInternal target = _targets[targetName]; int n = target.Dependencies.Count; List <Task> tasks = new List <Task>(); for (int i = 0; i < n; i++) { var dependantTargetName = target.Dependencies.Keys.ElementAt(i); var executionMode = target.Dependencies.Values.ElementAt(i); if (_executedTargets.Contains(dependantTargetName)) { continue; } if (_args.TargetsToExecute != null) { if (!_args.TargetsToExecute.Contains(dependantTargetName)) { throw new TaskExecutionException($"Target {dependantTargetName} is not on the TargetsToExecute list", 3); } DependenciesExecutedCount++; } if (executionMode == TaskExecutionMode.Synchronous) { RunTarget(taskContext, dependantTargetName); } else { tasks.Add(RunTargetAsync(taskContext, dependantTargetName)); if (i + 1 < n) { if (target.Dependencies.Values.ElementAt(i + 1) != TaskExecutionMode.Synchronous) { continue; } if (tasks.Count <= 0) { continue; } Task.WaitAll(tasks.ToArray()); tasks = new List <Task>(); } else { if (tasks.Count > 0) { Task.WaitAll(tasks.ToArray()); } } } } }
public void SetDefaultTarget(ITargetInternal target) { DefaultTargets.Add(target); }
public void MarkTargetAsExecuted(ITargetInternal target) { _executedTargets.Add(target.TargetName); }
public ITarget CreateTarget(string name) { ITargetInternal target = TargetTree.AddTarget(name); return(_fluentFactory.GetTargetFluentInterface(target, (ITaskContextInternal)this)); }
public ITargetInternal AddTarget(ITargetInternal target) { _targets.Add(target.TargetName, target); return(target); }