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

3
.gitignore vendored
View File

@ -59,3 +59,6 @@ package-lock.json
# Gradle: # Gradle:
.idea/gradle.xml .idea/gradle.xml
.idea/libraries .idea/libraries
# Idea
*.iml

8
Jenkinsfile vendored
View File

@ -23,12 +23,14 @@ build('swag-claim-management', 'docker-host') {
} }
// Java // Java
runStage('Execute build container') { runStage('Build client & server') {
withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) { withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) {
if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) { if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('epic/')) {
sh 'make SETTINGS_XML=${SETTINGS_XML} BRANCH_NAME=${BRANCH_NAME} wc_java.deploy' 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 { } else {
sh 'make SETTINGS_XML=${SETTINGS_XML} wc_java.compile' 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)" 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 java.compile: java.settings
$(MVN) compile $(MVN) compile

View File

@ -18,8 +18,24 @@
5. Once you finish with the changes you can run tests using: `npm test` 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: 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)**

50
pom.xml
View File

@ -35,6 +35,9 @@
<jackson-version>2.8.9</jackson-version> <jackson-version>2.8.9</jackson-version>
<jackson-threetenbp-version>2.6.4</jackson-threetenbp-version> <jackson-threetenbp-version>2.6.4</jackson-threetenbp-version>
<spring-version>5.1.3.RELEASE</spring-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> </properties>
<dependencies> <dependencies>
@ -109,18 +112,18 @@
<dependency> <dependency>
<groupId>javax.annotation</groupId> <groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId> <artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version> <version>${javax-annotation-api-version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.xml.bind</groupId> <groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId> <artifactId>jaxb-api</artifactId>
<version>2.3.1</version> <version>${jaxb-version}</version>
</dependency> </dependency>
<!-- Bean Validation API support --> <!-- Bean Validation API support -->
<dependency> <dependency>
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId> <artifactId>validation-api</artifactId>
<version>1.1.0.Final</version> <version>${javax-validation-api-version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -132,6 +135,9 @@
</dependency> </dependency>
</dependencies> </dependencies>
<profiles>
<profile>
<id>server</id>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -140,12 +146,12 @@
<version>2.3.1</version> <version>2.3.1</version>
<executions> <executions>
<execution> <execution>
<id>generate-server</id>
<phase>generate-sources</phase> <phase>generate-sources</phase>
<goals> <goals>
<goal>generate</goal> <goal>generate</goal>
</goals> </goals>
<configuration> <configuration>
<inputSpec>web_deploy/swagger.yaml</inputSpec> <inputSpec>web_deploy/swagger.yaml</inputSpec>
<configOptions> <configOptions>
<dateLibrary>java8</dateLibrary> <dateLibrary>java8</dateLibrary>
@ -162,4 +168,40 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </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>
<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> </project>