Skip to content

Commit

Permalink
Look for missing <dependency.version> in <dependencyManagement> section.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpobst committed Nov 4, 2024
1 parent 8b11bf8 commit cab13d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ static void FixDependency (BindingConfig config, MavenArtifactConfig mavenArtifa

var version = dependency.Version;

// If <version> was empty, look for a matching <dependencyManagement> entry
if (string.IsNullOrWhiteSpace (version)) {
var dep_man_dep = project.DependencyManagement?.Dependencies?.FirstOrDefault (d => d.GroupAndArtifactId () == dependency.GroupAndArtifactId ());

if (dep_man_dep is not null)
version = dep_man_dep.Version;
}

if (string.IsNullOrWhiteSpace (version))
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ public static string GetRelativePath (string filespec, string folder)

public static bool Satisfies (this Dependency dependency, string value)
{
if (!dependency.Version.HasValue ()) {
Console.WriteLine ($"{dependency.GroupId}:{dependency.ArtifactId} Version has no value");
dependency.Version = value;
}
if (!dependency.Version.HasValue ())
throw new Exception ("no value");

var version = MavenVersion.Parse (value);
var range = MavenVersionRange.Parse (dependency.Version);
Expand Down

0 comments on commit cab13d3

Please sign in to comment.