ikvmnet / ikvm-maven

Support for adding dependencies on Maven artifacts to .NET projects, using IKVM.
MIT License
53 stars 5 forks source link

Version is supposed to be optional in Maven, but is required by IkvmReference #15

Closed NightOwl888 closed 2 years ago

NightOwl888 commented 2 years ago

As was reported in #2 and https://github.com/ikvm-revived/ikvm/issues/169, Maven doesn't always include dependencies that are "required" in .NET.

However, when adding these "extra" dependencies to a project, it is very difficult to work out what version of the dependency we are supposed to include. A POM project would simply exclude the <version> element and let Maven figure it out, but we can't do that because of validation requiring a version number on IkvmReference.

    <MavenReference Include="commons-logging:commons-logging">
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
    </MavenReference>
Rebuild started...
1>------ Rebuild All started: Project: IKVM-GH-169, Configuration: Debug Any CPU ------
Restored F:\Users\shad\source\repos\IKVM-GH-169\IKVM-GH-169\IKVM-GH-169.csproj (in 60 ms).
1>F:\Users\shad\.nuget\packages\ikvm.maven.sdk\1.0.1\buildTransitive\netstandard2.0\IKVM.Maven.Sdk.targets(48,9): error MAVEN0007: Missing Maven version.
1>Done building project "IKVM-GH-169.csproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
wasabii commented 2 years ago

The restriction is on MavenReference, as the error mentions.

Is it not the case that a dependency node requires a version?

Also, the dependencies are never "required in .NET". They are required if you attempt to use them, though.

If 'version' on a maven dependency coordinate isn't required, then yeah, we should remove the requirement. I sure thought it was though.

NightOwl888 commented 2 years ago

Maven Coordinates

The POM defined above is the bare minimum that Maven allows. groupId:artifactId:version are all required fields (although, groupId and version do not need to be explicitly defined if they are inherited from a parent - more on inheritance later). The three fields act much like an address and timestamp in one. This marks a specific place in a repository, acting like a coordinate system for Maven projects

Looks like I was confused by the fact that some POM files use inheritance to derive the <version>, thus being able to exclude the element in those cases. But at the end of the day, it is a required field.