Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flapdoodle 3.4.6 upgrade #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,28 @@
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>2.1.1</version>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.process</artifactId>
<version>2.0.5</version>
<version>3.1.11</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.7.0</version>
<version>3.12.11</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>

<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo.packageresolver</artifactId>
<version>1.0.3</version>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import de.flapdoodle.embed.mongo.MongoImportExecutable;
import de.flapdoodle.embed.mongo.MongoImportProcess;
import de.flapdoodle.embed.mongo.MongoImportStarter;
import de.flapdoodle.embed.mongo.config.IMongoImportConfig;
import de.flapdoodle.embed.mongo.config.MongoImportConfigBuilder;
import de.flapdoodle.embed.mongo.config.MongoImportConfig;
import de.flapdoodle.embed.mongo.config.Net;
import de.flapdoodle.embed.mongo.config.Timeout;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -77,17 +76,16 @@ private void sendImportScript() throws IOException, InterruptedException, MojoEx
database = defaultImportDatabase;
}

IMongoImportConfig mongoImportConfig = new MongoImportConfigBuilder()
MongoImportConfig mongoImportConfig = MongoImportConfig.builder()
.version(getVersion())
.net(new Net(getPort(), NetworkUtils.localhostIsIPv6()))
.db(database)
.collection(importData.getCollection())
.upsert(importData.getUpsertOnImport())
.dropCollection(importData.getDropOnImport())
.importFile(importData.getFile())
.jsonArray(true)
.timeout(new Timeout(importData.getTimeout()))
.build();
.build().withDatabaseName(database)
.withCollectionName(importData.getCollection())
.withIsUpsertDocuments(importData.getUpsertOnImport())
.withIsDropCollection(importData.getDropOnImport())
.withImportFile(importData.getFile())
.withIsJsonArray(true)
.withTimeout(new Timeout(importData.getTimeout()));

MongoImportExecutable mongoImport = MongoImportStarter.getDefaultInstance().prepare(mongoImportConfig);

Expand Down
58 changes: 29 additions & 29 deletions src/main/java/com/github/joelittlejohn/embedmongo/StartMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@
import java.util.List;
import java.util.concurrent.TimeUnit;

import de.flapdoodle.embed.mongo.config.Defaults;
import de.flapdoodle.embed.mongo.config.MongoCmdOptions;
import de.flapdoodle.embed.mongo.config.MongodConfig;
import de.flapdoodle.embed.mongo.packageresolver.Command;
import de.flapdoodle.embed.process.config.RuntimeConfig;
import de.flapdoodle.embed.process.config.store.ImmutableDownloadConfig;
import de.flapdoodle.embed.process.config.store.ProxyFactory;
import de.flapdoodle.embed.process.config.store.SameDownloadPathForEveryDistribution;
import de.flapdoodle.embed.process.runtime.CommandLinePostProcessor;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
Expand All @@ -35,27 +43,15 @@
import com.github.joelittlejohn.embedmongo.log.Loggers;
import com.github.joelittlejohn.embedmongo.log.Loggers.LoggingStyle;

import de.flapdoodle.embed.mongo.Command;
import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.ExtractedArtifactStoreBuilder;
import de.flapdoodle.embed.mongo.config.DownloadConfigBuilder;
import de.flapdoodle.embed.mongo.config.IMongodConfig;
import de.flapdoodle.embed.mongo.config.MongoCmdOptionsBuilder;
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
import de.flapdoodle.embed.mongo.config.Net;
import de.flapdoodle.embed.mongo.config.RuntimeConfigBuilder;
import de.flapdoodle.embed.mongo.config.Storage;
import de.flapdoodle.embed.process.config.IRuntimeConfig;
import de.flapdoodle.embed.process.config.io.ProcessOutput;
import de.flapdoodle.embed.process.config.store.HttpProxyFactory;
import de.flapdoodle.embed.process.config.store.IDownloadConfig;
import de.flapdoodle.embed.process.config.store.IProxyFactory;
import de.flapdoodle.embed.process.config.store.NoProxyFactory;
import de.flapdoodle.embed.process.distribution.Distribution;
import de.flapdoodle.embed.process.exceptions.DistributionException;
import de.flapdoodle.embed.process.runtime.ICommandLinePostProcessor;
import de.flapdoodle.embed.process.store.IArtifactStore;

/**
Expand Down Expand Up @@ -116,7 +112,7 @@ protected void savePortToProjectProperties(int port) {
*
* @since 0.1.10
*/
@Parameter(property = "embedmongo.downloadPath", defaultValue = "http://fastdl.mongodb.org/")
@Parameter(property = "embedmongo.downloadPath", defaultValue = "http://fastdl.mongodb.org")
private String downloadPath;

/**
Expand Down Expand Up @@ -159,16 +155,15 @@ public void executeStart() throws MojoExecutionException, MojoFailureException {
try {

final List<String> mongodArgs = this.createMongodArgsList();
final ICommandLinePostProcessor commandLinePostProcessor = new ICommandLinePostProcessor() {
final CommandLinePostProcessor commandLinePostProcessor = new CommandLinePostProcessor() {
@Override
public List<String> process(final Distribution distribution, final List<String> args) {
args.addAll(mongodArgs);
return args;
}
};

IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
.defaults(Command.MongoD)
RuntimeConfig runtimeConfig = Defaults.runtimeConfigFor(Command.MongoD)
.processOutput(getOutputConfig())
.artifactStore(getArtifactStore())
.commandLinePostProcessor(commandLinePostProcessor)
Expand All @@ -181,21 +176,19 @@ public List<String> process(final Distribution distribution, final List<String>
}
savePortToProjectProperties(port);

IMongodConfig config = new MongodConfigBuilder()
MongodConfig config = MongodConfig.builder()
.version(getVersion()).net(new Net(bindIp, port, NetworkUtils.localhostIsIPv6()))
.replication(new Storage(getDataDirectory(), null, 0))
.cmdOptions(new MongoCmdOptionsBuilder()
.enableAuth(authEnabled)
.cmdOptions(MongoCmdOptions.builder()
.auth(authEnabled)
.useNoJournal(!journal)
.useStorageEngine(storageEngine)
.storageEngine(storageEngine)
.build())
.build();

executable = MongodStarter.getInstance(runtimeConfig).prepare(config);
} catch (DistributionException e) {
throw new MojoExecutionException("Failed to download MongoDB distribution: " + e.withDistribution(), e);
} catch (IOException e) {
throw new MojoExecutionException("Unable to Config MongoDB: ", e);
}

try {
Expand Down Expand Up @@ -247,26 +240,33 @@ private ProcessOutput getOutputConfig() throws MojoFailureException {
}

private IArtifactStore getArtifactStore() {
IDownloadConfig downloadConfig = new DownloadConfigBuilder().defaultsForCommand(Command.MongoD).proxyFactory(getProxyFactory(settings)).downloadPath(downloadPath).build();
return new ExtractedArtifactStoreBuilder().defaults(Command.MongoD).download(downloadConfig).build();
ImmutableDownloadConfig.Builder downloadConfigBuilder =
Defaults.downloadConfigFor(Command.MongoD);
ImmutableDownloadConfig downloadConfig = downloadConfigBuilder
.proxyFactory(getProxyFactory(settings))
.downloadPath(new SameDownloadPathForEveryDistribution(downloadPath))
.build();

return Defaults.extractedArtifactStoreFor(Command.MongoD)
.withDownloadConfig(downloadConfig);
}

public IProxyFactory getProxyFactory(Settings settings) {
public ProxyFactory getProxyFactory(Settings settings) {
URI downloadUri = URI.create(downloadPath);
final String downloadHost = downloadUri.getHost();
final String downloadProto = downloadUri.getScheme();

if (settings.getProxies() != null) {
for (org.apache.maven.settings.Proxy proxy : (List<org.apache.maven.settings.Proxy>) settings.getProxies()) {
for (org.apache.maven.settings.Proxy proxy : settings.getProxies()) {
if (proxy.isActive()
&& equalsIgnoreCase(proxy.getProtocol(), downloadProto)
&& !contains(proxy.getNonProxyHosts(), downloadHost)) {
return new HttpProxyFactory(proxy.getHost(), proxy.getPort());
}
}
}
return new NoProxyFactory();

return () -> null;
}

private String getDataDirectory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import java.io.IOException;
import java.io.OutputStreamWriter;

import de.flapdoodle.embed.process.io.IStreamProcessor;
import de.flapdoodle.embed.process.io.StreamProcessor;

public class FileOutputStreamProcessor implements IStreamProcessor {
public class FileOutputStreamProcessor implements StreamProcessor {

private static OutputStreamWriter stream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package com.github.joelittlejohn.embedmongo.log;

import de.flapdoodle.embed.mongo.Command;
import de.flapdoodle.embed.mongo.config.MongodProcessOutputConfig;
import de.flapdoodle.embed.mongo.packageresolver.Command;
import de.flapdoodle.embed.process.config.io.ProcessOutput;
import de.flapdoodle.embed.process.io.NamedOutputStreamProcessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
*/
package com.github.joelittlejohn.embedmongo.log;

import de.flapdoodle.embed.process.io.IStreamProcessor;

public class NoopStreamProcessor implements IStreamProcessor {
import de.flapdoodle.embed.process.io.StreamProcessor;

public class NoopStreamProcessor implements StreamProcessor {

@Override
public void process(String block) {
Expand Down

This file was deleted.