Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/blobs-in-lib
Browse files Browse the repository at this point in the history
* main:
  [Xamarin.Android.build.Tasks] `<CheckDuplicateJavaLibraries/>` ignores `repackaged.jar` (#8664)
  • Loading branch information
grendello committed Jan 24, 2024
2 parents 8d1bb33 + 2cbb5c9 commit d6eee9a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ namespace Xamarin.Android.Tasks
{
public class CheckDuplicateJavaLibraries : AndroidTask
{
readonly static string [] ExcludedFiles = new [] {
"classes.jar",
"r-classes.jar",
};

public override string TaskPrefix => "CDJ";

public ITaskItem [] JavaSourceFiles { get; set; }
public ITaskItem[] JavaLibraries { get; set; }
public ITaskItem[] LibraryProjectJars { get; set; }
public string [] ExcludedFiles { get; set; }

public override bool RunTask ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,31 +722,45 @@ public void LibraryProjectZipWithLint ()
}

/// <summary>
/// Tests two .aar files with r-classes.jar
/// Tests two .aar files with r-classes.jar, repackaged.jar
/// </summary>
[Test]
public void AarWithRClassesJar ()
public void CheckDuplicateJavaLibraries ()
{
var path = Path.Combine ("temp", TestName);
var lib1 = new XamarinAndroidBindingProject {
ProjectName = "Library1",
AndroidClassParser = "class-parse",
Jars = {
// r-classes.jar
new AndroidItem.LibraryProjectZip ("Library1.aar") {
BinaryContent = () => ResourceData.Library1Aar
}
},
// repackaged.jar
new AndroidItem.AndroidLibrary ("emoji2-1.4.0.aar") {
MetadataValues = "Bind=false",
WebContent = "https://maven.google.com/androidx/emoji2/emoji2/1.4.0/emoji2-1.4.0.aar",
},
},
};
var lib2 = new XamarinAndroidBindingProject {
ProjectName = "Library2",
AndroidClassParser = "class-parse",
Jars = {
// r-classes.jar
new AndroidItem.LibraryProjectZip ("Library2.aar") {
BinaryContent = () => ResourceData.Library2Aar
}
},
// repackaged.jar
new AndroidItem.AndroidLibrary ("connect-client-1.1.0-alpha07.aar") {
MetadataValues = "Bind=false",
WebContent = "https://maven.google.com/androidx/health/connect/connect-client/1.1.0-alpha07/connect-client-1.1.0-alpha07.aar",
},
},
};
var app = new XamarinAndroidApplicationProject ();
var app = new XamarinAndroidApplicationProject {
SupportedOSPlatformVersion = "30", // androidx.health requires minSdkVersion="30"
};
app.AddReference (lib1);
app.AddReference (lib2);
using (var lib1Builder = CreateDllBuilder (Path.Combine (path, lib1.ProjectName)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,17 @@ because xbuild doesn't support framework reference assemblies.
</Target>

<Target Name="_CheckDuplicateJavaLibraries" DependsOnTargets="_GetLibraryImports">
<ItemGroup>
<_AndroidExcludedDuplicateJavaLibraries Include="classes.jar" />
<_AndroidExcludedDuplicateJavaLibraries Include="r-classes.jar" />
<_AndroidExcludedDuplicateJavaLibraries Include="repackaged.jar" />
</ItemGroup>
<CheckDuplicateJavaLibraries
JavaSourceFiles="@(AndroidJavaSource)"
JavaLibraries="@(AndroidJavaLibrary)"
LibraryProjectJars="@(ExtractedJarImports)" />
LibraryProjectJars="@(ExtractedJarImports)"
ExcludedFiles="@(_AndroidExcludedDuplicateJavaLibraries)"
/>
</Target>

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

0 comments on commit d6eee9a

Please sign in to comment.