|
1 | | -/* |
2 | | -Error: Could not resolve type with token 01000016 from typeref (expected class |
3 | | -'Cake.Core.CakeTaskBuilder`1' in assembly |
4 | | -'Cake.Core, Version=0.26.1.0, Culture=neutral, PublicKeyToken=null') |
5 | | -*/ |
6 | | -//#load "../../common.cake" // |
7 | 1 |
|
8 | | -var TARGET = Argument ("t", Argument ("target", "Default")); |
| 2 | +var TARGET = Argument("t", Argument("target", "Default")); |
9 | 3 |
|
10 | | -var JAR_VERSION = "1.3.31"; |
11 | | - |
12 | | -var JAR_STDLIB_URL = string.Format ("https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/{0}/kotlin-stdlib-{0}.jar", JAR_VERSION); |
13 | | -var JAR_STDLIB_JDK7_URL = string.Format ("https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/{0}/kotlin-stdlib-jdk7-{0}.jar", JAR_VERSION); |
14 | | -var JAR_STDLIB_JDK8_URL = string.Format ("https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk8/{0}/kotlin-stdlib-jdk8-{0}.jar", JAR_VERSION); |
15 | | - |
16 | | -var JAR_STDLIB_DEST = "./externals/kotlin-stdlib.jar"; |
17 | | -var JAR_STDLIB_JDK7_DEST = "./externals/kotlin-stdlib-jdk7.jar"; |
18 | | -var JAR_STDLIB_JDK8_DEST = "./externals/kotlin-stdlib-jdk8.jar"; |
19 | | - |
20 | | -string[] configs = new string[] |
| 4 | +Task("binderate") |
| 5 | + .Does(() => |
21 | 6 | { |
22 | | - "Debug", |
23 | | - "Release" |
24 | | -}; |
25 | | - |
26 | | -Task ("externals") |
27 | | - .Does |
28 | | - ( |
29 | | - () => |
30 | | - { |
31 | | - EnsureDirectoryExists ("./externals/"); |
32 | | - |
33 | | - if (!FileExists (JAR_STDLIB_DEST)) |
34 | | - { |
35 | | - DownloadFile (JAR_STDLIB_URL, JAR_STDLIB_DEST); |
36 | | - } |
37 | | - if (!FileExists (JAR_STDLIB_JDK7_DEST)) |
38 | | - { |
39 | | - DownloadFile (JAR_STDLIB_JDK7_URL, JAR_STDLIB_JDK7_DEST); |
40 | | - } |
41 | | - if (!FileExists (JAR_STDLIB_JDK8_DEST)) |
42 | | - { |
43 | | - DownloadFile (JAR_STDLIB_JDK8_URL, JAR_STDLIB_JDK8_DEST); |
44 | | - } |
45 | | - |
46 | | - |
47 | | - string dir = "./native/KotlinSample/"; |
48 | | - var gradlew = MakeAbsolute((FilePath)"./native/KotlinSample/gradlew"); |
| 7 | + var configFile = MakeAbsolute(new FilePath("./config.json")).FullPath; |
| 8 | + var basePath = MakeAbsolute(new DirectoryPath("./")).FullPath; |
49 | 9 |
|
50 | | - int exitCodeWithArgument = StartProcess (gradlew, new ProcessSettings { |
51 | | - Arguments = "build", |
52 | | - WorkingDirectory = dir |
53 | | - }); |
54 | | - |
55 | | - } |
56 | | -); |
| 10 | + var exit = StartProcess("xamarin-android-binderator", |
| 11 | + $"--config=\"{configFile}\" --basepath=\"{basePath}\""); |
| 12 | + if (exit != 0) throw new Exception($"xamarin-android-binderator exited with code {exit}."); |
| 13 | +}); |
57 | 14 |
|
| 15 | +Task("native") |
| 16 | + .Does(() => |
| 17 | +{ |
| 18 | + var gradlew = MakeAbsolute((FilePath)"./native/KotlinSample/gradlew"); |
| 19 | + var exit = StartProcess(gradlew, new ProcessSettings { |
| 20 | + Arguments = "assemble", |
| 21 | + WorkingDirectory = "./native/KotlinSample/" |
| 22 | + }); |
| 23 | + if (exit != 0) throw new Exception($"Gradle exited with exit code {exit}."); |
| 24 | +}); |
| 25 | + |
| 26 | +Task("externals") |
| 27 | + .IsDependentOn("binderate") |
| 28 | + .IsDependentOn("native"); |
58 | 29 |
|
59 | 30 | Task("libs") |
60 | 31 | .IsDependentOn("externals") |
61 | | - .Does |
62 | | - ( |
63 | | - () => |
64 | | - { |
65 | | - RestorePackages("./source/**/*.sln"); |
66 | | - Build("./source/**/*.sln"); |
67 | | - Build("./source/**/*.csproj"); |
68 | | - |
69 | | - string[] assemblies = new string[] |
70 | | - { |
71 | | - "./source/Xamarin.Kotlin.StdLib/bin/Release/Xamarin.Kotlin.StdLib.dll", |
72 | | - "./source/Xamarin.Kotlin.StdLib.Jdk7/bin/Release/Xamarin.Kotlin.StdLib.Jdk7.dll", |
73 | | - "./source/Xamarin.Kotlin.StdLib.Jdk8/bin/Release/Xamarin.Kotlin.StdLib.Jdk8.dll", |
74 | | - }; |
| 32 | + .Does(() => |
| 33 | +{ |
| 34 | + var settings = new MSBuildSettings() |
| 35 | + .SetConfiguration("Release") |
| 36 | + .SetVerbosity(Verbosity.Minimal) |
| 37 | + .WithRestore() |
| 38 | + .WithProperty("DesignTimeBuild", "false") |
| 39 | + .WithProperty("PackageOutputPath", MakeAbsolute((DirectoryPath)"./output/").FullPath) |
| 40 | + .WithTarget("Pack"); |
75 | 41 |
|
76 | | - EnsureDirectoryExists("./output/"); |
77 | | - foreach(string asm in assemblies) |
78 | | - { |
79 | | - CopyFileToDirectory(asm, "./output/"); |
80 | | - } |
| 42 | + MSBuild("./generated/Xamarin.Kotlin.sln", settings); |
| 43 | +}); |
81 | 44 |
|
82 | | - } |
83 | | - ); |
| 45 | +Task("nuget") |
| 46 | + .IsDependentOn("libs"); |
84 | 47 |
|
85 | 48 | Task("samples") |
86 | | -.Does |
87 | | - ( |
88 | | - () => |
89 | | - { |
90 | | - RestorePackages("./samples/**/*.sln"); |
91 | | - Build("./samples/**/*.sln"); |
92 | | - Build("./samples/**/*.csproj"); |
93 | | - |
94 | | - } |
95 | | - ); |
96 | | - |
97 | | -public void RestorePackages(string pattern) |
| 49 | + .IsDependentOn("libs") |
| 50 | + .Does(() => |
98 | 51 | { |
99 | | - FilePathCollection files = GetFiles(pattern); |
| 52 | + var settings = new MSBuildSettings() |
| 53 | + .SetConfiguration("Release") |
| 54 | + .SetVerbosity(Verbosity.Minimal) |
| 55 | + .WithRestore() |
| 56 | + .WithProperty("DesignTimeBuild", "false"); |
100 | 57 |
|
101 | | - foreach(FilePath file in files) |
102 | | - { |
103 | | - NuGetRestore(file, new NuGetRestoreSettings { } ); |
104 | | - } |
| 58 | + MSBuild("./samples/KotlinSample.sln", settings); |
| 59 | +}); |
105 | 60 |
|
106 | | - return; |
107 | | -} |
108 | | -public void Build(string pattern) |
| 61 | +Task("clean") |
| 62 | + .Does(() => |
109 | 63 | { |
110 | | - FilePathCollection files = GetFiles(pattern); |
111 | | - |
112 | | - foreach(FilePath file in files) |
113 | | - { |
114 | | - foreach (string config in configs) |
115 | | - { |
116 | | - MSBuild |
117 | | - ( |
118 | | - file.ToString(), |
119 | | - new MSBuildSettings |
120 | | - { |
121 | | - Configuration = config, |
122 | | - } |
123 | | - //.WithProperty("DefineConstants", "TRACE;DEBUG;NETCOREAPP2_0;NUNIT") |
124 | | - .WithProperty("AndroidClassParser", "jar2xml") |
125 | | - |
126 | | - ); |
127 | | - } |
128 | | - } |
129 | | - |
130 | | - return; |
131 | | -} |
132 | | - |
133 | | -public void Package(string pattern) |
134 | | -{ |
135 | | - NuGetPackSettings settings = new NuGetPackSettings |
136 | | - { |
137 | | - BasePath = "./", |
138 | | - OutputDirectory = "./output/" |
139 | | - /* |
140 | | - Id = "TestNuGet", |
141 | | - Version = "0.0.0.1", |
142 | | - Title = "The tile of the package", |
143 | | - Authors = new string[] {"John Doe"}, |
144 | | - Owners = new string[] {"Contoso"}, |
145 | | - Description = "The description of the package", |
146 | | - Summary = "Excellent summary of what the package does", |
147 | | - ProjectUrl = new Uri("https://github.com/SomeUser/TestNuGet/"), |
148 | | - IconUrl = new Uri("http://cdn.rawgit.com/SomeUser/TestNuGet/master/icons/testNuGet.png"), |
149 | | - LicenseUrl = new Uri("https://github.com/SomeUser/TestNuGet/blob/master/LICENSE.md"), |
150 | | - Copyright = "Some company 2015", |
151 | | - ReleaseNotes = new string[] {"Bug fixes", "Issue fixes", "Typos"}, |
152 | | - Tags = new string[] {"Cake", "Script", "Build"}, |
153 | | - RequireLicenseAcceptance= false, |
154 | | - Symbols = false, |
155 | | - NoPackageAnalysis = true, |
156 | | - Files = new string[] |
157 | | - { |
158 | | - new NuSpecContent {Source = "bin/TestNuGet.dll", Target = "bin"}, |
159 | | - }, |
160 | | - BasePath = "./src/TestNuGet/bin/release", |
161 | | - */ |
162 | | - }; |
163 | | - |
164 | | - FilePathCollection files = GetFiles(pattern); |
| 64 | + CleanDirectories("./generated/*/bin"); |
| 65 | + CleanDirectories("./generated/*/obj"); |
165 | 66 |
|
166 | | - foreach(FilePath file in files) |
167 | | - { |
168 | | - foreach (string config in configs) |
169 | | - { |
170 | | - NuGetPack(file.ToString(), settings); |
171 | | - } |
172 | | - } |
173 | | - |
174 | | - return; |
175 | | -} |
176 | | -Task ("nuget") |
177 | | - .IsDependentOn("libs") |
178 | | - .Does |
179 | | - ( |
180 | | - () => |
181 | | - { |
182 | | - Package("./nuget/*.nuspec"); |
183 | | - |
184 | | - return; |
185 | | - } |
186 | | - ); |
187 | | - |
188 | | -Task ("clean") |
189 | | - .Does |
190 | | - ( |
191 | | - () => |
192 | | - { |
193 | | - DeleteFiles ("./externals/*.jar"); |
194 | | - } |
195 | | - ); |
| 67 | + CleanDirectories("./externals/"); |
| 68 | + CleanDirectories("./generated/"); |
| 69 | + CleanDirectories("./native/.gradle"); |
| 70 | + CleanDirectories("./native/**/build"); |
| 71 | +}); |
196 | 72 |
|
197 | 73 | Task("Default") |
198 | | -.Does |
199 | | - ( |
200 | | - () => |
201 | | - { |
202 | | - RunTarget("nuget"); |
203 | | - } |
204 | | - ); |
| 74 | + .IsDependentOn("externals") |
| 75 | + .IsDependentOn("libs") |
| 76 | + .IsDependentOn("nuget") |
| 77 | + .IsDependentOn("samples"); |
205 | 78 |
|
206 | | -RunTarget (TARGET); |
| 79 | +RunTarget(TARGET); |
0 commit comments