Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Tasks/Desugar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ protected override string GenerateCommandLineCommands ()

cmd.AppendSwitch ("--min_sdk_version ");
cmd.AppendSwitch (minApiVersion.ToString ());

if (minApiVersion < 24) {
cmd.AppendSwitch("--desugar_try_with_resources_omit_runtime_classes ");
}

//cmd.AppendSwitchIfNotNull ("-J-Dfile.encoding=", "UTF8");

Expand All @@ -85,6 +89,8 @@ protected override string GenerateCommandLineCommands ()
foreach (var jar in InputJars) {
var output = Path.Combine (OutputDirectory, BitConverter.ToString (md5.ComputeHash (Encoding.UTF8.GetBytes (jar))) + Path.GetFileName (jar));
outputs.Add (output);
cmd.AppendSwitch ("--classpath_entry ");
cmd.AppendFileNameIfNotNull (jar);
cmd.AppendSwitch ("--input ");
cmd.AppendFileNameIfNotNull (jar);
cmd.AppendSwitch ("--output ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2973,6 +2973,42 @@ public void Desugar (bool isRelease, bool enableDesugar, bool enableProguard)
EnableDesugar = enableDesugar,
EnableProguard = enableProguard,
};
//Okhttp and Okio
//https://github.com/square/okhttp
//https://github.com/square/okio
if (enableProguard) {
//NOTE: these are just enough rules to get it to build, not optimal
var rules = new [] {
"-dontwarn com.google.devtools.build.android.desugar.**",
"-dontwarn javax.annotation.**",
"-dontwarn org.codehaus.mojo.animal_sniffer.*",
};
//FIXME: We aren't de-BOM'ing proguard files?
var encoding = new UTF8Encoding (encoderShouldEmitUTF8Identifier: false);
var bytes = encoding.GetBytes (string.Join (Environment.NewLine, rules));
proj.OtherBuildItems.Add (new BuildItem ("ProguardConfiguration", "okhttp3.pro") {
BinaryContent = () => bytes,
});
}
proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "okio-1.13.0.jar") {
WebContent = "http://central.maven.org/maven2/com/squareup/okio/okio/1.13.0/okio-1.13.0.jar"
});
proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "okhttp-3.8.0.jar") {
WebContent = "http://central.maven.org/maven2/com/squareup/okhttp3/okhttp/3.8.0/okhttp-3.8.0.jar"
});
proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "retrofit-2.3.0.jar") {
WebContent = "http://central.maven.org/maven2/com/squareup/retrofit2/retrofit/2.3.0/retrofit-2.3.0.jar"
});
proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "converter-gson-2.3.0.jar") {
WebContent = "http://central.maven.org/maven2/com/squareup/retrofit2/converter-gson/2.3.0/converter-gson-2.3.0.jar"
});
proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "gson-2.7.jar") {
WebContent = "http://central.maven.org/maven2/com/google/code/gson/gson/2.7/gson-2.7.jar"
});
//Twitter SDK https://mvnrepository.com/artifact/com.twitter.sdk.android/twitter-core/3.3.0
proj.OtherBuildItems.Add (new BuildItem ("AndroidAarLibrary", "twitter-core-3.3.0.aar") {
WebContent = "http://repo.spring.io/libs-release/com/twitter/sdk/android/twitter-core/3.3.0/twitter-core-3.3.0.aar",
});
/* The source is simple:
*
public class Lambda
Expand Down