diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..ca5a761 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "build_utils"] + path = build_utils + url = git@github.com:rbkmoney/build_utils.git + branch = master diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..6eeb0be --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,40 @@ +#!groovy +build('swag-webhook-events', 'docker-host') { + checkoutRepo() + loadBuildUtils() + + def pipeDefault + def gitUtils + runStage('load pipeline') { + env.JENKINS_LIB = "build_utils/jenkins_lib" + pipeDefault = load("${env.JENKINS_LIB}/pipeDefault.groovy") + gitUtils = load("${env.JENKINS_LIB}/gitUtils.groovy") + } + + pipeDefault() { + runStage('init') { + withGithubSshCredentials { + sh 'make wc_init' + } + } + + runStage('build') { + sh 'make wc_build' + } + + // Java + runStage('Build client & server') { + withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) { + if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) { + sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.deploy_client_old' + sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.deploy_client' + sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.deploy_server' + } else { + sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.compile_client_old' + sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.compile_client' + sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.compile_server' + } + } + } + } +} diff --git a/Makefile b/Makefile index 8f43e2b..4db4777 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,128 @@ -all: build +SUBMODULES = build_utils +SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES)) + +UTILS_PATH := build_utils +TEMPLATES_PATH := . + +# Name of the service +SERVICE_NAME := swag-webhook-events +# Service image default tag +SERVICE_IMAGE_TAG ?= $(shell git rev-parse HEAD) +# The tag for service image to be pushed with +SERVICE_IMAGE_PUSH_TAG ?= $(SERVICE_IMAGE_TAG) + +BUILD_IMAGE_TAG := f3732d29a5e622aabf80542b5138b3631a726adb + +CALL_ANYWHERE := \ + all submodules init build java.compile java.deploy + +CALL_W_CONTAINER := $(CALL_ANYWHERE) + +all: compile + +-include $(UTILS_PATH)/make_lib/utils_image.mk +-include $(UTILS_PATH)/make_lib/utils_container.mk + +.PHONY: $(CALL_W_CONTAINER) + +$(SUBTARGETS): %/.git: % + git submodule update --init $< + touch $@ + +submodules: $(SUBTARGETS) + +init: + npm install build: - npm install npm run build -start: - npm start +# Java + +ifdef SETTINGS_XML +DOCKER_RUN_OPTS = -v $(SETTINGS_XML):$(SETTINGS_XML) +DOCKER_RUN_OPTS += -e SETTINGS_XML=$(SETTINGS_XML) +endif + +ifdef LOCAL_BUILD +DOCKER_RUN_OPTS += -v $$HOME/.m2:/home/$(UNAME)/.m2:rw +endif + +COMMIT_HASH := $(shell git --no-pager log -1 --pretty=format:"%h") +NUMBER_COMMITS := $(shell git rev-list --count HEAD) + +JAVA_PKG_VERSION := 1.$(NUMBER_COMMITS)-$(COMMIT_HASH) + +ifdef BRANCH_NAME +ifeq "$(findstring epic,$(BRANCH_NAME))" "epic" +JAVA_PKG_VERSION := $(JAVA_PKG_VERSION)-epic +endif +endif + +MVN = mvn -s $(SETTINGS_XML) -Dcommit.number="$(NUMBER_COMMITS)" + +java.swag.compile_client_old: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) compile -P="client-old" + +java.swag.deploy_client_old: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-client-old" && \ + $(MVN) deploy -P="client-old" + +java.swag.install_client_old: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-client-old" && \ + $(MVN) install -P="client-old" + +java.swag.compile_client: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) compile -P="client" + +java.swag.deploy_client: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-client" && \ + $(MVN) deploy -P="client" + +java.swag.install_client: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-client" && \ + $(MVN) install -P="client" + +java.swag.compile_server: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) compile -P="server" + +java.swag.deploy_server: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-server" && \ + $(MVN) deploy -P="server" + +java.swag.install_server: + $(if $(SETTINGS_XML),,echo "SETTINGS_XML not defined" ; exit 1) + $(MVN) clean && \ + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)-server" && \ + $(MVN) install -P="server" + +java.compile: java.settings + $(MVN) compile + +java.deploy: java.settings + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)" && \ + $(MVN) deploy + +java.install: java.settings + $(MVN) clean && \ + $(MVN) versions:set versions:commit -DnewVersion="$(JAVA_PKG_VERSION)" && \ + $(MVN) install + +java.settings: + $(if $(SETTINGS_XML),, echo "SETTINGS_XML not defined"; exit 1) diff --git a/build_utils b/build_utils new file mode 160000 index 0000000..b9b18f3 --- /dev/null +++ b/build_utils @@ -0,0 +1 @@ +Subproject commit b9b18f3ee375aa5fd105daf57189ac242c40f572 diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..6ae8615 --- /dev/null +++ b/pom.xml @@ -0,0 +1,256 @@ + + + 4.0.0 + + + com.rbkmoney + parent + 1.0.0 + + + swag-webhook-events + SNAPSHOT + jar + + + com.rbkmoney.swag_webhook_events + UTF-8 + 1.5.21 + 2.7 + 1.0.0 + 1.8 + ${java.version} + ${java.version} + 9.2.15.v20160210 + 1.7.21 + 4.12 + 2.5 + 2.7.0 + 2.8.9 + 2.6.4 + 5.1.3.RELEASE + 1.3.2 + 2.3.1 + 1.1.0.Final + 4.5.2 + 2.8.5 + 2.7.5 + 1.0.1 + + + + + + org.springframework + spring-core + ${spring-version} + provided + + + org.springframework + spring-webmvc + ${spring-version} + provided + + + org.springframework + spring-web + ${spring-version} + provided + + + + + io.springfox + springfox-swagger2 + ${springfox-version} + + + com.fasterxml.jackson.core + jackson-annotations + + + org.mapstruct + mapstruct + + + + + io.springfox + springfox-swagger-ui + ${springfox-version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + + + + com.google.code.gson + gson + ${gson.version} + + + + io.gsonfire + gson-fire + ${gson.fire.version} + + + + com.squareup.okhttp + okhttp + ${okhttp.version} + + + + com.squareup.okhttp + logging-interceptor + ${okhttp.version} + + + + junit + junit + ${junit-version} + test + + + javax.servlet + servlet-api + ${servlet-api-version} + provided + + + javax.annotation + javax.annotation-api + ${javax.version} + + + javax.xml.bind + jaxb-api + ${jaxb.version} + + + + javax.validation + validation-api + ${javax-validation.version} + provided + + + + org.apache.httpcomponents + httpclient + ${http-client.version} + test + + + + + + server + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + generate-server + generate-sources + + generate + + + web_deploy/swagger.yaml + + java8 + + + spring + spring-mvc + + ${default.package}.api + ${default.package}.model + + + + + + + + + client + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + generate-client + generate-sources + + generate + + + web_deploy/swagger.yaml + + java8 + + + java + resttemplate + + ${default.package}.api + ${default.package}.model + + + + + + + + + client-old + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + generate-client + generate-sources + + generate + + + web_deploy/swagger.yaml + + java8 + + + java + + ${default.package}.api + ${default.package}.model + + + + + + + + + + + diff --git a/spec/definitions/Payment.yaml b/spec/definitions/Payment.yaml index b0c7185..9ee5e7b 100644 --- a/spec/definitions/Payment.yaml +++ b/spec/definitions/Payment.yaml @@ -82,4 +82,9 @@ properties: Уникальный отпечаток user agent'а плательщика type: string payer: - $ref: '#/definitions/Payer' \ No newline at end of file + $ref: '#/definitions/Payer' + fee: + description: > + Комиссия системы, в минорных денежных единицах. + type: integer + format: int64