Skip to content

Commit

Permalink
Gradle (#233)
Browse files Browse the repository at this point in the history
* Build BDK using Gradle

Use Gradle instead of Maven for faster builds thanks to incremental
support!

Most of the configuration is at the root level and applied to all
subprojects. Sub projects mostly define their dependencies.

Use the Java platform support to implement Maven BOM and align
dependencies.
Gradle wrapper can be used to build.
Circle CI configuration has been updated.

Jenkins configuration for release is not yet migrated.
Code coverage configuration for legacy BDK felt off, we need to review
it together.

* Code coverage configuration for legacy

Put back BUNDLE coverage and use the current value for coverage check

* Remove unused method

* Put back Maven wrapper for now

* Support Snyk scan

Repositories were not defined for BOM
  • Loading branch information
symphony-youri committed Sep 21, 2020
1 parent 36a0519 commit d11f39e
Show file tree
Hide file tree
Showing 26 changed files with 831 additions and 53 deletions.
66 changes: 25 additions & 41 deletions .circleci/config.yml
@@ -1,71 +1,47 @@
# Java Maven CircleCI 2.0 configuration file
# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: maven:3.6-amazoncorretto-8

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
- image: cimg/openjdk:8.0

working_directory: ~/repo

environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m

steps:
- checkout

# Download and cache dependencies
- restore_cache:
key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: mvn compile dependency:go-offline

- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}

# run tests!
- run:
name: Verify BDK 2.0
command: mvn verify -P2.0

# when lock file changes, use increasingly general patterns to restore cache
- gradle-repo-v1-{{ .Branch }}-{{ checksum "build.gradle" }}
- gradle-repo-v1-{{ .Branch }}-
- gradle-repo-v1-
# run tests!
- run:
name: Verify legacy projects
command: mvn verify -Plegacy
name: Build
# Jacoco does not support incremental build so we don't run it automatically with check
command: ./gradlew build jacocoTestReport jacocoTestCoverageVerification

- run:
name: Save test results
command: |
mkdir -p ~/test-results/junit/
find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \;
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/test-results/junit/ \;
when: always

- run:
name: Save code coverage BDK 2.0
name: Save code coverage
command: |
mkdir -p ~/code-coverage/jacoco/symphony-bdk-core/
find . -type f -regex ".*/symphony-bdk-core/target/jacoco.exec" -exec cp {} ~/code-coverage/jacoco/symphony-bdk-core/ \;
find . -type d -regex ".*/symphony-bdk-core/target/jacoco-report" -exec cp -r {} ~/code-coverage/jacoco/symphony-bdk-core/ \;
- run:
name: Save code coverage Legacy SDK
command: |
mkdir -p ~/code-coverage/jacoco/symphony-api-client-java/
find . -type f -regex ".*/symphony-api-client-java/target/jacoco.exec" -exec cp {} ~/code-coverage/jacoco/symphony-api-client-java/ \;
find . -type d -regex ".*/symphony-api-client-java/target/jacoco-report" -exec cp -r {} ~/code-coverage/jacoco/symphony-api-client-java/ \;
mkdir -p ~/code-coverage/jacoco/
find . -type d -regex ".*/build/reports/jacoco/test/html" -exec cp --parents -r {} ~/code-coverage/jacoco/ \;
when: always

- store_test_results:
path: ~/test-results
Expand All @@ -76,3 +52,11 @@ jobs:
- store_artifacts:
path: ~/code-coverage/jacoco

- save_cache:
paths:
- ~/.gradle/wrapper
key: v1-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- save_cache:
paths:
- ~/.gradle
key: gradle-repo-v1-{{ .Branch }}-{{ checksum "build.gradle" }}
8 changes: 6 additions & 2 deletions .gitignore
Expand Up @@ -11,10 +11,14 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

target/
*!.mvn/wrapper/maven-wrapper.jar
*.jar

target/

build/
.gradle/
!gradle/wrapper/gradle-wrapper.jar

.DS_Store
settings.xml
datafeed.id
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -31,7 +31,7 @@ public class BotApplication {
```

## Build from Source
The Symphony BDK uses a [Maven](https://maven.apache.org/) build. The instructions below use the [Maven Wrapper](https://github.com/takari/maven-wrapper)
The Symphony BDK uses a [Gradle](https://docs.gradle.org/) build. The instructions below use the [Gradle Wrapper](https://docs.gradle.org/current/userguide/gradle_wrapper.html)
from the root of the source tree. The wrapper script serves as a cross-platform, self-contained bootstrap mechanism for
the build system.

Expand All @@ -42,12 +42,12 @@ Be sure that your `JAVA_HOME` environment variable points to the `jdk1.8+` folde
### Build from the Command Line
To compile, test and build all jars, use:
```shell script
./mvnw clean package
./gradlew
```
### Install in local Maven repository
To install all Symphony BDK jars in your local Maven repository, use:
```shell script
./mvnw clean install
./gradlew publishToMavenLocal
```

## License
Expand Down
64 changes: 64 additions & 0 deletions build.gradle
@@ -0,0 +1,64 @@
allprojects {
group = 'com.symphony.platformsolutions'
version = '1.2.0-SNAPSHOT'

defaultTasks 'build'
}

subprojects {
apply plugin: 'signing'
}

configure(subprojects.findAll { it.name != 'symphony-bdk-bom' }) {
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'

repositories {
mavenCentral()
}

publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}

signing {
sign publishing.publications.maven
}

sourceCompatibility = '1.8'

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

javadoc {
options.addStringOption('Xdoclint:none', '-quiet')
}

java {
withJavadocJar()
withSourcesJar()
}

jar {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": project.version)
}
}

test {
useJUnitPlatform()
}

dependencies {
implementation platform(project(':symphony-bdk-bom'))
annotationProcessor platform(project(':symphony-bdk-bom'))
testAnnotationProcessor platform(project(':symphony-bdk-bom'))
}
}
2 changes: 1 addition & 1 deletion docs/internal/bdk-architecture.md
@@ -1,6 +1,6 @@
# BDK2.0 - Project Architecture

The BDK project is composed in a set of different Maven modules. The approach consists in having one module per BDK
The BDK project is composed in a set of different modules. The approach consists in having one module per BDK
"layer".

## The layers
Expand Down
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit d11f39e

Please sign in to comment.