Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 643cbc2

Browse files
authored
[binderator] Fix for POM versions that use properties. (#1273)
1 parent af495b0 commit 643cbc2

4 files changed

Lines changed: 33 additions & 7 deletions

File tree

Util/Xamarin.AndroidBinderator/Xamarin.AndroidBinderator.Tool/Xamarin.AndroidBinderator.Tool.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<PropertyGroup>
1414
<PackageId>Xamarin.AndroidBinderator.Tool</PackageId>
15-
<PackageVersion>0.4.9</PackageVersion>
15+
<PackageVersion>0.5.0</PackageVersion>
1616
<Title>Xamarin Android Binderator</Title>
1717
<PackageDescription>A tool for generating Xamarin.Android Binding projects from Razor templates and Maven Repository data.</PackageDescription>
1818
<PackageProjectUrl>https://go.microsoft.com/fwlink/?linkid=2100525</PackageProjectUrl>

Util/Xamarin.AndroidBinderator/Xamarin.AndroidBinderator/Engine.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ static List<BindingProjectModel> BuildProjectModels(BindingConfig config, Dictio
324324
if (!ShouldIncludeDependency(config, mavenArtifact, mavenDep, exceptions))
325325
continue;
326326

327-
mavenDep.Version = FixVersion(mavenDep.Version);
327+
mavenDep.Version = FixVersion(mavenDep.Version, mavenProject);
328328

329329
var depMapping = config.MavenArtifacts.FirstOrDefault(
330330
ma => !string.IsNullOrEmpty(ma.Version)
@@ -477,11 +477,28 @@ static Dictionary<string, string> MergeValues(Dictionary<string, string> dest, D
477477
// VersionRange.Parse cannot handle single number versions that we sometimes see in Maven, like "1".
478478
// Fix them to be "1.0".
479479
// https://github.com/NuGet/Home/issues/10342
480-
static string FixVersion(string version)
480+
static string FixVersion(string version, Project project)
481481
{
482482
if (string.IsNullOrWhiteSpace(version))
483483
return version;
484484

485+
// Handle versions with Properties, like:
486+
// <properties>
487+
// <java.version>1.8</java.version>
488+
// <gson.version>2.8.6</gson.version>
489+
// </properties>
490+
// <dependencies>
491+
// <dependency>
492+
// <groupId>com.google.code.gson</groupId>
493+
// <artifactId>gson</artifactId>
494+
// <version>${gson.version}</version>
495+
// </dependency>
496+
// </dependencies>
497+
if (project?.Properties != null) {
498+
foreach (var prop in project.Properties.Any)
499+
version = version.Replace($"${{{prop.Name.LocalName}}}", prop.Value);
500+
}
501+
485502
if (!version.Contains("."))
486503
version += ".0";
487504

Util/Xamarin.AndroidBinderator/Xamarin.AndroidBinderator/MavenFactory.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,17 @@ public static async Task Initialize(BindingConfig config)
2222
artifact_mavens.Add((repo, artifact));
2323
}
2424

25-
foreach (var group in artifact_mavens.GroupBy(a => a.Item1))
26-
await group.Key.Refresh(group.Select (g => g.Item2.GroupId).Distinct().ToArray());
25+
foreach (var maven_group in artifact_mavens.GroupBy(a => a.Item1)) {
26+
var maven = maven_group.Key;
27+
var artifacts = maven_group.Select(a => a.Item2);
28+
29+
foreach (var artifact_group in artifacts.GroupBy(a => a.GroupId)) {
30+
var gid = artifact_group.Key;
31+
var artifact_ids = artifact_group.Select(a => a.ArtifactId).ToArray();
32+
33+
await maven.Populate(gid, artifact_ids);
34+
}
35+
}
2736
}
2837

2938
public static MavenRepository GetMavenRepository(BindingConfig config, MavenArtifactConfig artifact)

Util/Xamarin.AndroidBinderator/Xamarin.AndroidBinderator/Xamarin.AndroidBinderator.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<PropertyGroup>
11-
<PackageVersion>2.2.9</PackageVersion>
11+
<PackageVersion>2.3.0</PackageVersion>
1212
<PackageId>Xamarin.AndroidBinderator</PackageId>
1313
<Title>Xamarin.AndroidBinderator</Title>
1414
<PackageDescription>An engine to generate Xamarin Binding projects from Maven repositories with a JSON config and razor templates.</PackageDescription>
@@ -23,7 +23,7 @@
2323

2424
<ItemGroup>
2525
<PackageReference Include="RazorLight" Version="2.0.0-beta1" />
26-
<PackageReference Include="MavenNet" Version="2.2.12" />
26+
<PackageReference Include="MavenNet" Version="2.2.13" />
2727
</ItemGroup>
2828

2929
<ItemGroup>

0 commit comments

Comments
 (0)