ikvmnet / ikvm

A Java Virtual Machine and Bytecode-to-IL Converter for .NET
Other
1.17k stars 110 forks source link

How to point to internal maven repositories to resolve depencies? #395

Closed askids closed 12 months ago

askids commented 1 year ago

hi,

For resolving java package dependencies, documentation mentions not to copy the jar, but to use maven reference. Our builds are run in environment, which has no access to internet. So there is a local copy of the Nuget repos, Maven repos etc maintained by a central team. For dotnet packages, we can provide custom Nuget config files to resolve the feeds. So now, when we use maven reference, how do we provide the internal maven repository URL to resolve the dependencies?

Thanks!

wasabii commented 1 year ago

There are a number of MSBuild properties you can set on the project or globally:

<MavenDefaultRepositories Condition=" '$(MavenDefaultRepositories)' == '' ">central=https://repo1.maven.org/maven2/</MavenDefaultRepositories>
<MavenAdditionalRepositories Condition=" '$(MavenAdditionalRepositories)' == '' "></MavenAdditionalRepositories>
<MavenRepositories Condition=" '$(MavenRepositories)' == '' ">$(MavenDefaultRepositories);$(MavenAdditionalRepositories)</MavenRepositories>

Makes most sense to add additional repositories to MavenAdditionalRepositories, since that gets merged into the total set. But you can also replace the default set, or replace the overall set. The values are strings of comma seperated values of = seperated name url pairs.

Maven settings are also merged in from ~/.m2/settings.xml.

wasabii commented 1 year ago

When packing a .NET project that references Maven, the Pack logic will encode the MavenReferences into the .nupkg, and upon restore consider these transitive dependencies of any project that consumes the published NuGet package. But it won't put any custom repository settings into the .nupkg itself: so it's still the responsibility of the end user to ensure he has repositories referenced that would contain any dependencies.

wasabii commented 12 months ago

Assuming this question is answered and closing.