diff --git a/.mvn/settings.xml b/.mvn/settings.xml index f94b247a34..5c84da1f0c 100644 --- a/.mvn/settings.xml +++ b/.mvn/settings.xml @@ -12,12 +12,13 @@ + + release + + oss - - true - ${env.GPG_KEY_NAME} ${env.GPG_PASSPHRASE} diff --git a/.travis.yml b/.travis.yml index c8279dabc3..f6465c8c88 100644 --- a/.travis.yml +++ b/.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= diff --git a/README.md b/README.md index 542d7616b3..8bf002775b 100644 --- a/README.md +++ b/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 @@ -22,6 +37,3 @@ but this requires additional configuration inside `~/.m2/settings.xml` ``` - - -For more information please go to the [Wiki](https://github.com/Codearte/accurest/wiki/2.2-Maven-Project) diff --git a/pom.xml b/pom.xml index 8505212d9f..6bf7f49877 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.codearte.accurest accurest-maven-plugin maven-plugin - 0.5-SNAPSHOT + 0.5.0-SNAPSHOT Accurate Maven Plugin Project Accurate REST Maven Plugin @@ -30,8 +30,6 @@ UTF-8 1.0.4 - - 0000000 @@ -150,41 +148,6 @@ coveralls-maven-plugin 4.1.0 - - com.smartcodeltd - release-candidate-maven-plugin - 1.0-201603091838.01dbbbf - - - default-cli - - updateVersion - - - {{ api_version }}-beta-${revision} - - - - - version - - - PROJECT_VERSION={{ version }} - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - oss - https://oss.sonatype.org/ - false - - org.apache.maven.plugins maven-release-plugin @@ -293,12 +256,6 @@ release - - - performRelease - true - - @@ -358,6 +315,120 @@ + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + oss + https://oss.sonatype.org/ + true + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + parse-version + deploy + + parse-version + + + + + + org.codehaus.mojo + versions-maven-plugin + 2.2 + + + switch-to-snapshot-version + deploy + + set + + + + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT + + + + + + org.apache.maven.plugins + maven-scm-plugin + 1.9.4 + false + + + tag-new-release + deploy + + tag + + + v${project.version} + + + + save-changes + deploy + + checkin + + + connection + pom.xml + Setting next development version to ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT. + + [ci skip] + + + + + + + + + + version + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + parse-version + initialize + + parse-version + + + + + + org.codehaus.mojo + versions-maven-plugin + 2.2 + + + set-release-version + initialize + + set + + + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion} + + + + diff --git a/src/main/java/io/codearte/accurest/maven/AccurestConverter.java b/src/main/java/io/codearte/accurest/maven/AccurestConverter.java new file mode 100644 index 0000000000..e04b814bce --- /dev/null +++ b/src/main/java/io/codearte/accurest/maven/AccurestConverter.java @@ -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(); + } + +} diff --git a/src/main/java/io/codearte/accurest/maven/ConvertMojo.java b/src/main/java/io/codearte/accurest/maven/ConvertMojo.java index a15b5a642b..16ee3642db 100644 --- a/src/main/java/io/codearte/accurest/maven/ConvertMojo.java +++ b/src/main/java/io/codearte/accurest/maven/ConvertMojo.java @@ -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); } } diff --git a/src/main/java/io/codearte/accurest/maven/RunMojo.java b/src/main/java/io/codearte/accurest/maven/RunMojo.java new file mode 100644 index 0000000000..5744ab4170 --- /dev/null +++ b/src/main/java/io/codearte/accurest/maven/RunMojo.java @@ -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) { + } + } + +}