Maven plugin to execute and package Micronaut applications.

It watches for changes in the project tree. If there are changes in the pom.xml file, dependencies will be reloaded. If the changes are anywhere underneath src/main, it will recompile the project and restart the application.

The plugin can handle changes in all the languages supported by Micronaut: Java, Kotlin and Groovy.

Usage

Add the plugin to your build/plugins section:

<project>

    <!-- ... -->

    <build>
        <plugins>

            <!-- ... -->

            <plugin>
                <groupId>io.micronaut.build</groupId>
                <artifactId>micronaut-maven-plugin</artifactId>
                <version>1.0.0.BUILD-SNAPSHOT</version>
            </plugin>
        </plugins>
    </build>
</project>

For snapshot versions, you need the Sonatype OSSRH Snapshot repository:

<project>

    <!-- ... -->

    <pluginRepositories>

        <!-- ... -->

        <pluginRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</project>

Then, you can use mn:run to run your application in development mode:

$ mvn clean mn:run

[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< java.maven.junit:java-maven-junit >------------------
[INFO] Building java-maven-junit 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ java-maven-junit ---
[INFO] Deleting /Users/alvarosanchez/Micronaut/micronaut-maven-plugin/examples/java/target
[INFO]
[INFO] --- micronaut-maven-plugin:1.0.0.BUILD-SNAPSHOT:run (default-cli) @ java-maven-junit ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /Users/alvarosanchez/Micronaut/micronaut-maven-plugin/examples/java/target/classes
13:36:32.665 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 919ms. Server Running: http://localhost:8080

Other options

  • Running in debug mode: mvn mn:run -Dmn.debug.

  • Changing the debugger port: mvn mn:run -Dmn.debug -Dmn.debug.port=5006.

  • Suspending the debugger execution: mn:run -Dmn.debug -Dmn.debug.suspend.

Goals

  • mn:run: executes a Micronaut application in development mode.