Skip to content

Commit

Permalink
Merge pull request #576 from xamarin/master_based_Xamarin.Kotlin.StdLib
Browse files Browse the repository at this point in the history
xamarin.kotlin.std lib bindings
  • Loading branch information
newky2k committed May 22, 2019
2 parents 6770a92 + 5e96e9b commit 92e6d9f
Show file tree
Hide file tree
Showing 16 changed files with 743 additions and 125 deletions.
232 changes: 189 additions & 43 deletions Android/Kotlin/build.cake
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

#load "../../common.cake"
/*
Error: Could not resolve type with token 01000016 from typeref (expected class
'Cake.Core.CakeTaskBuilder`1' in assembly
'Cake.Core, Version=0.26.1.0, Culture=neutral, PublicKeyToken=null')
*/
//#load "../../common.cake" //

var TARGET = Argument ("t", Argument ("target", "Default"));

var JAR_VERSION = "1.3.11";
var JAR_VERSION = "1.3.31";

var JAR_STDLIB_URL = string.Format ("https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/{0}/kotlin-stdlib-{0}.jar", JAR_VERSION);
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);
Expand All @@ -13,53 +17,195 @@ var JAR_STDLIB_DEST = "./externals/kotlin-stdlib.jar";
var JAR_STDLIB_JDK7_DEST = "./externals/kotlin-stdlib-jdk7.jar";
var JAR_STDLIB_JDK8_DEST = "./externals/kotlin-stdlib-jdk8.jar";

var buildSpec = new BuildSpec () {
Libs = new ISolutionBuilder [] {
new DefaultSolutionBuilder {
SolutionPath = "./source/Xamarin.Kotlin.sln",
OutputFiles = new [] {
new OutputFileCopy { FromFile = "./source/Xamarin.Kotlin.StdLib/bin/Release/Xamarin.Kotlin.StdLib.dll", },
new OutputFileCopy { FromFile = "./source/Xamarin.Kotlin.StdLib.Jdk7/bin/Release/Xamarin.Kotlin.StdLib.Jdk7.dll", },
new OutputFileCopy { FromFile = "./source/Xamarin.Kotlin.StdLib.Jdk8/bin/Release/Xamarin.Kotlin.StdLib.Jdk8.dll", },
string[] configs = new string[]
{
"Debug",
"Release"
};

Task ("externals")
.Does
(
() =>
{
EnsureDirectoryExists ("./externals/");
if (!FileExists (JAR_STDLIB_DEST))
{
DownloadFile (JAR_STDLIB_URL, JAR_STDLIB_DEST);
}
if (!FileExists (JAR_STDLIB_JDK7_DEST))
{
DownloadFile (JAR_STDLIB_JDK7_URL, JAR_STDLIB_JDK7_DEST);
}
if (!FileExists (JAR_STDLIB_JDK8_DEST))
{
DownloadFile (JAR_STDLIB_JDK8_URL, JAR_STDLIB_JDK8_DEST);
}
string dir = "./native/KotlinSample/kotlinsamplelibrary/";
int exitCodeWithArgument =
StartProcess
(
"gradle",
new ProcessSettings
{
Arguments = "build",
RedirectStandardOutput = false,
WorkingDirectory = dir
}
);
}
},

Samples = new ISolutionBuilder [] {
new DefaultSolutionBuilder {
PreBuildAction = () => {
var gradlew = MakeAbsolute((FilePath)"./native/KotlinSample/gradlew");
StartProcess (gradlew, new ProcessSettings {
Arguments = "build",
WorkingDirectory = "./native/KotlinSample/"
});
},
SolutionPath = "./samples/KotlinSample.sln"
},
},
);

NuGets = new [] {
new NuGetInfo { NuSpec = "./nuget/Xamarin.Kotlin.StdLib.nuspec", RequireLicenseAcceptance = true },
new NuGetInfo { NuSpec = "./nuget/Xamarin.Kotlin.StdLib.Jdk7.nuspec", RequireLicenseAcceptance = true },
new NuGetInfo { NuSpec = "./nuget/Xamarin.Kotlin.StdLib.Jdk8.nuspec", RequireLicenseAcceptance = true },
},
};

Task ("externals")
.Does (() =>
Task("libs")
.IsDependentOn("externals")
.Does
(
() =>
{
RestorePackages("./source/**/*.sln");
Build("./source/**/*.sln");
Build("./source/**/*.csproj");
string[] assemblies = new string[]
{
"./source/Xamarin.Kotlin.StdLib/bin/Release/Xamarin.Kotlin.StdLib.dll",
"./source/Xamarin.Kotlin.StdLib.Jdk7/bin/Release/Xamarin.Kotlin.StdLib.Jdk7.dll",
"./source/Xamarin.Kotlin.StdLib.Jdk8/bin/Release/Xamarin.Kotlin.StdLib.Jdk8.dll",
};
EnsureDirectoryExists("./output/");
foreach(string asm in assemblies)
{
CopyFileToDirectory(asm, "./output/");
}
}
);

Task("samples")
.Does
(
() =>
{
RestorePackages("./samples/**/*.sln");
Build("./samples/**/*.sln");
Build("./samples/**/*.csproj");
}
);

public void RestorePackages(string pattern)
{
FilePathCollection files = GetFiles(pattern);

foreach(FilePath file in files)
{
NuGetRestore(file, new NuGetRestoreSettings { } );
}

return;
}
public void Build(string pattern)
{
FilePathCollection files = GetFiles(pattern);

foreach(FilePath file in files)
{
foreach (string config in configs)
{
MSBuild
(
file.ToString(),
new MSBuildSettings
{
Configuration = config,
}
//.WithProperty("DefineConstants", "TRACE;DEBUG;NETCOREAPP2_0;NUNIT")
.WithProperty("AndroidClassParser", "jar2xml")

);
}
}

return;
}

public void Package(string pattern)
{
EnsureDirectoryExists ("./externals/");
NuGetPackSettings settings = new NuGetPackSettings
{
BasePath = "./",
OutputDirectory = "./output/"
/*
Id = "TestNuGet",
Version = "0.0.0.1",
Title = "The tile of the package",
Authors = new string[] {"John Doe"},
Owners = new string[] {"Contoso"},
Description = "The description of the package",
Summary = "Excellent summary of what the package does",
ProjectUrl = new Uri("https://github.com/SomeUser/TestNuGet/"),
IconUrl = new Uri("http://cdn.rawgit.com/SomeUser/TestNuGet/master/icons/testNuGet.png"),
LicenseUrl = new Uri("https://github.com/SomeUser/TestNuGet/blob/master/LICENSE.md"),
Copyright = "Some company 2015",
ReleaseNotes = new string[] {"Bug fixes", "Issue fixes", "Typos"},
Tags = new string[] {"Cake", "Script", "Build"},
RequireLicenseAcceptance= false,
Symbols = false,
NoPackageAnalysis = true,
Files = new string[]
{
new NuSpecContent {Source = "bin/TestNuGet.dll", Target = "bin"},
},
BasePath = "./src/TestNuGet/bin/release",
*/
};

if (!FileExists (JAR_STDLIB_DEST)) DownloadFile (JAR_STDLIB_URL, JAR_STDLIB_DEST);
if (!FileExists (JAR_STDLIB_JDK7_DEST)) DownloadFile (JAR_STDLIB_JDK7_URL, JAR_STDLIB_JDK7_DEST);
if (!FileExists (JAR_STDLIB_JDK8_DEST)) DownloadFile (JAR_STDLIB_JDK8_URL, JAR_STDLIB_JDK8_DEST);
});
FilePathCollection files = GetFiles(pattern);

foreach(FilePath file in files)
{
foreach (string config in configs)
{
NuGetPack(file.ToString(), settings);
}
}

Task ("clean").IsDependentOn ("clean-base").Does (() =>
{
DeleteFiles ("./externals/*.jar");
});
return;
}
Task ("nuget")
.IsDependentOn("libs")
.Does
(
() =>
{
Package("./nuget/*.nuspec");
return;
}
);

Task ("clean")
.Does
(
() =>
{
DeleteFiles ("./externals/*.jar");
}
);

SetupXamarinBuildTasks (buildSpec, Tasks, Task);
Task("Default")
.Does
(
() =>
{
RunTarget("nuget");
}
);

RunTarget (TARGET);
4 changes: 2 additions & 2 deletions Android/Kotlin/nuget/Xamarin.Kotlin.StdLib.Jdk7.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>Xamarin.Kotlin.StdLib.Jdk7</id>
<title>Kotlin Standard Library JDK 7 extension for Xamarin.Android</title>
<version>1.3.21.0</version>
<version>1.3.31.0</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand All @@ -12,7 +12,7 @@
<projectUrl>https://go.microsoft.com/fwlink/?linkid=865001</projectUrl>
<licenseUrl>https://go.microsoft.com/fwlink/?linkid=865052</licenseUrl>
<dependencies>
<dependency id="Xamarin.Kotlin.StdLib" version="1.3.21.0" />
<dependency id="Xamarin.Kotlin.StdLib" version="1.3.31.0" />
</dependencies>
</metadata>
<files>
Expand Down
4 changes: 2 additions & 2 deletions Android/Kotlin/nuget/Xamarin.Kotlin.StdLib.Jdk8.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>Xamarin.Kotlin.StdLib.Jdk8</id>
<title>Kotlin Standard Library JDK 8 extension for Xamarin.Android</title>
<version>1.3.21.0</version>
<version>1.3.31.0</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand All @@ -12,7 +12,7 @@
<projectUrl>https://go.microsoft.com/fwlink/?linkid=865005</projectUrl>
<licenseUrl>https://go.microsoft.com/fwlink/?linkid=865054</licenseUrl>
<dependencies>
<dependency id="Xamarin.Kotlin.StdLib.Jdk7" version="1.3.21.0" />
<dependency id="Xamarin.Kotlin.StdLib.Jdk7" version="1.3.31.0" />
</dependencies>
</metadata>
<files>
Expand Down
2 changes: 1 addition & 1 deletion Android/Kotlin/nuget/Xamarin.Kotlin.StdLib.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>Xamarin.Kotlin.StdLib</id>
<title>Kotlin Standard Library for Xamarin.Android</title>
<version>1.3.21.0</version>
<version>1.3.31.0</version>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand Down
Loading

0 comments on commit 92e6d9f

Please sign in to comment.