Find the default phase that a Maven plugin binds to - java

Given a <plugin> element in a pom.xml, how do I find the default phase that it binds to?
For example, I'd like to know which phase of the Maven lifecycle does the maven-war-plugin gets executed.

The best way to see what's really happening in your project along those lines is with mvn help:effective-pom. It doesn't just show the defaults; it shows what actually is according to your current pom.

I'm having a problem with the above-reply.
Here's a simple pom. It uses an annotation processor plugin, which is bound to generate-sources by-default, since I didn't specify a <phase>.
<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>com.test</groupId>
<artifactId>test-simple</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.5</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
mvn generate-resources does indeed invoke the plugin...
$ mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test-simple 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-processor-plugin:2.0.5:process (default) # test-simple ---
Yet scanning the output of mvn help:effective-pom doesn't yield any clue to the default binding of this plugin.
$ mvn help:effective-pom |grep generate-sources; echo $?
1
The only way I've so-far found to list default phase binding is by examining plugin source.

Related

Could not find goal 'devmode' in plugin org.codehaus.mojo

I am a beginner in GWT and Maven. I created a new GWT Application project in Eclipse. Then, I converted that project into Maven Project by right-click on Project name => Configure => Convert to Maven Project and I saw that a pom file was generated for that project. Next, I run as project as Maven build but it was not compiled since a goal was not specified there. Actually, I don't understand what exactly have I to write under that goal section, therefore, I wrote package under that and then again I built maven and it compiled successfully.
After that, I tried to run this maven project in Command Prompt on the SuperDevMode using the 2nd step mentioned on Run the GWT Project under the Setting up a new project section. But while following these steps on Command Prompt, I got an error that devmode could not be found. Here is my Command prompt log:
C:\Users\TEST>cd eclipse-workspace/MyWebApp
C:\Users\TEST\eclipse-workspace\MyWebApp>mvn war:exploded
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenApp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-war-plugin:3.1.0:exploded (default-cli) # abcdef ---
[INFO] Exploding webapp
[INFO] Assembling webapp [abcdef] in [C:\Users\TEST\eclipse-workspace\MyWebApp\target\abcdef-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Webapp assembled in [63 msecs]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.920 s
[INFO] Finished at: 2017-08-30T11:24:53+05:30
[INFO] Final Memory: 12M/107M
[INFO] ------------------------------------------------------------------------
C:\Users\TEST\eclipse-workspace\MyWebApp>mvn gwt:devmode
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.301 s
[INFO] Finished at: 2017-08-30T11:25:02+05:30
[INFO] Final Memory: 8M/107M
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'devmode' in plugin org.codehaus.mojo:gwt-maven-plugin:2.8.1 among available goals clean, compile, compile-report, css, debug, eclipse, eclipseTest, generateAsync, help, i18n, mergewebxml, resources, run, run-codeserver, source-jar, test -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException
Here is my pom.xml file:
<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>MyWebApp</groupId>
<artifactId>abcdef</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<name>MavenApp</name>
<description>It is a maven app</description>
</project>
I searched a lot to resolve this error but found no solution for that issue. Please help me to fix this issue as I am very confused on how to fix it.
Edit: After further study, I used mvn gwt:run as an alternative to the command mvn gwt:devmode, but still I got another error on command prompt as given below:
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.8.1:run (default-cli) on project MyWebApp: The parameters 'runTarget' for goal org.codehaus.mojo:gwt-maven-plugin:2.8.1:run are missing or invalid
Without any more information than gwt:devmode, Maven will try to find an appropriate plugin, based on its default settings. It happens that a gwt-maven-plugin exists with org.codehaus.mojo as groupId, fitting in Maven built-in plugin resolution.
But this is not the plugin you're looking for.
You are probably trying to use this one, so just add this to your pom.xml, in the <plugins> section:
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-8</version>
<extensions>true</extensions>
<configuration>
<moduleName>com.example.app.App</moduleName>
</configuration>
</plugin>
Adapting the moduleName if needed.
Well, I was able to solve this issue by copying some dependencies, plugin, and configuration from the pom.xml file (which is generated in the project created by the webAppCreator using maven) to the pom.xml file of my project created in the Eclipse. So, this is my pom.xml file created finally:
<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>MyPersonalProject</groupId>
<artifactId>MyPersonalProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<!-- Setting maven.compiler.source to something different to 1.8
needs that you configure the sourceLevel in gwt-maven-plugin since
GWT compiler 2.8 requires 1.8 (see gwt-maven-plugin block below) -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- Don't let your Mac use a crazy non-standard encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<!-- ensure all GWT deps use the same version (unless overridden) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.8.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-6</version>
<executions>
<execution>
<goals>
<goal>import-sources</goal>
<goal>compile</goal>
<goal>import-test-sources</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<moduleName>mypackage.MyPersonalproject</moduleName>
<failOnError>true</failOnError>
<!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if you use
a different source language for java compilation -->
<sourceLevel>1.8</sourceLevel>
<!-- Compiler configuration -->
<compilerArgs>
<!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
<arg>-compileReport</arg>
<arg>-XcompilerMetrics</arg>
</compilerArgs>
<!-- DevMode configuration -->
<warDir>${project.build.directory}/${project.build.finalName}</warDir>
<classpathScope>compile+runtime</classpathScope>
<!-- URL(s) that should be opened by DevMode (gwt:devmode). -->
<startupUrls>
<startupUrl>MyPersonalProject.html</startupUrl>
</startupUrls>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I run this application using maven in the Command Prompt, it ran successfully except showing 2 or 3 warnings in the Command Prompt log. Also, I noticed that the SNAPSHOT generated in the version is different for the pom.xml created by Eclipse as compared to the one created by the maven project on command prompt.

Automatically executing dependency:build-classpath in maven

I am literally trying to do exactly this:
http://maven.apache.org/plugins/maven-dependency-plugin/usage.html#The_dependency:build-classpath_mojo
What's amazing is that after finding an explicit example of exactly what I want Maven to do.. I still can't get it to work.
From the command line, I can run ...
mvn -Dmdep.outputFile=classpath.txt dependency:build-classpath
... which does indeed produce a file called classpath.txt with the information I'd like.
I would like to be able to issue a command like "mvn compile" and have the production of this classpath.txt file be a part of that process. The example provided at the link above associates it with generate-sources, which to my understanding should suffice.
When executing a command like "mvn compile" with this pom snippet below, nothing regarding the build-classpath goal seems to execute.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>build-classpath</id>
<phase>generate-sources</phase>
<goals>
<goal>build-classpath</goal>
</goals>
<configuration>
<outputFile>myfile.txt</outputFile>
<mdep.outputFile>myFile1.txt</mdep.outputFile>
<ihavenoidea>whatgoeshere</ihavenoidea>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
And here is what I end up with:
$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building someproj 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # someproj ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # someproj ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.600s
[INFO] Finished at: Fri Jan 31 14:05:29 CST 2014
[INFO] Final Memory: 9M/156M
[INFO] ------------------------------------------------------------------------
$ ls
bin html log pom.xml resources sql src target test-output wwwroot
Your plugin definition is inside <pluginManagement>, which means that when you will declare a "real" execution of that plugin inside a pom that has this pom as parent (or this pom itself), it will use that configuration.
This is generaly a good idea to use <pluginManagement> when a common configuration has to be applied on multiple execution, through multiple modules in the same global project.
Here, I would personally keep the compiler plugin inside <pluginManagement>, as you probably always want that plugin to be configured like this, but I woul move the dependency-plugin inside the <plugins> section (outside the <pluginManagement> section, well yes, this can be confusive...)
You may think of <pluginManagement> as a kind of template. It's often used in parent POMs to define a common configuration. Only plugins in <build><plugins> are included in the build.
That said, Maven does do some "magic" depending on the packaging type. I answered a similar question here.

Maven Not Downloading Plugin

I'm trying to set up Maven on a node project I'm working on for build reasons. I've added the following minimal pom.xml file to the project:
<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>project.id</groupId>
<artifactId>project-title</artifactId>
<version>0.0.1</version>
<name>project-name</name>
<description>Project Description</description>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<!--<executable>npm start</executable> -->
<executable>echo 'HELLO'</executable>
</configuration>
</plugin>
</plugins>
</build>
</project>
However, now when I run mvn install it starts, begins to download the plugin but never finishes. Here is the command and console:
$ mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building project-name 0.0.1
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/org/codehaus/mojo/exec-maven-plugin/1.2.1/exec-maven-plugin-1.2.1.pom
Now when I curl or visit the address, I can see the xml file perfect. Can anyone give me any direction on how to head from here? I'm using Maven 3.1.1 and Java 7.
Check your settings.xml file, which Maven looks for in the following locations and order:
$HOME/.m2/settings.xml
$M2_HOME/conf/settings.xml
There is a section in the settings.xml file for proxies and mirrors, which may be why you're seeing inconsistent bhavior between curl and mvn
EDIT
See Maven docs on settings.xml for more details:
<proxies>
<proxy>
<id>myproxy</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy.somewhere.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
</proxy>
</proxies>
In some cases it takes long time for maven to understand network problems. I saw situations when it "hangs" for 15 minutes on secured network without proper config for proxy.
I didn't use curl, but I wonder if it can use system proxy settings? Maven should be configured separately, he doesn't understand them.

Maven exec:java goal on a multi-module project

I'm trying to run exec-maven-plugin's exec:java goal on a simple two-module project where one module depends on the other. So far I can't find a configuration that works. Here's a boiled-down test case:
+ exec-multi-module-test/
+ pom.xml
+ module1/
+ pom.xml
+ src/
+ main/
+ java/
+ HelloPrinter.java
+ module2/
+ pom.xml
+ src/
+ main/
+ java/
+ MyMain.java
Here's the parent pom:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.mkscrg.sandbox</groupId>
<artifactId>exec-multi-module-test</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
<module>module2</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
</plugin>
</plugins>
</build>
</project>
module1's pom:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>exec-multi-module-test</artifactId>
<groupId>com.mkscrg.sandbox</groupId>
<version>1.0</version>
</parent>
<artifactId>module1</artifactId>
</project>
module2's pom:
4.0.0
<parent>
<artifactId>exec-multi-module-test</artifactId>
<groupId>com.mkscrg.sandbox</groupId>
<version>1.0</version>
</parent>
<artifactId>module2</artifactId>
<dependencies>
<dependency>
<groupId>com.mkscrg.sandbox</groupId>
<artifactId>module1</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
This project compiles successfully from the top, but running mvn exec:java -Dexec.mainClass=myMain fails:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] exec-multi-module-test
[INFO] module1
[INFO] module2
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building exec-multi-module-test 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) # exec-multi-module-test >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) # exec-multi-module-test <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) # exec-multi-module-test ---
[WARNING]
java.lang.ClassNotFoundException: MyMain
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:680)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] exec-multi-module-test ............................ FAILURE [0.363s]
[INFO] module1 ........................................... SKIPPED
[INFO] module2 ........................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.566s
[INFO] Finished at: Mon Jun 18 14:11:54 PDT 2012
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project exec-multi-module-test: An exception occured while executing the Java class. MyMain -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
What's the right way to configure this project to allow exec:java to see MyMain?
EDIT: Here's a gist if you'd like to try this yourself: https://gist.github.com/2950830
EDIT: Clarification: I know it's possible to mvn install and then either run exec:java from module2's directory or use the -pl flag from the top. However, I'd like to avoid running mvn install. It shouldn't be necessary to modify my local repository in order to run this goal in a multi-module project. Just as mvn compile "just works" with a multi-module project, so should other goals/phases.
Goals in a multi-module project, when run from the parent, will run against all modules. I don't think that's what you want. You can try:
mvn exec:java -pl module2 -Dexec.mainClass=MyMain
That might work? More info:
Running a specific Maven plugin goal from the command line in a sub-module of a multi-module reactor project
However, I think it's more intuitive to change directory to the sub-module containing the executable before running it.
You should bind the exec-maven-plugin to a maven lifecycle goal, say verify.
Since you want the plugin to be executed only for module2, define the plugin configurations in the parent pom within pluginManagement. Use the same only in module 2.
Then run the following:
mvn verify -Dexec.mainClass=MyMain.
parent pom
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
module 2
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
See this answer for a single-command alternative without mvn install:
https://stackoverflow.com/a/26448447/1235281
By using skip in the parent pom.xml, you can tell Maven to only run exec:java on a specific submodule.
GitHub:
https://github.com/Oduig/mavenfiddle

Maven android compiling multiple source directories

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.
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.

Categories

Resources