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

[Xamarin.Android.build.Tasks] <CheckDuplicateJavaLibraries/> ignores repackaged.jar #8664

Merged
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
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 @@ -842,10 +842,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
Loading