Maven Central
Maven Central
Maven Central contains the following released MockServer artifacts:
- mockserver-netty - a web server for mocking and proxying using Netty
Add to a maven build pom.xml as follows:
<dependencies> ... <dependency> <groupId>org.mock-server</groupId> <artifactId>mockserver-netty</artifactId> <version>RELEASE</version> </dependency> ... <dependencies>
Add to a gradle build build.gradle as follows:
dependencies { ... testImplementation("org.mock-server:mockserver-netty:5.7.2") ... }
- mockserver-netty:jar-with-dependencies - as above using Netty that includes all dependencies are bundled into the jar file, this artifact can be downloaded.
- mockserver-war - a deployable WAR for mocking that can be deployed to any JEE web server, this artifact can be downloaded.
- mockserver-proxy-war - a deployable WAR for proxying that can be deployed to any JEE web server, this artifact can be downloaded.
- mockserver-maven-plugin - a set of maven plugins to start, stop and fork MockServer using maven
Add to a maven build pom.xml as follows:
<plugin> <groupId>org.mock-server</groupId> <artifactId>mockserver-maven-plugin</artifactId> <version>RELEASE</version> <configuration> <serverPort>1080</serverPort> <pipeLogToConsole>true</pipeLogToConsole> </plugin>
- mockserver-client-java - a Java client to communicate with both the server and the proxy
Add to a maven build pom.xml as follows:
<dependency> <groupId>org.mock-server</groupId> <artifactId>mockserver-client-java</artifactId> <version>RELEASE</version> </dependency>
Add to a gradle build build.gradle as follows:
dependencies { ... testImplementation("org.mock-server:mockserver-client-java:5.7.2") ... }
Sonatype SNAPSHOT
The latest SNAPSHOT version can be found at Sonatype
Maven
To use the SNAPSHOT version in a maven project you need to configure your maven settings.xml or your pom.xml to include the Sonatype SNAPSHOT repository as follows:
<profile>
<id>sonatype</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>sonatype-nexus-snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>sonatype-nexus-snapshots</id>
<name>sonatype-nexus-snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
Note: typically it is best practice to configure the ~/.m2/settings.xml file instead of the settings.xml file located inside the conf directory in the maven installation directory (i.e. $M2_HOME). This is because the ~/.m2/settings.xml file will be consistent between maven version upgrades and any changes to this file will only affect a single user.
Once the Sonatype SNAPSHOT repository has been added, as above, the latest SNAPSHOT build can referenced.
For example add a dependency on the latest SNAPSHOT build for mockserver-netty, as follows:
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
<version>SNAPSHOT</version>
</dependency>
Gradle
To use the SNAPSHOT version in a gralde project you need to add the correct repository into the project as follows:
repositories {
...
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
...
}
Once the Sonatype SNAPSHOT repository has been added, the latest SNAPSHOT build can referenced, as follows:
dependencies {
...
testImplementation("org.mock-server:mockserver-netty:5.7.2-SNAPSHOT")
...
}