BJ-532: Claim Management. Create client/server build (#3)

This commit is contained in:
Baikov Dmitrii 2019-07-18 18:58:34 +03:00 committed by GitHub
parent 5c6a8d9bba
commit 9b5413de72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 138 additions and 41 deletions

5
.gitignore vendored
View File

@ -58,4 +58,7 @@ package-lock.json
# Gradle:
.idea/gradle.xml
.idea/libraries
.idea/libraries
# Idea
*.iml

14
Jenkinsfile vendored
View File

@ -23,13 +23,15 @@ build('swag-claim-management', 'docker-host') {
}
// Java
runStage('Execute build container') {
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} wc_java.deploy'
} else {
sh 'make SETTINGS_XML=${SETTINGS_XML} wc_java.compile'
}
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) {
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'
sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} java.swag.compile_server'
}
}
}
}

View File

@ -63,6 +63,40 @@ endif
MVN = mvn -s $(SETTINGS_XML) -Dcommit.number="$(NUMBER_COMMITS)"
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

View File

@ -18,8 +18,24 @@
5. Once you finish with the changes you can run tests using: `npm test`
6. Share you changes with the rest of the world by pushing to GitHub :smile:
Для генерации клиентского java-кода используйте команду
`npm run-script build && swagger-codegen generate -i web_deploy/swagger.json -l java -o ./java --api-package "com.rbkmoney.swag.claim_management.client" --artifact-id "swag-claim-management" --artifact-version "1.1.0" --group-id "com.rbkmoney" --model-package "com.rbkmoney.swag.claim_management.model" --library resttemplate --additional-properties dateLibrary=java8`
Пример подключения в проект клиентской зависимости:
Для генерации серверного java-кода используйте команду
`mvn package`
```
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>claim-management</artifactId>
<version>1.45-5184fdc-client</version>
</dependency>
```
Пример подключения в проект серверной зависимости:
```
<dependency>
<groupId>com.rbkmoney</groupId>
<artifactId>claim-management</artifactId>
<version>1.45-5184fdc-server</version>
</dependency>
```
**Нельзя использовать две зависимости одновременно (из-за одинакового пути в package)**

102
pom.xml
View File

@ -35,6 +35,9 @@
<jackson-version>2.8.9</jackson-version>
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
<spring-version>5.1.3.RELEASE</spring-version>
<javax-annotation-api-version>1.3.2</javax-annotation-api-version>
<javax-validation-api-version>1.1.0.Final</javax-validation-api-version>
<jaxb-version>2.3.1</jaxb-version>
</properties>
<dependencies>
@ -109,18 +112,18 @@
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<version>${javax-annotation-api-version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
<version>${jaxb-version}</version>
</dependency>
<!-- Bean Validation API support -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<version>${javax-validation-api-version}</version>
<scope>provided</scope>
</dependency>
@ -132,34 +135,73 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<profiles>
<profile>
<id>server</id>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>generate-server</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>web_deploy/swagger.yaml</inputSpec>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<inputSpec>web_deploy/swagger.yaml</inputSpec>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<language>spring</language>
<library>spring-mvc</library>
<language>spring</language>
<library>spring-mvc</library>
<apiPackage>${default.package}.api</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>client</id>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>generate-client</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>web_deploy/swagger.yaml</inputSpec>
<configOptions>
<dateLibrary>java8</dateLibrary>
</configOptions>
<apiPackage>${default.package}.api</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<language>java</language>
<library>resttemplate</library>
<apiPackage>${default.package}.api</apiPackage>
<modelPackage>${default.package}.model</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>