Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 170 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,190 @@
version: 2
jobs:
build:
version: 2.1

# -------------------------------------------------------------------------------------
# References
# -------------------------------------------------------------------------------------
references:
cache_key: &cache_key v1-jars-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Branch }}-{{ checksum "~/gradle.lock" }}
cache_key_java21: &cache_key_java21 v1-jars-java21-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Branch }}-{{ checksum "~/gradle.lock" }}

# -------------------------------------------------------------------------------------
# Executors
# -------------------------------------------------------------------------------------
executors:
java8-executor:
docker:
- image: cimg/openjdk:8.0.322
environment:
GRADLE_OPTS: "-Djenkins=true -Xmx1024m"
TERM: dumb
CONTAINER_BUILD: "true"

java21-executor:
docker:
- image: circleci/openjdk:8-jdk-browsers
- image: cimg/openjdk:21.0
environment:
GRADLE_OPTS: "-Djenkins=true"
GRADLE_OPTS: "-Xmx1024m"
TERM: dumb
CONTAINER_BUILD: "true"

# -------------------------------------------------------------------------------------
# Commands
# -------------------------------------------------------------------------------------
commands:

save_project:
steps:
- checkout:
path: ~/$CIRCLE_PROJECT_REPONAME
- run:
name: Build and Upload
context: bintray-creds
- run:
name: Save project to workspace
command: |
rm -rf ~/project
cp -a ~/$CIRCLE_PROJECT_REPONAME ~/project

restore_project:
steps:
- run:
name: Restore project from workspace
command: |
cd ~/$CIRCLE_PROJECT_REPONAME
./gradlew clean build publish --refresh-dependencies
rm -rf ~/$CIRCLE_PROJECT_REPONAME
cp -a ~/project ~/$CIRCLE_PROJECT_REPONAME

attach_project:
steps:
- attach_workspace:
at: ~/
- restore_project

persist_project:
steps:
- save_project
- persist_to_workspace:
root: ~/
paths:
- project

collect_test_results:
steps:
- run:
name: Save test results
name: Collect test results
command: |
cd ~/$CIRCLE_PROJECT_REPONAME
mkdir -p ~/junit/
find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} ~/junit/ \;
when: always
- store_test_results:
path: ~/junit
- run:
- store_artifacts:
path: ~/junit

# -------------------------------------------------------------------------------------
# Jobs
# -------------------------------------------------------------------------------------
jobs:

setup:
executor: java8-executor
steps:
- checkout:
path: ~/$CIRCLE_PROJECT_REPONAME
- run:
name: Generate gradle.lock
command: |
find ~/$CIRCLE_PROJECT_REPONAME -type f -name build.gradle | sort -d | awk NF | xargs cat > ~/gradle.lock
- save_project
- persist_to_workspace:
root: ~/
paths:
- gradle.lock
- project

compile:
executor: java8-executor
steps:
- attach_project
- restore_cache:
key: *cache_key
- run:
name: Compile
command: |
cd ~/$CIRCLE_PROJECT_REPONAME
./gradlew compileJava compileTestJava --no-daemon
- save_cache:
paths:
- ~/.gradle
key: *cache_key
- persist_project

test:
executor: java8-executor
steps:
- attach_project
- restore_cache:
key: *cache_key
- run:
name: Run Tests
command: |
cd ~/$CIRCLE_PROJECT_REPONAME
./gradlew test --no-daemon
- collect_test_results

test-java21:
executor: java21-executor
steps:
- attach_project
- restore_cache:
key: *cache_key_java21
- run:
name: Run Tests on Java 21
command: |
cd ~/$CIRCLE_PROJECT_REPONAME
./gradlew test -x compileJava -x compileTestJava --no-daemon
- save_cache:
paths:
- ~/.gradle
key: *cache_key_java21
- collect_test_results

publish:
executor: java8-executor
steps:
- attach_project
- restore_cache:
key: *cache_key
- run:
name: Assemble and Publish
command: |
cd ~/$CIRCLE_PROJECT_REPONAME
./gradlew assemble publish --no-daemon
- run:
name: Save artifacts
command: |
cd ~/$CIRCLE_PROJECT_REPONAME
mkdir -p ~/artifacts/
find . -type f -regex ".*/build/libs/.*jar" -exec cp {} ~/artifacts/ \;
- store_artifacts:
path: ~/artifacts
path: ~/artifacts

# -------------------------------------------------------------------------------------
# Workflows
# -------------------------------------------------------------------------------------
workflows:
build_test_publish:
jobs:
- setup
- compile:
context: cloudsmith-creds
requires:
- setup
- test:
context: cloudsmith-creds
requires:
- compile
- test-java21:
context: cloudsmith-creds
requires:
- compile
- publish:
context: cloudsmith-creds
requires:
- test
- test-java21
101 changes: 66 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,22 @@ buildscript {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
// Spotless needs Java 17 to run, and this build also runs on Java 8
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
classpath 'com.diffplug.spotless:spotless-plugin-gradle:8.2.1'
}
}
}

plugins {
id 'java'
id 'maven'
id 'java-library'
id 'eclipse'
id 'maven-publish'
}

publishing {
repositories {
maven {
name = 'cloudsmith'
def releasesRepoUrl = "https://api-g.cloudsmith.io/maven/cinchapi/platform/"
def snapshotsRepoUrl = "https://api-g.cloudsmith.io/maven/cinchapi/platform-snapshots/"
// Only a master build publishes a plain X.Y.Z, so every other version,
// such as a release candidate or a feature build, is a snapshot.
url = (mavenVersion ==~ /\d+\.\d+\.\d+/) ? releasesRepoUrl : snapshotsRepoUrl
credentials {
username = System.getenv('CLOUDSMITH_API_USER')
password = System.getenv('CLOUDSMITH_API_KEY')
}
}
}
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId group
artifactId project.name
version mavenVersion
}
}
wrapper {
gradleVersion = '8.14.3'
}

// The project version is controlled externally by the "version.sh" script.
Expand Down Expand Up @@ -116,18 +98,25 @@ if (JavaVersion.current().isJava8Compatible()) {
}
}

// Target Java 8, even when a newer JDK runs the build
if (JavaVersion.current().isJava9Compatible()) {
tasks.withType(JavaCompile).configureEach {
options.release = 8
}
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

task testJar(type: Jar, dependsOn: classes) {
classifier = 'tests'
archiveClassifier = 'tests'
from sourceSets.test.output
}

Expand All @@ -140,17 +129,59 @@ artifacts {
// Ensure that these transitive dependencies are excluded so we don't get version clashes
def exclusions = [[group : 'com.google.guava', module: 'guava']]
exclusions.each { exclusion ->
configurations.compile.dependencies.all {
configurations.implementation.dependencies.all {
if (name != exclusion.module || group != exclusion.group) {
exclude group: exclusion.group, module: exclusion.module
}
}
}

dependencies {
compile 'com.google.guava:guava:25.1-jre'
compile group: 'com.cinchapi', name: 'accent4j', version: '1.5.3', changing:true
compile 'org.apache.commons:commons-csv:1.6'
api platform('com.cinchapi:cinchapi-bom:1.0.0')
implementation 'com.google.guava:guava'
implementation group: 'com.cinchapi', name: 'accent4j'
implementation 'org.apache.commons:commons-csv:1.6'

testCompile 'junit:junit:4.11'
testImplementation 'junit:junit'
}

publishing {
repositories {
maven {
name = 'cloudsmith'
def releasesRepoUrl = "https://api-g.cloudsmith.io/maven/cinchapi/platform/"
def snapshotsRepoUrl = "https://api-g.cloudsmith.io/maven/cinchapi/platform-snapshots/"
// Only a master build publishes a plain X.Y.Z, so every other version,
// such as a release candidate or a feature build, is a snapshot.
url = (mavenVersion ==~ /\d+\.\d+\.\d+/) ? releasesRepoUrl : snapshotsRepoUrl
credentials {
username = System.getenv('CLOUDSMITH_API_USER')
password = System.getenv('CLOUDSMITH_API_KEY')
}
}
}
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
groupId group
artifactId project.name
version mavenVersion
}
}
}

// Format with the Cinchapi formatter when the build runs on Java 17 or later.
// The repo's own copyright headers stay as they are, so there is no license
// header step, and the Eclipse profile leaves header comments alone.
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
apply plugin: 'com.diffplug.spotless'
spotless {
java {
target 'src/*/java/**/*.java'
importOrderFile 'spotless.java.importerorder'
eclipse().configFile 'spotless.java.eclipseformat.xml'
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Tue Jun 19 17:13:15 PDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-bin.zip
Loading