Filter Results of Maven Archetype:Generate
One of my favorite features of Maven is being able to utilize archetypes to provide me with a starting point for my projects. As most developers familiar with Maven already know, you can generate a project based on an existing archetype simply by typing mvn archetype:generate
in your command line console. However, having to scroll through thousands of possible archetype results is no fun. Below is an option to the mvn command which can be used to filter your results.
mvn archetype:generate -Dfilter=your_search_word
So if searching for “kotlin” archetypes for example, you would simply type:
mvn archetype:generate -Dfilter=kotlin
This command would provide you with the following:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: remote -> com.github.K0zka:kotlin-simple-archetype (-)
2: remote -> com.github.mhshams:kotlin-quickstart-archetype (Kotlin Quick Start Archetype)
3: remote -> com.udaan.archetypes:dropwizard-kotlin (Maven archetype for Kotlin based Dropwizard applications)
4: remote -> io.fabric8.archetypes:funktion-kotlin-example-archetype (Creates a new funktion kotlin example)
5: remote -> net.miob.maven:kotlin-archetype (A maven quick start archetype for kotlin projects.)
6: remote -> org.jetbrains.kotlin:kotlin-archetype-js (Kotlin single-module JavaScript project archetype)
7: remote -> org.jetbrains.kotlin:kotlin-archetype-jvm (Kotlin single-module JVM project archetype)
8: remote -> org.openjdk.jmh:jmh-kotlin-benchmark-archetype (Generates Kotlin benchmarking project, uses JMH bytecode processors)
9: remote -> org.robovm:robovm-cross-platform-kotlin-template (-)
10: remote -> org.robovm:robovm-templates-cross-platform-kotlin (-)
Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): :
As you can see, the list of results is drastically smaller than the one without the filter option.