1

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.

Community
  • 1
  • 1
arunkumar
  • 32,803
  • 4
  • 32
  • 47

1 Answers1

2

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.

Paul Grime
  • 14,970
  • 4
  • 36
  • 58
  • +1 for the mvn org.mirah.maven..:compile suggestion. It downloaded the plugin and attempted to compile the mirah sources. The output of `mvn -X compile` is here in this [pastie](http://pastebin.com/2ty85HDE) since its a bit long. Now I just need to figure out how to call it with just `mvn compile`. – arunkumar Sep 09 '11 at 17:11
  • Sorry didn't see the update. Yes the maven-mirah-plugin works fine on its own. I'm just not able to figure out how to get it to work along side the Java code. I'll approve this answer if I don't see any other responses. At least it got me a step closer, thanks. – arunkumar Sep 10 '11 at 20:56
  • Hmm, if I were you I'd strip your project to the bare bones and try again, adding one thing each time until it stops working. – Paul Grime Sep 10 '11 at 21:04
  • Well it is pared to the bone. I created the android archetype added no other code or configuration then added the maven plugin, thats all. Maybe I can start with a working maven-mirah version and then try and add android and java to it. I will post back on how that goes. – arunkumar Sep 10 '11 at 21:10