Question

I have created a maven android project using this archetype. I want to integrate mirah source files inside my project. So I added the plugin mentioned here to my pom.xml. I setup the configuration section for the plugin to point the source directory to src/main/mirah.

But when I run mvn compile it only compiles the sources inside src/main/java. I have tried running it with mvn -X compile to try and debug the issue, but I can't find anything related to mirah or the mirah-maven-plugin there.

Using the archetype it created two projects - project and project-it (tests) , there is a pom.xml in the root directory as well as a pom.xml in project and project-it directories. I have tried the above configurations in both the root directory as well as in project's pom.xml.

I have come across this question related to using the build-helper plugin but I don't know if it will help in my case. Since my mirah plugin isn't getting called at all.

Is this the right way to do what I'm trying to do? Any help on the setup, or pointer to how to troubleshoot this would be much appreciated.

The relevant bit of my pom.xml

<plugin>
   <groupId>org.mirah.maven</groupId>
   <artifactId>maven-mirah-plugin</artifactId>
   <version>1.0</version>
   <configuration>
       <sourceDirectory>src/main/mirah</sourceDirectory>
       <outputDirectory>target/classes</outputDirectory>
       <bytecode>true</bytecode>
       <verbose>false</verbose>
   </configuration>
   <executions>
      <execution>
         <phase>compile</phase>
         <goals><goal>compile</goal></goals>
      </execution>
   </executions>
</plugin>

Edited as per answer below.

I have added the source directory using the build-helper plugin and I'm able to get the mirah sources to compile using mvn org.mirah.maven:maven-mirah-plugin:1.0:compile from the answer below. But mvn compile still only compiles the sources in src/main/java and not src/main/mirah.

For anyone interested in the output of mvn -X compile here is the pastie.

Was it helpful?

Solution

This page https://github.com/calavera/maven-mirah-plugin#readme says that the mirah plugin extends the default compiler plugin. So this would suggest that the build helper plugin would work for multiple source directories, if it works for the default compiler plugin.

Looking at the mirah plugin, you probably don't need to specify sourceDirectory and outputDirectory yourself, as it seems you're using the defaults.

The -X switch won't have any impact on the mirah plugin directly, as it doesn't do any tracing itself (above what the default compiler plugin does).

Can you show your -X output anyway to show that the mirah plugin isn't invoked?

Alternatively, you could build the mirah plugin yourself and add tracing. It doesn't seem a complicated plugin.

What happens when you try and invoke the plugin directly? E.g.

mvn org.mirah.maven:maven-mirah-plugin:1.0:compile

EDIT:

Tried it myself and this works for me (by 'works' I mean the plugin gets invoked - my build actually fails).

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>temp</groupId>
    <artifactId>temp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.mirah.maven</groupId>
                <artifactId>maven-mirah-plugin</artifactId>
                <version>1.0</version>
                <configuration>
                    <bytecode>true</bytecode>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

With this output:

D:\dev\workspaces\3.6\temp>mvn compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - temp:temp:jar:0.0.1-SNAPSHOT
[INFO]    task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [mirah:compile {execution: default}]
[INFO] No sources to compile
Parsing...
  D:\dev\workspaces\3.6\temp\src\main\mirah/test.mirah
Inferring types...
* [Mirah::Typer] Learned local type under #<Mirah::AST::StaticScope:0xbc5245> : a = Type(int)

... ETC ...

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unknown error - Unknown Error (20047) - D:\dev\workspaces\3.6\temp\target\classes\D:

I don't know what the error means as I'm not a mirah user.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top