forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] Fix @(JavaDocJar) (dotnet#5479)
Fixes: dotnet#2745 Issue dotnet#2745 noted that `@(JavaDocJar)` didn't work; attempting to use it would result in an MSB3375 error: …/Xamarin.Android.Bindings.Documentation.targets(31,5): error MSB3375: The file "obj/Debug/javadocs/glide-3.7.0-javadoc.stamp" does not exist. This issue was subsequently hidden by 380e95e, which disabled the `_ExtractJavaDocJars` target unless JDK 1.8 was being used. There were two problems with 380e95e: 1. The `_ExtractJavaDocJars` target didn't need to be disabled! It just unzips the `.jar`; it does not require JDK 1.8. 2. The check for JDK 1.8 was bad, and was *never* True. The only documentation-related functionality that needed to be disabled because of JDK 11 was `@(JavaSourceJar)`, which got a better fix in commits a7413a2 and 0e95ec7 [not relevant for d16-9]. Fix the `_ExtractJavaDocJars` target so that it properly runs when there are any `@(JavaDocJar)` items, then fix the `_ExtractJavaDocJars` target so that it doesn't emit an MSB3375 error. Note: `@(JavaDocJar)` is still problematic: it involves parsing Javadoc HTML, which contains numerous "dialects" (it's why the JDK 11 commit skipped `@(JavaSourceJar)` support: trying to update our HTML scrapers was "too fiddly"). Deprecate `@(JavaDocJar)`. Fix the `$(_JavadocSupported)` test so that it is no longer always false, by moving it's definition into a `_GetJavadocSupported` target. This allows `$(_JdkVersion)` to be interpreted *after* it is set. Update the `BindingBuildTest.cs` infrastructure so that instead of having `.jar` files encoded in Base64, we instead use `@(EmbeddedResource)`s for the `.jar` files. A new `UpdateResources` target will update the appropriate `.jar` files.
- Loading branch information
Showing
14 changed files
with
195 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
### Issues fixed | ||
|
||
* [GitHub 2745](https://github.com/xamarin/xamarin-android/issues/2745): | ||
The `@(JavaDocJar)` build action would either cause an MSB3375 error, | ||
or wasn't used at all. | ||
|
||
#### Deprecation of JavaDocJar Build action in favor of JavaSourceJar | ||
|
||
The `@(JavaDocJar)` Build action is deprecated, and will not work in .NET 6. | ||
Please use the `@(JavaSourceJar)` build action. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Directory.Build.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<Project> | ||
|
||
<Target Name="UpdateResources" | ||
DependsOnTargets="_UpdateJavaSourceJar_Bytecode;_UpdateJavaSourceJar_Sources;_UpdateJavaSourceJar_Javadoc"> | ||
</Target> | ||
|
||
<ItemGroup> | ||
<JavaSourceJarTest Include="java/com/microsoft/android/test/msbuildtest/JavaSourceJarTest.java" /> | ||
</ItemGroup> | ||
|
||
<Target Name="_UpdateJavaSourceJar_Bytecode" | ||
Inputs="@(JavaSourceJarTest)" | ||
Outputs="Resources\javasourcejartest.jar"> | ||
<PropertyGroup> | ||
<_SourceVersions>-source $(JavacSourceVersion) -target $(JavacTargetVersion)</_SourceVersions> | ||
<_Outdir>$(IntermediateOutputPath)/classes</_Outdir> | ||
</PropertyGroup> | ||
<MakeDir Directories="$(_Outdir)" /> | ||
<!-- Note: do NOT include `-parameters`; we want parameter name inferrence via -sources or -javadoc --> | ||
<Exec Command="$(JavaCPath) $(_SourceVersions) -d $(_Outdir) @(JavaSourceJarTest, ' ')" /> | ||
<Exec | ||
Command="$(JarPath) cf Resources/javasourcejartest.jar -C $(_Outdir) ." | ||
WorkingDirectory="$(MSBuildThisFileDirectory)" | ||
/> | ||
</Target> | ||
|
||
<Target Name="_UpdateJavaSourceJar_Sources" | ||
Inputs="@(JavaSourceJarTest)" | ||
Outputs="Resources\javasourcejartest-sources.jar"> | ||
<Exec | ||
Command="$(JarPath) cf Resources/javasourcejartest-sources.jar -C java ." | ||
WorkingDirectory="$(MSBuildThisFileDirectory)" | ||
/> | ||
</Target> | ||
|
||
<Target Name="_UpdateJavaSourceJar_Javadoc" | ||
Inputs="@(JavaSourceJarTest)" | ||
Outputs="Resources/javasourcejartest-javadoc.jar"> | ||
<PropertyGroup> | ||
<_Javadoc>"$(Java8SdkDirectory)/bin/javadoc"</_Javadoc> | ||
<_Outdir>$(IntermediateOutputPath)/javadoc</_Outdir> | ||
</PropertyGroup> | ||
<MakeDir Directories="$(_Outdir)" /> | ||
<Exec | ||
Command="$(_Javadoc) -public -d "$(_Outdir)" @(JavaSourceJarTest, ' ')" | ||
WorkingDirectory="$(MSBuildThisFileDirectory)" | ||
/> | ||
<Exec | ||
Command="$(JarPath) cf Resources/javasourcejartest-javadoc.jar -C "$(_Outdir)" ." | ||
WorkingDirectory="$(MSBuildThisFileDirectory)" | ||
/> | ||
</Target> | ||
|
||
</Project> |
Binary file added
BIN
+389 KB
...oid.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Resources/javasourcejartest-javadoc.jar
Binary file not shown.
Binary file added
BIN
+1.42 KB
...oid.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Resources/javasourcejartest-sources.jar
Binary file not shown.
Binary file added
BIN
+1.51 KB
...rin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Resources/javasourcejartest.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ResourceData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Xamarin.Android.Build.Tests | ||
{ | ||
static class ResourceData | ||
{ | ||
static Lazy<byte[]> javaSourceJarTestJar = new Lazy<byte[]>(() => GetResourceData ("javasourcejartest.jar")); | ||
static Lazy<byte[]> javaSourceJarTestSourcesJar = new Lazy<byte[]>(() => GetResourceData ("javasourcejartest-sources.jar")); | ||
static Lazy<byte[]> javaSourceJarTestJavadocJar = new Lazy<byte[]>(() => GetResourceData ("javasourcejartest-javadoc.jar")); | ||
|
||
public static byte[] JavaSourceJarTestJar => javaSourceJarTestJar.Value; | ||
public static byte[] JavaSourceJarTestSourcesJar => javaSourceJarTestSourcesJar.Value; | ||
public static byte[] JavaSourceJarTestJavadocJar => javaSourceJarTestJavadocJar.Value; | ||
|
||
static byte[] GetResourceData (string name) | ||
{ | ||
using (var s = typeof (InlineData).Assembly.GetManifestResourceStream (name)) | ||
using (var m = new MemoryStream (checked ((int) s.Length))) { | ||
s.CopyTo (m); | ||
return m.ToArray (); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...in.Android.Build.Tests/java/com/microsoft/android/test/msbuildtest/JavaSourceJarTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.xamarin.android.test.msbuildtest; | ||
|
||
public class JavaSourceJarTest | ||
{ | ||
/** | ||
* Returns greeting message. | ||
* <p> | ||
* Returns "Morning, ", "Hello, " or "Evening, " with name argument, | ||
* depending on the argument hour. | ||
* </p> | ||
* @param name name to display. | ||
* @param date time to determine the greeting message. | ||
* @return the resulting message. | ||
*/ | ||
public String greet (String name, java.util.Date date) | ||
{ | ||
String head = date.getHours () < 11 ? "Morning, " : date.getHours () < 17 ? "Hello, " : "Evening, "; | ||
return head + name; | ||
} | ||
} |