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

Commit f37ecf9

Browse files
[Guava] Multi-target for .NET 6 and MonoAndroid90 (#1111)
So far ported these packages to .NET 6: * Xamarin.Google.Guava * Xamarin.Google.Guava.FailureAccess * Xamarin.Google.Guava.ListenableFuture This requires: * Xamarin.Android from VS 16.10 * .NET 6.0.100-preview.4.21255.9 * .NET 6 Android workload * Xamarin.Legacy.Sdk * Updated `build.cake` to use `dotnet build` Other changes: * .nupkg should include a single copy of the .jar file * Added a Guava sample project
1 parent 4f6aec5 commit f37ecf9

File tree

19 files changed

+186
-82
lines changed

19 files changed

+186
-82
lines changed

.ci/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ jobs:
107107
inputs:
108108
version: ${{ parameters.dotnet }}
109109
performMultiLevelLookup: true
110+
includePreviewVersions: true
110111
condition: ne('${{ parameters.dotnet }}', '')
111112
# custom init steps
112113
- ${{ parameters.initSteps }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ tmpnupkg/
1313
*.user
1414
artifacts/
1515
.idea/
16+
*.binlog
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- Uncomment if a $(PackageVersionSuffix) is ever needed -->
4+
<!-- <PackageVersionSuffix>-net6preview04</PackageVersionSuffix> -->
5+
<!-- <PackageVersionSuffix Condition=" '$(BUILD_BUILDID)' != '' ">$(PackageVersionSuffix).$(BUILD_BUILDID)</PackageVersionSuffix> -->
6+
<GuavaNuGetVersion>28.2.0.1$(PackageVersionSuffix)</GuavaNuGetVersion>
7+
<GuavaFailureAccessNuGetVersion>1.0.1.3$(PackageVersionSuffix)</GuavaFailureAccessNuGetVersion>
8+
<GuavaListenableFutureNuGetVersion>1.0.0.3$(PackageVersionSuffix)</GuavaListenableFutureNuGetVersion>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<_NuGetBuildFolders Include="build\;buildTransitive\" />
12+
<_TfmNuGetBuildFolders Include="@(_NuGetBuildFolders->'%(Identity)monoandroid90\');@(_NuGetBuildFolders->'%(Identity)net6.0-android30.0\')" />
13+
</ItemGroup>
14+
</Project>

Android/Guava/build.cake

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ var GUAVA_VERSION = GUAVA_VERSION_BASE + "-android";
77
var GUAVA_FAILUREACCESS_VERSION = "1.0.1";
88
var GUAVA_LISTENABLEFUTURE_VERSION = "1.0";
99

10-
var GUAVA_NUGET_VERSION = "28.2.0.0";
11-
var GUAVA_FAILUREACCESS_NUGET_VERSION = "1.0.1.2";
12-
var GUAVA_LISTENABLEFUTURE_NUGET_VERSION = "1.0.0.2";
13-
1410
var JSR305_VERSION = "3.0.2";
1511
var CHECKER_COMPAT_QUAL_VERSION = "2.5.5";
1612
var ERROR_PRONE_ANNOTATIONS_VERSION = "2.3.3";
@@ -99,50 +95,47 @@ Task ("externals")
9995
if (zipFile != null)
10096
zipFile.Close();
10197
}
102-
103-
// Update .csproj nuget versions
104-
XmlPoke("./source/Guava/Guava.csproj", "/Project/PropertyGroup/PackageVersion", GUAVA_NUGET_VERSION);
105-
XmlPoke("./source/Guava.FailureAccess/Guava.FailureAccess.csproj", "/Project/PropertyGroup/PackageVersion", GUAVA_FAILUREACCESS_NUGET_VERSION);
106-
XmlPoke("./source/Guava.ListenableFuture/Guava.ListenableFuture.csproj", "/Project/PropertyGroup/PackageVersion", GUAVA_LISTENABLEFUTURE_NUGET_VERSION);
10798
});
10899

109100

110101
Task("libs")
111102
.IsDependentOn("externals")
112103
.Does(() =>
113104
{
114-
MSBuild("./Guava.sln", c => {
115-
c.Configuration = "Release";
116-
c.Restore = true;
117-
c.MaxCpuCount = 0;
118-
c.Properties.Add("DesignTimeBuild", new [] { "false" });
119-
});
105+
DotNetCoreRestore ("./Guava.sln");
106+
107+
DotNetCoreMSBuild ("./Guava.sln",
108+
new DotNetCoreMSBuildSettings()
109+
.SetConfiguration("Release")
110+
);
120111
});
121112

122113
Task("nuget")
123114
.IsDependentOn("libs")
124115
.Does(() =>
125116
{
126-
MSBuild ("./Guava.sln", c => {
127-
c.Configuration = "Release";
128-
c.MaxCpuCount = 0;
129-
c.Targets.Clear();
130-
c.Targets.Add("Pack");
131-
c.Properties.Add("PackageOutputPath", new [] { MakeAbsolute(new FilePath("./output")).FullPath });
132-
c.Properties.Add("PackageRequireLicenseAcceptance", new [] { "true" });
133-
c.Properties.Add("DesignTimeBuild", new [] { "false" });
134-
c.Properties.Add("NoBuild", new [] { "true" });
135-
});
117+
DotNetCoreMSBuild ("./Guava.sln",
118+
new DotNetCoreMSBuildSettings()
119+
.WithTarget("Pack")
120+
.SetConfiguration("Release")
121+
.WithProperty ("PackageOutputPath", MakeAbsolute(new FilePath("./output")).FullPath)
122+
.WithProperty ("PackageRequireLicenseAcceptance", "true")
123+
.WithProperty ("NoBuild", "true")
124+
);
136125
});
137126

138127
Task("samples")
139-
.IsDependentOn("nuget");
128+
.IsDependentOn("nuget")
129+
.Does (() =>
130+
{
131+
MSBuild("./samples/GuavaSample/GuavaSample.csproj", c => c.Restore = true);
132+
});
140133

141134
Task ("clean")
142135
.Does (() =>
143136
{
144137
if (DirectoryExists ("./externals/"))
145-
DeleteDirectory ("./externals", true);
138+
DeleteDirectory ("./externals", new DeleteDirectorySettings { Recursive = true });
146139
});
147140

148141
Task ("ci")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Google.Common.Util.Concurrent;
2+
using Java.Lang;
3+
using Java.Util.Concurrent;
4+
5+
namespace GuavaSample
6+
{
7+
// Just ensure this compiles
8+
public class Future : Java.Lang.Object, IListenableFuture
9+
{
10+
public bool IsCancelled { get; set; }
11+
12+
public bool IsDone { get; set; }
13+
14+
public void AddListener(IRunnable p0, IExecutor p1)
15+
{
16+
17+
}
18+
19+
public bool Cancel(bool mayInterruptIfRunning) => true;
20+
21+
public Object Get() => null;
22+
23+
public Object Get(long timeout, TimeUnit unit) => null;
24+
}
25+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{FF3EDEBE-27B3-42E5-A713-9EA81CB5397A}</ProjectGuid>
9+
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
10+
<TemplateGuid>{122416d6-6b49-4ee2-a1e8-b825f31c79fe}</TemplateGuid>
11+
<OutputType>Library</OutputType>
12+
<AppDesignerFolder>Properties</AppDesignerFolder>
13+
<RootNamespace>GuavaSample</RootNamespace>
14+
<AssemblyName>GuavaSample</AssemblyName>
15+
<FileAlignment>512</FileAlignment>
16+
<Deterministic>True</Deterministic>
17+
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion>
18+
<AndroidClassParser>class-parse</AndroidClassParser>
19+
<IsPackable>false</IsPackable>
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
22+
<DebugSymbols>True</DebugSymbols>
23+
<DebugType>portable</DebugType>
24+
<Optimize>False</Optimize>
25+
<OutputPath>bin\Debug\</OutputPath>
26+
<DefineConstants>DEBUG;TRACE</DefineConstants>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
</PropertyGroup>
30+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
31+
<DebugSymbols>True</DebugSymbols>
32+
<DebugType>portable</DebugType>
33+
<Optimize>True</Optimize>
34+
<OutputPath>bin\Release\</OutputPath>
35+
<DefineConstants>TRACE</DefineConstants>
36+
<ErrorReport>prompt</ErrorReport>
37+
<WarningLevel>4</WarningLevel>
38+
</PropertyGroup>
39+
<ItemGroup>
40+
<Reference Include="System" />
41+
<Reference Include="System.Xml" />
42+
<Reference Include="System.Core" />
43+
<Reference Include="Mono.Android" />
44+
<Reference Include="System.Numerics" />
45+
<Reference Include="System.Numerics.Vectors" />
46+
</ItemGroup>
47+
<ItemGroup>
48+
<Compile Include="Future.cs" />
49+
<Compile Include="Properties\AssemblyInfo.cs" />
50+
</ItemGroup>
51+
<ItemGroup>
52+
<PackageReference Include="Xamarin.Google.Guava" Version="$(GuavaNuGetVersion)" />
53+
<PackageReference Include="Xamarin.Google.Guava.ListenableFuture" Version="$(GuavaListenableFutureNuGetVersion)" />
54+
<PackageReference Include="Xamarin.Google.Guava.FailureAccess" Version="$(GuavaFailureAccessNuGetVersion)" />
55+
</ItemGroup>
56+
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
57+
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using Android.App;
5+
6+
// General Information about an assembly is controlled through the following
7+
// set of attributes. Change these attribute values to modify the information
8+
// associated with an assembly.
9+
[assembly: AssemblyTitle("GuavaSample")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("GuavaSample")]
14+
[assembly: AssemblyCopyright("Copyright © 2018")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
[assembly: ComVisible(false)]
18+
19+
// Version information for an assembly consists of the following four values:
20+
//
21+
// Major Version
22+
// Minor Version
23+
// Build Number
24+
// Revision
25+
[assembly: AssemblyVersion("1.0.0.0")]
26+
[assembly: AssemblyFileVersion("1.0.0.0")]

Android/Guava/samples/NuGet.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="local-output" value="../output" />
5+
</packageSources>
6+
</configuration>
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
1+
<Project Sdk="Xamarin.Legacy.Sdk">
32
<PropertyGroup>
4-
<TargetFramework>monoandroid90</TargetFramework>
3+
<TargetFrameworks>net6.0-android30;monoandroid90</TargetFrameworks>
54
<IsBindingProject>true</IsBindingProject>
65
<AssemblyName>Xamarin.Google.Guava.FailureAccess</AssemblyName>
7-
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
8-
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
9-
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
10-
<AndroidUseIntermediateDesignerFile>True</AndroidUseIntermediateDesignerFile>
11-
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
126
<RootNamespace>Guava.FailureAccess</RootNamespace>
13-
<AndroidClassParser>class-parse</AndroidClassParser>
14-
<AndroidCodegenTarget>XAJavaInterop1</AndroidCodegenTarget>
157
<Java7DocPaths>..\..\externals\guava-failureaccess-javadocs\</Java7DocPaths>
168
</PropertyGroup>
179

@@ -32,20 +24,17 @@ Guava is a set of core libraries that includes new collection types (such as mul
3224
<PackageProjectUrl>https://go.microsoft.com/fwlink/?linkid=865028</PackageProjectUrl>
3325
<PackageLicenseUrl>https://go.microsoft.com/fwlink/?linkid=865030</PackageLicenseUrl>
3426
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
35-
<PackageVersion>1.0.1.2</PackageVersion>
27+
<PackageVersion>$(GuavaFailureAccessNuGetVersion)</PackageVersion>
3628
</PropertyGroup>
3729

3830
<ItemGroup>
39-
<None Include="Guava.FailureAccess.targets" Pack="True" PackagePath="build\$(TargetFramework)\$(PackageId).targets" />
40-
<None Include="Guava.FailureAccess.targets" Pack="True" PackagePath="buildTransitive\$(TargetFramework)\$(PackageId).targets" />
41-
<None Include="..\..\externals\guava-failureaccess.jar" Pack="True" PackagePath="build\$(TargetFramework)\guava-failureaccess.jar" />
42-
<None Include="..\..\externals\guava-failureaccess.jar" Pack="True" PackagePath="buildTransitive\$(TargetFramework)\guava-failureaccess.jar" />
31+
<None Include="Guava.FailureAccess.targets" Pack="True" PackagePath="@(_TfmNuGetBuildFolders->'%(Identity)$(PackageId).targets')" />
32+
<None Include="..\..\externals\guava-failureaccess.jar" Pack="True" PackagePath="jar" />
4333
<None Include="..\..\External-Dependency-Info.txt" Pack="True" PackagePath="THIRD-PARTY-NOTICES.txt" />
4434
</ItemGroup>
4535

4636
<ItemGroup>
4737
<InputJar Include="..\..\externals\guava-failureaccess.jar" />
48-
<TransformFile Include="Transforms.xml" />
4938
</ItemGroup>
5039

5140
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
4-
<AndroidJavaLibrary Include="$(MSBuildThisFileDirectory)*.jar" />
4+
<AndroidJavaLibrary Include="$(MSBuildThisFileDirectory)..\..\jar\*.jar" />
55
</ItemGroup>
66
</Project>

0 commit comments

Comments
 (0)