-
Notifications
You must be signed in to change notification settings - Fork 5
/
recipe.cake
108 lines (96 loc) · 3.96 KB
/
recipe.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#load nuget:?package=Cake.Recipe&version=3.1.1
#addin nuget:?package=Cake.FileHelpers&version=4.0.1
var standardNotificationMessage = "Version {0} of {1} has just been released, it will be available here https://www.nuget.org/packages/{1}, once package indexing is complete.";
Environment.SetVariableNames();
BuildParameters.SetParameters(
context: Context,
buildSystem: BuildSystem,
masterBranchName: "main",
sourceDirectoryPath: "./src",
title: "Cake.IntelliJ.Recipe",
repositoryOwner: "cake-contrib",
shouldRunInspectCode: false,
shouldRunIntegrationTests: true,
shouldRunCoveralls: false,
shouldRunCodecov: false,
shouldRunDotNetCorePack: true,
gitterMessage: "@/all " + standardNotificationMessage,
twitterMessage: standardNotificationMessage,
preferredBuildProviderType: BuildProviderType.GitHubActions,
preferredBuildAgentOperatingSystem: PlatformFamily.Linux);
BuildParameters.PrintParameters(Context);
ToolSettings.SetToolPreprocessorDirectives(
gitReleaseManagerGlobalTool: "#tool dotnet:?package=GitReleaseManager.Tool&version=0.17.0");
ToolSettings.SetToolSettings(context: Context);
BuildParameters.Tasks.CleanTask
.IsDependentOn("Generate-Version-File")
.IsDependentOn("Copy-Cake-Recipe-Content");
Task("Copy-Cake-Recipe-Content")
.Does(() =>
{
var src = Directory("./lib/Cake.Recipe/Source/Cake.Recipe/Content");
var dst = Directory("./src/Cake.IntelliJ.Recipe/Content/Cake.Recipe");
var here = Directory("./src/Cake.IntelliJ.Recipe/Content");
DeleteFiles((dst + File("*.cake")).Path.FullPath);
DeleteFiles((dst + File("*.cake_ex")).Path.FullPath);
var files = GetFiles((src + File("*.cake")).Path.FullPath);
foreach (var file in files)
{
var name = file.GetFilename().FullPath;
var newName = name + "_ex";
CopyFile(file, dst + File(newName));
var fileHere = (here + File(name)).Path;
if(!FileExists(fileHere))
{
Warning("Creating new file from Cake.Recipe: "+name);
FileWriteText(fileHere, "#l ./Cake.Recipe/"+newName);
}
}
});
Task("Generate-Version-File")
.Does<BuildVersion>((context, buildVersion) => {
var gitTool = context.Tools.Resolve(new[]{"git", "git.exe"});
var cakeRecipeVersion = "";
if(gitTool == null) {
throw new FileNotFoundException("git could not be found on your system.");
}
// git submodule update --init
StartProcess(gitTool, new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("submodule")
.Append("update")
.Append("--init")
});
StartProcess(gitTool, new ProcessSettings {
Arguments = new ProcessArgumentBuilder()
.Append("submodule")
.Append("status")
.AppendQuoted(context.MakeAbsolute(File("./lib/Cake.Recipe")).FullPath),
RedirectStandardOutput = true,
RedirectedStandardOutputHandler = x => cakeRecipeVersion += x,
});
var buildMetaDataCodeGen = TransformText(@"
public class BuildMetaData
{
public static string Date { get; } = ""<%date%>"";
public static string Version { get; } = ""<%cakeRecipeVersion%>"";
public static string CakeVersion { get; } = ""<%cakeVersion%>"";
}
public class IntelliJBuildMetaData
{
public static string Version { get; } = ""<%version%>"";
}",
"<%",
"%>"
)
.WithToken("date", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"))
.WithToken("version", buildVersion.SemVersion)
.WithToken("cakeVersion", context.GetType().Assembly.GetName().Version)
.WithToken("cakeRecipeVersion", cakeRecipeVersion.Trim().Split(" ")[0])
.ToString();
System.IO.File.WriteAllText(
"./src/Cake.IntelliJ.Recipe/Content/version.cake",
buildMetaDataCodeGen
);
});
Build.RunDotNetCore();