Skip to content

Commit d6eee9a

Browse files
committed
Merge branch 'main' into dev/grendel/blobs-in-lib
* main: [Xamarin.Android.build.Tasks] `<CheckDuplicateJavaLibraries/>` ignores `repackaged.jar` (#8664)
2 parents 8d1bb33 + 2cbb5c9 commit d6eee9a

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

src/Xamarin.Android.Build.Tasks/Tasks/CheckDuplicateJavaLibraries.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,12 @@ namespace Xamarin.Android.Tasks
99
{
1010
public class CheckDuplicateJavaLibraries : AndroidTask
1111
{
12-
readonly static string [] ExcludedFiles = new [] {
13-
"classes.jar",
14-
"r-classes.jar",
15-
};
16-
1712
public override string TaskPrefix => "CDJ";
1813

1914
public ITaskItem [] JavaSourceFiles { get; set; }
2015
public ITaskItem[] JavaLibraries { get; set; }
2116
public ITaskItem[] LibraryProjectJars { get; set; }
17+
public string [] ExcludedFiles { get; set; }
2218

2319
public override bool RunTask ()
2420
{

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -722,31 +722,45 @@ public void LibraryProjectZipWithLint ()
722722
}
723723

724724
/// <summary>
725-
/// Tests two .aar files with r-classes.jar
725+
/// Tests two .aar files with r-classes.jar, repackaged.jar
726726
/// </summary>
727727
[Test]
728-
public void AarWithRClassesJar ()
728+
public void CheckDuplicateJavaLibraries ()
729729
{
730730
var path = Path.Combine ("temp", TestName);
731731
var lib1 = new XamarinAndroidBindingProject {
732732
ProjectName = "Library1",
733733
AndroidClassParser = "class-parse",
734734
Jars = {
735+
// r-classes.jar
735736
new AndroidItem.LibraryProjectZip ("Library1.aar") {
736737
BinaryContent = () => ResourceData.Library1Aar
737-
}
738+
},
739+
// repackaged.jar
740+
new AndroidItem.AndroidLibrary ("emoji2-1.4.0.aar") {
741+
MetadataValues = "Bind=false",
742+
WebContent = "https://maven.google.com/androidx/emoji2/emoji2/1.4.0/emoji2-1.4.0.aar",
743+
},
738744
},
739745
};
740746
var lib2 = new XamarinAndroidBindingProject {
741747
ProjectName = "Library2",
742748
AndroidClassParser = "class-parse",
743749
Jars = {
750+
// r-classes.jar
744751
new AndroidItem.LibraryProjectZip ("Library2.aar") {
745752
BinaryContent = () => ResourceData.Library2Aar
746-
}
753+
},
754+
// repackaged.jar
755+
new AndroidItem.AndroidLibrary ("connect-client-1.1.0-alpha07.aar") {
756+
MetadataValues = "Bind=false",
757+
WebContent = "https://maven.google.com/androidx/health/connect/connect-client/1.1.0-alpha07/connect-client-1.1.0-alpha07.aar",
758+
},
747759
},
748760
};
749-
var app = new XamarinAndroidApplicationProject ();
761+
var app = new XamarinAndroidApplicationProject {
762+
SupportedOSPlatformVersion = "30", // androidx.health requires minSdkVersion="30"
763+
};
750764
app.AddReference (lib1);
751765
app.AddReference (lib2);
752766
using (var lib1Builder = CreateDllBuilder (Path.Combine (path, lib1.ProjectName)))

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,10 +843,17 @@ because xbuild doesn't support framework reference assemblies.
843843
</Target>
844844

845845
<Target Name="_CheckDuplicateJavaLibraries" DependsOnTargets="_GetLibraryImports">
846+
<ItemGroup>
847+
<_AndroidExcludedDuplicateJavaLibraries Include="classes.jar" />
848+
<_AndroidExcludedDuplicateJavaLibraries Include="r-classes.jar" />
849+
<_AndroidExcludedDuplicateJavaLibraries Include="repackaged.jar" />
850+
</ItemGroup>
846851
<CheckDuplicateJavaLibraries
847852
JavaSourceFiles="@(AndroidJavaSource)"
848853
JavaLibraries="@(AndroidJavaLibrary)"
849-
LibraryProjectJars="@(ExtractedJarImports)" />
854+
LibraryProjectJars="@(ExtractedJarImports)"
855+
ExcludedFiles="@(_AndroidExcludedDuplicateJavaLibraries)"
856+
/>
850857
</Target>
851858

852859
<Target Name="_LintChecks" Condition=" '$(AndroidLintEnabled)' == 'True' ">

0 commit comments

Comments
 (0)