Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 798b2ef

Browse files
committed
Add the new binderator-based bindings for Kotlin
- dropped the version to v1.2.71 (the latest v1.2 before upgrading) - using binderator instead of manual projects - using targets files instead of embedded jars
1 parent 8b22847 commit 798b2ef

33 files changed

+322
-1094
lines changed

Android/Kotlin/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
generated/

Android/Kotlin/build.cake

Lines changed: 59 additions & 186 deletions
Original file line numberDiff line numberDiff line change
@@ -1,206 +1,79 @@
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" //
71

8-
var TARGET = Argument ("t", Argument ("target", "Default"));
2+
var TARGET = Argument("t", Argument("target", "Default"));
93

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(() =>
216
{
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;
499

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+
});
5714

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");
5829

5930
Task("libs")
6031
.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");
7541

76-
EnsureDirectoryExists("./output/");
77-
foreach(string asm in assemblies)
78-
{
79-
CopyFileToDirectory(asm, "./output/");
80-
}
42+
MSBuild("./generated/Xamarin.Kotlin.sln", settings);
43+
});
8144

82-
}
83-
);
45+
Task("nuget")
46+
.IsDependentOn("libs");
8447

8548
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(() =>
9851
{
99-
FilePathCollection files = GetFiles(pattern);
52+
var settings = new MSBuildSettings()
53+
.SetConfiguration("Release")
54+
.SetVerbosity(Verbosity.Minimal)
55+
.WithRestore()
56+
.WithProperty("DesignTimeBuild", "false");
10057

101-
foreach(FilePath file in files)
102-
{
103-
NuGetRestore(file, new NuGetRestoreSettings { } );
104-
}
58+
MSBuild("./samples/KotlinSample.sln", settings);
59+
});
10560

106-
return;
107-
}
108-
public void Build(string pattern)
61+
Task("clean")
62+
.Does(() =>
10963
{
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");
16566

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+
});
19672

19773
Task("Default")
198-
.Does
199-
(
200-
() =>
201-
{
202-
RunTarget("nuget");
203-
}
204-
);
74+
.IsDependentOn("externals")
75+
.IsDependentOn("libs")
76+
.IsDependentOn("nuget")
77+
.IsDependentOn("samples");
20578

206-
RunTarget (TARGET);
79+
RunTarget(TARGET);

Android/Kotlin/config.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[{
2+
"mavenRepositoryType" : "MavenCentral",
3+
"slnFile" : "generated/Xamarin.Kotlin.sln",
4+
"templates" : [
5+
{
6+
"templateFile": "source/Project.cshtml",
7+
"outputFileRule" : "generated/{groupid}.{artifactid}/{groupid}.{artifactid}.csproj"
8+
},
9+
{
10+
"templateFile": "source/Targets.cshtml",
11+
"outputFileRule" : "generated/{groupid}.{artifactid}/{nugetid}.targets"
12+
}
13+
],
14+
"artifacts" : [
15+
{
16+
"groupId" : "org.jetbrains.kotlin",
17+
"artifactId" : "kotlin-stdlib",
18+
"version" : "1.2.71",
19+
"nugetId" : "Xamarin.Kotlin.StdLib"
20+
},
21+
{
22+
"groupId" : "org.jetbrains.kotlin",
23+
"artifactId" : "kotlin-stdlib-common",
24+
"version" : "1.2.71",
25+
"nugetId" : "Xamarin.Kotlin.StdLib.Common",
26+
"metadata" :
27+
{
28+
"friendlyName" : "Common"
29+
}
30+
},
31+
{
32+
"groupId" : "org.jetbrains.kotlin",
33+
"artifactId" : "kotlin-stdlib-jdk7",
34+
"version" : "1.2.71",
35+
"nugetId" : "Xamarin.Kotlin.StdLib.Jdk7",
36+
"metadata" :
37+
{
38+
"friendlyName" : "JDK 7 extension"
39+
}
40+
},
41+
{
42+
"groupId" : "org.jetbrains.kotlin",
43+
"artifactId" : "kotlin-stdlib-jdk8",
44+
"version" : "1.2.71",
45+
"nugetId" : "Xamarin.Kotlin.StdLib.Jdk8",
46+
"metadata" :
47+
{
48+
"friendlyName" : "JDK 8 extension"
49+
}
50+
},
51+
{
52+
"groupId" : "org.jetbrains.kotlin",
53+
"artifactId" : "kotlin-stdlib-jre7",
54+
"version" : "1.2.71",
55+
"nugetId" : "Xamarin.Kotlin.StdLib.Jre7"
56+
},
57+
{
58+
"groupId" : "org.jetbrains.kotlin",
59+
"artifactId" : "kotlin-stdlib-jre8",
60+
"version" : "1.2.71",
61+
"nugetId" : "Xamarin.Kotlin.StdLib.Jre8"
62+
},
63+
{
64+
"groupId" : "org.jetbrains",
65+
"artifactId" : "annotations",
66+
"version" : "13.0",
67+
"nugetId" : "Xamarin.Jetbrains.Annotations"
68+
}
69+
]
70+
}]

Android/Kotlin/native/KotlinSample/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.3.21'
4+
ext.kotlin_version = '1.2.51'
55
repositories {
66
google()
77
jcenter()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<RestoreNoCache>true</RestoreNoCache>
5+
<RestorePackagesPath>$(MSBuildThisFileDirectory)..\externals\packages</RestorePackagesPath>
6+
</PropertyGroup>
7+
</Project>
Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 2012
4-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Kotlin.StdLib", "..\source\Xamarin.Kotlin.StdLib\Xamarin.Kotlin.StdLib.csproj", "{A905D25B-A356-47F7-ACDD-70DA7596B1D1}"
5-
EndProject
64
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KotlinSample", "KotlinSample\KotlinSample.csproj", "{F1C5F1D2-9A56-4700-B9AE-524C072FF06D}"
75
EndProject
86
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KotlinSampleLibrary", "KotlinSampleLibrary\KotlinSampleLibrary.csproj", "{7284601F-A95A-4707-9FF2-4618AB0A9AA9}"
97
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Kotlin.StdLib.Jdk7", "..\source\Xamarin.Kotlin.StdLib.Jdk7\Xamarin.Kotlin.StdLib.Jdk7.csproj", "{B2E2FEF0-A260-433E-A747-485D6220D51C}"
11-
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Kotlin.StdLib.Jdk8", "..\source\Xamarin.Kotlin.StdLib.Jdk8\Xamarin.Kotlin.StdLib.Jdk8.csproj", "{2B848B8A-8E51-4A01-A523-13B7451C6289}"
13-
EndProject
148
Global
159
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1610
Debug|Any CPU = Debug|Any CPU
1711
Release|Any CPU = Release|Any CPU
1812
EndGlobalSection
1913
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20-
{A905D25B-A356-47F7-ACDD-70DA7596B1D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{A905D25B-A356-47F7-ACDD-70DA7596B1D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{A905D25B-A356-47F7-ACDD-70DA7596B1D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{A905D25B-A356-47F7-ACDD-70DA7596B1D1}.Release|Any CPU.Build.0 = Release|Any CPU
2414
{F1C5F1D2-9A56-4700-B9AE-524C072FF06D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2515
{F1C5F1D2-9A56-4700-B9AE-524C072FF06D}.Debug|Any CPU.Build.0 = Debug|Any CPU
2616
{F1C5F1D2-9A56-4700-B9AE-524C072FF06D}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -29,13 +19,5 @@ Global
2919
{7284601F-A95A-4707-9FF2-4618AB0A9AA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
3020
{7284601F-A95A-4707-9FF2-4618AB0A9AA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
3121
{7284601F-A95A-4707-9FF2-4618AB0A9AA9}.Release|Any CPU.Build.0 = Release|Any CPU
32-
{B2E2FEF0-A260-433E-A747-485D6220D51C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33-
{B2E2FEF0-A260-433E-A747-485D6220D51C}.Debug|Any CPU.Build.0 = Debug|Any CPU
34-
{B2E2FEF0-A260-433E-A747-485D6220D51C}.Release|Any CPU.ActiveCfg = Release|Any CPU
35-
{B2E2FEF0-A260-433E-A747-485D6220D51C}.Release|Any CPU.Build.0 = Release|Any CPU
36-
{2B848B8A-8E51-4A01-A523-13B7451C6289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37-
{2B848B8A-8E51-4A01-A523-13B7451C6289}.Debug|Any CPU.Build.0 = Debug|Any CPU
38-
{2B848B8A-8E51-4A01-A523-13B7451C6289}.Release|Any CPU.ActiveCfg = Release|Any CPU
39-
{2B848B8A-8E51-4A01-A523-13B7451C6289}.Release|Any CPU.Build.0 = Release|Any CPU
4022
EndGlobalSection
4123
EndGlobal

0 commit comments

Comments
 (0)