accurest:run
This commit is contained in:
@@ -12,12 +12,13 @@
|
||||
</server>
|
||||
</servers>
|
||||
|
||||
<activeProfiles>
|
||||
<activeProfile>release</activeProfile>
|
||||
</activeProfiles>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>oss</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<gpg.keyname>${env.GPG_KEY_NAME}</gpg.keyname>
|
||||
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
|
||||
|
||||
10
.travis.yml
10
.travis.yml
@@ -2,14 +2,15 @@ language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
before_install:
|
||||
- if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" ]]; then openssl aes-256-cbc -K $encrypted_6c56aea9ab8c_key -iv $encrypted_6c56aea9ab8c_iv -in .mvn/codesigning.asc.enc -out .mvn/codesigning.asc -d; fi
|
||||
- if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" ]]; then gpg --fast-import .mvn/codesigning.asc; fi
|
||||
- openssl aes-256-cbc -K $encrypted_6c56aea9ab8c_key -iv $encrypted_6c56aea9ab8c_iv -in .mvn/codesigning.asc.enc -out .mvn/codesigning.asc -d
|
||||
- gpg --fast-import .mvn/codesigning.asc
|
||||
- git config --global user.email "builds@travis-ci.com"
|
||||
- git config --global user.name "Travis CI"
|
||||
- if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" ]]; then git checkout master; fi
|
||||
before_script:
|
||||
- if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" ]]; then ./mvnw release-candidate:updateVersion -Drevision=$TRAVIS_BUILD_NUMBER; fi
|
||||
- if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" ]]; then ./mvnw initialize -Pversion; fi
|
||||
script:
|
||||
- if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" ]]; then ./mvnw deploy --settings .mvn/settings.xml -Prelease; else ./mvnw install; fi
|
||||
- if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" ]]; then ./mvnw deploy --settings .mvn/settings.xml; else ./mvnw install; fi
|
||||
after_success:
|
||||
- ./mvnw clean test jacoco:report coveralls:report
|
||||
install: true
|
||||
@@ -19,6 +20,7 @@ branches:
|
||||
cache:
|
||||
directories:
|
||||
- ~/.m2/repository
|
||||
- ~/.m2/wrapper
|
||||
env:
|
||||
global:
|
||||
- secure: oYAoU+PDuaWLo4MBoQYCF++kEqwWn8xtDAeBxBRIvduJO7758+haeSW43AFjmLfuJ9aUdfS+MrqGnDuj+Nqw1oSU9vdbyX7m+Q3wFDkO1Ln2NCaifrSCVHaAAMSfSKNlYBjD4+sATsrnSF75BSIS2WMNItkGcac7DPD+Ls64Ovw9MbkMB2i4TRYboGFNvOhtFYSOexd6hWltin0s6EHtsqFJKBKiPfvZYPJ34d0bfvMbi/TyfDoaia0QG8EUqyF1FZhBT5j/iXD03kTMdZ59o3pUgkgZjMfiD7rJGWffwZ+kV8PtzYyzjhiH8o+tqhFkLRXfu+s6zcMjBhJDR1rgguEqzlKbGRoFahY5PI+fbLwyNz+kQwtXxF3+lpwM/VZ/1OHPgpTtdDiz5ArRskb/Y/caGbLhjkm4V2x3/7fvRHGcLZf7DraJoShT/5MvG0AN7PCjEhbGX+08YaRucmQLWHUo1pGazwagP+7MqDsimdR+VzIY/HUctFi4DPOLjmZROukcPCFJTwn2T/0TFC5Luptb5ifsT9RvBv89/A71XcYs6rrGcU4UHdy6gZwWIRECKG82X+0jwoM39dFfweF7iVIuimdK2+yy4DtLZQfeqR7pWphs2i42twQUWcwIpRQyi/hn+wteVz7yxIBKfphaIVVP3juS1RPtMD0vOm8BRpo=
|
||||
|
||||
24
README.md
24
README.md
@@ -3,16 +3,31 @@
|
||||
Accurate REST Maven Plugin
|
||||
====
|
||||
|
||||
|
||||
Converting [Accurest](https://github.com/Codearte/accurest/wiki/1.-Introduction) GroovyDSL into WireMock stub mappings:
|
||||
|
||||
mvn io.codearte.accurest:accurest-maven-plugin:convert
|
||||
|
||||
or shortly
|
||||
or shortly (*)
|
||||
|
||||
mvn accurest:convert
|
||||
|
||||
but this requires additional configuration inside `~/.m2/settings.xml`
|
||||
|
||||
Accurest Runner
|
||||
---
|
||||
|
||||
mvn io.codearte.accurest:accurest-maven-plugin:run
|
||||
|
||||
or shortly (*)
|
||||
|
||||
mvn accurest:run
|
||||
|
||||
|
||||
For more information please go to the [Wiki](https://github.com/Codearte/accurest/wiki/2.2-Maven-Project)
|
||||
|
||||
|
||||
---
|
||||
|
||||
(*) Additional configuration inside `~/.m2/settings.xml`
|
||||
|
||||
```xml
|
||||
<settings>
|
||||
@@ -22,6 +37,3 @@ but this requires additional configuration inside `~/.m2/settings.xml`
|
||||
</settings>
|
||||
|
||||
```
|
||||
|
||||
|
||||
For more information please go to the [Wiki](https://github.com/Codearte/accurest/wiki/2.2-Maven-Project)
|
||||
|
||||
159
pom.xml
159
pom.xml
@@ -6,7 +6,7 @@
|
||||
<groupId>io.codearte.accurest</groupId>
|
||||
<artifactId>accurest-maven-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>0.5-SNAPSHOT</version>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
|
||||
<name>Accurate Maven Plugin Project</name>
|
||||
<description>Accurate REST Maven Plugin</description>
|
||||
@@ -30,8 +30,6 @@
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<accurest.version>1.0.4</accurest.version>
|
||||
|
||||
<revision>0000000</revision>
|
||||
</properties>
|
||||
|
||||
<licenses>
|
||||
@@ -150,41 +148,6 @@
|
||||
<artifactId>coveralls-maven-plugin</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.smartcodeltd</groupId>
|
||||
<artifactId>release-candidate-maven-plugin</artifactId>
|
||||
<version>1.0-201603091838.01dbbbf</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-cli</id>
|
||||
<goals>
|
||||
<goal>updateVersion</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<releaseVersionFormat>{{ api_version }}-beta-${revision}</releaseVersionFormat>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>version</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputTemplate>PROJECT_VERSION={{ version }}</outputTemplate>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>oss</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>false</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
@@ -293,12 +256,6 @@
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>performRelease</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -358,6 +315,120 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.7</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>oss</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>parse-version</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>parse-version</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>switch-to-snapshot-version</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>set</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<allowSnapshots/>
|
||||
<newVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT</newVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-scm-plugin</artifactId>
|
||||
<version>1.9.4</version>
|
||||
<inherited>false</inherited>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>tag-new-release</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>tag</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tag>v${project.version}</tag>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>save-changes</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>checkin</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<connectionType>connection</connectionType>
|
||||
<includes>pom.xml</includes>
|
||||
<message>Setting next development version to ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT.
|
||||
|
||||
[ci skip]</message>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<!-- Set version for release-->
|
||||
<profile>
|
||||
<id>version</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.10</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>parse-version</id>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>parse-version</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>set-release-version</id>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>set</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<newVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}</newVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package io.codearte.accurest.maven;
|
||||
|
||||
import io.codearte.accurest.config.AccurestConfigProperties;
|
||||
import io.codearte.accurest.wiremock.DslToWireMockClientConverter;
|
||||
import io.codearte.accurest.wiremock.RecursiveFilesConverter;
|
||||
|
||||
public class AccurestConverter {
|
||||
|
||||
public void convert(AccurestConfigProperties config){
|
||||
RecursiveFilesConverter converter = new RecursiveFilesConverter(new DslToWireMockClientConverter(), config);
|
||||
converter.processFiles();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,8 +33,7 @@ public class ConvertMojo extends AbstractMojo {
|
||||
getLog().info(format(" Accurest contracts directory: %s", config.getContractsDslDir().getAbsolutePath()));
|
||||
getLog().info(format("WireMock stubs mappings directory: %s", config.getStubsOutputDir().getAbsolutePath()));
|
||||
|
||||
RecursiveFilesConverter converter = new RecursiveFilesConverter(new DslToWireMockClientConverter(), config);
|
||||
converter.processFiles();
|
||||
new AccurestConverter().convert(config);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
68
src/main/java/io/codearte/accurest/maven/RunMojo.java
Normal file
68
src/main/java/io/codearte/accurest/maven/RunMojo.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package io.codearte.accurest.maven;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
import com.github.tomakehurst.wiremock.common.SingleRootFileSource;
|
||||
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
|
||||
import com.github.tomakehurst.wiremock.standalone.JsonFileMappingsLoader;
|
||||
import io.codearte.accurest.config.AccurestConfigProperties;
|
||||
|
||||
@Mojo(name = "run", requiresProject = false)
|
||||
public class RunMojo extends AbstractMojo {
|
||||
|
||||
@Parameter(property = "contractsDir", defaultValue = "${basedir}")
|
||||
private File contractsDir;
|
||||
|
||||
@Parameter(property = "port", defaultValue = "8089")
|
||||
private int port;
|
||||
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
|
||||
try {
|
||||
Path mappingsPath = Files.createTempDirectory("mappings");
|
||||
AccurestConfigProperties config = new AccurestConfigProperties();
|
||||
config.setContractsDslDir(contractsDir);
|
||||
config.setStubsOutputDir(mappingsPath.toFile());
|
||||
new AccurestConverter().convert(config);
|
||||
getLog().info(
|
||||
format(" Accurest contracts directory: %s", config.getContractsDslDir().getAbsolutePath()));
|
||||
getLog().info(
|
||||
format("WireMock stubs mappings directory: %s", config.getStubsOutputDir().getAbsolutePath()));
|
||||
|
||||
WireMockServer wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig().port(port));
|
||||
wireMockServer.loadMappingsUsing(
|
||||
new JsonFileMappingsLoader(new SingleRootFileSource(mappingsPath.toFile())));
|
||||
wireMockServer.start();
|
||||
|
||||
pressAnyKeyToContinue();
|
||||
getLog().info("Shutting down ...");
|
||||
|
||||
wireMockServer.stop();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void pressAnyKeyToContinue() {
|
||||
getLog().info("Press any key to continue...");
|
||||
try {
|
||||
System.in.read();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user