Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added --classpath_entry for Desugar #2158

Merged
merged 7 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from 6 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);
jonathanpeppers marked this conversation as resolved.
Show resolved Hide resolved
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,41 @@ 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 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