diff --git a/README.md b/README.md
index ce9e2b04e9331241a0b3d1de86bfb7dcb93a1b61..1e4feca68e911a0dc83a83fedae56e434867c0c8 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,12 @@ Usage
<skip>false</skip>
<!-- optional, skips this plugin entirely, use on the command line like -Dembedmongo.skip -->
+
+ <features>
+ <feature>sync_delay</feature>
+ <feature>text_search</feature>
+ </features>
+ <!-- optional, a list of MongoDB features to enable, default is none -->
</configuration>
</execution>
<execution>
diff --git a/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java b/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java
index 120f80c6800ad018c1ef234a17886c024841a9e3..8010a4eb77d8acaa1397d606ba0ca62781226b8d 100644
--- a/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java
+++ b/src/main/java/com/syncleus/maven/plugins/mongodb/StartMongoMojo.java
@@ -23,6 +23,7 @@ import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.*;
+import de.flapdoodle.embed.mongo.distribution.Feature;
import de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion;
import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.mongo.distribution.Versions;
@@ -50,6 +51,7 @@ import org.apache.maven.project.MavenProject;
import java.io.File;
import java.io.IOException;
import java.net.*;
+import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -231,6 +233,14 @@ public class StartMongoMojo extends AbstractMojo {
@Parameter(property = "project", readonly = true)
private MavenProject project;
+ /**
+ * A list of the MongoDB features enabled.
+ *
+ * @since 1.0.0
+ */
+ @Parameter
+ private String[] features;
+
/**
* If true the plugin does nothing at all, allows you to skip from the command line.
*
@@ -391,8 +401,18 @@ public class StartMongoMojo extends AbstractMojo {
}
private IFeatureAwareVersion getVersion() {
- if(this.version == null || this.version.equals(""))
- return Version.Main.PRODUCTION;
+
+ final HashSet<Feature> featuresSet = new HashSet<Feature>();
+ if(this.features != null && this.features.length > 0) {
+ for(final String featureString : this.features)
+ featuresSet.add(Feature.valueOf(featureString.toUpperCase()));
+ }
+
+ if(this.version == null || this.version.equals("")) {
+ if(featuresSet.isEmpty())
+ return Version.Main.PRODUCTION;
+ this.version = Version.Main.PRODUCTION.asInDownloadPath();
+ }
String versionEnumName = this.version.toUpperCase().replaceAll("\\.", "_");
@@ -400,18 +420,20 @@ public class StartMongoMojo extends AbstractMojo {
versionEnumName = "V" + versionEnumName;
}
+ IVersion determinedVersion;
try {
- return Version.valueOf(versionEnumName);
+ determinedVersion = Version.valueOf(versionEnumName);
} catch (final IllegalArgumentException e) {
getLog().warn("Unrecognised MongoDB version '" + this.version + "', this might be a new version that we don't yet know about. Attemping download anyway...");
- return Versions.withFeatures(new IVersion() {
+ determinedVersion = new IVersion() {
@Override
public String asInDownloadPath() {
return version;
}
- });
+ };
}
+ return Versions.withFeatures(determinedVersion, (featuresSet.isEmpty() ? null : (Feature[]) featuresSet.toArray()));
}
private String getDataDirectory() {