idris-jvm icon indicating copy to clipboard operation
idris-jvm copied to clipboard

Use as part of a Maven build

Open PhilAndrew opened this issue 5 years ago • 2 comments

Hello, this is really good, please keep working on this as I will use it in my project from now onwards.

So I want to build Idris JVM code as part of a maven build, since it calls idris like this

idris --portable-codegen jvm -p idrisjvmffi HelloWorld.idr -o target

I will use the Maven exec plugin to call idris exec from maven.

However I guess that Idris 2.0 can be built by this to be a JVM program, then in theory the Idris compiler could be a JVM program? If it was a JVM program then it could be more easily integrated into Maven builds as part of JVM.

PhilAndrew avatar Dec 20 '19 02:12 PhilAndrew

This is how I now compile Idris in Maven. Any suggestions how to improve?

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <longModulepath>false</longModulepath> <!-- Due to a bug https://github.com/mojohaus/exec-maven-plugin/issues/75 -->
          <!-- idris  - - portable-codegen jvm -p idrisjvmffi HelloWorld.idr -o target -->
          <executable>idris</executable>
          <workingDirectory>.</workingDirectory>
          <arguments>
            <!--<argument> - - ibcsubdir=ibr</argument>-->
            <argument>--idrispath=src/main/idris</argument>
            <argument>--portable-codegen</argument>
            <argument>jvm</argument>
            <argument>-p</argument>
            <argument>idrisjvmffi</argument>
            <argument>src/main/idris/HelloWorld.idr</argument>
            <argument>--cg-opt</argument>
            <argument>--classes-dir=target/classes</argument>
            <argument>-o</argument>
            <argument>idristarget</argument>
          </arguments>
        </configuration>
      </plugin>

PhilAndrew avatar Dec 20 '19 04:12 PhilAndrew

Hi,

Until we have native maven plugins for Idris, exec-maven-plugin is the only way. Regarding Idris 2, I was able to compile Idris 2 for the JVM and I've uploaded an initial release here (very much work in progress as Idris 2 itself) so as you said, the Idris 2 compiler can already run on the JVM. I am currently working on JVM back end for Idris 2 so once this is done, we will have Idris 2 compiler and Idris 2 compiler generated code both can run on the JVM.

mmhelloworld avatar Dec 20 '19 04:12 mmhelloworld

Idris 2 compiler can now run on the JVM along with.a JVM backend. I am closing this issue if that is okay as still exec-maven-plugin is the only way to run the compiler with Maven as of now. This repository itself does that as we can see from here https://github.com/mmhelloworld/idris-jvm/blob/main/idris-jvm-compiler/pom.xml#L118 which calls idris2 running on JVM through make.

mmhelloworld avatar Feb 27 '23 15:02 mmhelloworld