ikvmnet / ikvm

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

Generating stubs as an MSBuild task? #286

Closed Oliver-makes-code closed 1 year ago

Oliver-makes-code commented 1 year ago

I've set up dotnet to build a gradle project and include it's output JAR in the dotnet build, so I can use Kotlin with a C# project, but in order to properly interop the two, it'd be nice if I could automatically generate the stub when building

Here's the relevant parts of my current csproj file:

  <ItemGroup>
    <PackageReference Include="ikvm" Version="8.4.4" />
    <IkvmReference Include="build/libs/output.jar" />
  </ItemGroup>

  <Target Name="Gradle" BeforeTargets="BeforeBuild">
    <!-- I'd like to generate stub here -->
    <Exec Command="./gradlew build" />
  </Target>
wasabii commented 1 year ago

So I thought about this once, but pretty much decided MSBuild was the wrong place to put it. It probably more likely should be in Gradle for this usage. After all, Gradle is the build system you're using for Java.

That said, IKVM.Net.SDK does do this, since it builds Java classes directly.

And there is a MSBuild Task for it.

Oliver-makes-code commented 1 year ago

And there is a MSBuild Task for it.

What is the task for it? I can't find it

wasabii commented 1 year ago

https://github.com/ikvm-revived/ikvm/blob/develop/src/IKVM.MSBuild.Tasks/IkvmExporter.cs

Exposed as <IkvmExporter /> in the IKVM.MSBuild package. Beware about using these tasks outside IKVM itself. Though you can, we provide no guarantees as to their stability, etc. We might rename them, change their properties, etc, without notice, as suites our own purposes for IKVM and IKVM.NET.Sdk.