Nuke.Cola
Loading...
Searching...
No Matches
ImplicitBuildInterfacePluginProvider.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using System.Threading.Tasks;
6using Nuke.Common.Utilities;
7
9
10[AttributeUsage(AttributeTargets.Interface)]
11public class ImplicitBuildInterfaceAttribute : Attribute {}
12
13/// <summary>
14/// Gather build interfaces from main assembly which should be implicitly included in the main
15/// build class without that knowing about it.
16/// </summary>
18{
19 public IEnumerable<IHavePlugin> GatherPlugins(BuildContext context)
20 {
21 var interfaces = Assembly.GetEntryAssembly()!
22 .GetBuildInterfaces()
23 .Where(i => i.Interface.HasCustomAttribute<ImplicitBuildInterfaceAttribute>())
24 .ToList();
25
26 if (interfaces.Count > 0)
27 yield return new ImplicitBuildInterfacePlugin
28 {
29 Interfaces = interfaces
30 };
31 }
32
33 public void InitializeEngine(BuildContext context) {}
34}
Gather build interfaces from main assembly which should be implicitly included in the main build clas...
IEnumerable< IHavePlugin > GatherPlugins(BuildContext context)
Gathering plugins from the provided context.
void InitializeEngine(BuildContext context)
One time initialization of the provider.
Implementations of this interface must represent a plugin system which might have a distinct logic an...
record class BuildContext(AbsolutePath Temporary, AbsolutePath Root)
Local paths for plugin discovery and compilation.