Skip to content
Merged
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
51 changes: 51 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: '2.1'
orbs:
jvm: sailthru/jvm@0.4.3

parameters:
publish_snapshot:
description: Flag indicating a SNAPSHOT version should be built for this branch
type: boolean
default: false

workflows:
build:
unless: << pipeline.parameters.publish_snapshot >>
jobs:
- jvm/test:
context:
- Docker Hub
- Nexus Credentials
filters:
branches:
only: /.*/
tags:
ignore: /.*/

publish:
jobs:
- jvm/publish_jar:
context:
- Docker Hub
- Nexus Credentials
filters:
branches:
ignore: /.*/
tags:
only: /^v\d+.\d+.\d+$/
version: ${CIRCLE_TAG}

publish_snapshot:
when: << pipeline.parameters.publish_snapshot >>
jobs:
- jvm/publish_jar:
name: Publish SNAPSHOT JAR
context:
- Docker Hub
filters:
branches:
only: /.*/
tags:
ignore: /.*/
# add "v" in front so the branch is > than actual version tags
version: v${CIRCLE_BRANCH}-SNAPSHOT
25 changes: 0 additions & 25 deletions .github/workflows/build.yml

This file was deleted.

63 changes: 0 additions & 63 deletions .github/workflows/publish.yml

This file was deleted.

48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ JsonLogic is documented extensively at [JsonLogic.com](http://jsonlogic.com), in

```xml
<dependency>
<groupId>io.github.jamsesso</groupId>
<groupId>com.sailthru</groupId>
<artifactId>json-logic-java</artifactId>
<version>1.1.0</version>
<version>2.0.0</version>
</dependency>
```

Expand Down Expand Up @@ -56,3 +56,47 @@ assert JsonLogic.truthy("Hello world!") == true;

// etc...
```

## Usage:

### Update dependencies:
```bash
./gradlew dependencies --write-locks
```

### Local testing
To "publish" a version locally for testing run:
```bash
./gradlew publishToMavenLocal
```

This will publish a copy of the library to maven local that will be accessible within other libraries/services.

Inside your other project update the version of the dependency to `vSANDBOX` to access the library.

For example:
```
implementation("com.sailthru:json-logic-java:v2.0.0")
// Becomes
implementation("com.sailthru:json-logic-java:vSANDBOX")
```

## Contents:
This template contains the bare minimal requirements to create and publish a Java library.

### CI/CD
CI/CD is provided by CircleCI. Specifically the [Sailthru JVM orb](https://circleci.com/developer/orbs/orb/sailthru/jvm).

Every branch is tested using the `./gradlew check` command.

To publish a release you must [create a GitHub Release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release).
Within this release you will need to create a semantic version tag in the format `vMAJOR.MINOR.PATCH` for example `v1.0.1`.

Once a tag is created CircleCI will automatically detect this and publish the JAR to [CodeArtifact](https://us-east-1.console.aws.amazon.com/codesuite/codeartifact/d/680305091011/sailthru/r/maven).

### Gradle
Most Gradle logic will be contained within our [Sailthru gradle plugin (gradle-config)](https://github.com/sailthru/gradle-config).

All projects require dependency locking, connecting to CodeArtifact as a source, and to use Checkstyle (this can be disabled if required).

Library projects also include support to publish to CodeArtifact.
113 changes: 11 additions & 102 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,110 +1,19 @@
import com.sailthru.gradle.ProjectType

plugins {
id "java"
id "maven"
id "signing"
id("java-library")
id("com.sailthru.gradle") version("v0.16.0")
}

group "io.github.jamsesso"
version "1.1.1-SNAPSHOT"

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}
group "com.sailthru"

dependencies {
compile "com.google.code.gson:gson:2.8.5"
testCompile "junit:junit:4.12"
}

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

task sourcesJar(type: Jar) {
classifier = "sources"
from sourceSets.main.allSource
}

test {
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
showStandardStreams = true
}
}

artifacts {
archives jar, javadocJar, sourcesJar
}

def getSonatypeUsername() {
return System.getenv('SONATYPE_USERNAME')
}

def getSonatypePassword() {
return System.getenv('SONATYPE_PASSWORD')
}

def hasCredentials() {
def result = getSonatypeUsername() != null && getSonatypePassword() != null
if (!result) {
println "Cannot publish package since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables."
}
return result
}

signing {
required { gradle.taskGraph.hasTask("uploadArchives") }
useInMemoryPgpKeys(System.getenv('SIGNING_KEY'), System.getenv('SIGNING_PASSWORD'))
sign configurations.archives
implementation('com.google.code.gson:gson:2.13.1')
testImplementation('junit:junit:4.13.2')
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: getSonatypeUsername(), password: getSonatypePassword())
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: getSonatypeUsername(), password: getSonatypePassword())
}

pom.project {
name "json-logic-java"
artifactId "json-logic-java"
packaging "jar"
description "A native Java implementation of the json-logic project"
url "https://github.com/jamsesso/json-logic-java"

scm {
connection "scm:git@github.com:jamsesso/json-logic-java.git"
developerConnection "scm:git@github.com:jamsesso/json-logic-java.git"
url "https://github.com/jamsesso/json-logic-java.git"
}

licenses {
license {
name "MIT License"
url "https://github.com/jamsesso/json-logic-java/blob/master/LICENSE"
}
}

developers {
developer {
id "jamsesso"
name "Sam Jesso"
email "samuel.jesso@gmail.com"
}
}
}
}
}
onlyIf { hasCredentials() }
sailthru {
type = ProjectType.LIBRARY
javaVersion = JavaVersion.VERSION_1_8
checkstyleEnabled = false
}
23 changes: 23 additions & 0 deletions gradle.lockfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
com.google.code.findbugs:jsr305:3.0.2=checkstyle
com.google.code.gson:gson:2.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.38.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
com.google.errorprone:error_prone_annotations:2.7.1=checkstyle
com.google.guava:failureaccess:1.0.1=checkstyle
com.google.guava:guava:31.0.1-jre=checkstyle
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=checkstyle
com.google.j2objc:j2objc-annotations:1.3=checkstyle
com.puppycrawl.tools:checkstyle:9.3=checkstyle
commons-beanutils:commons-beanutils:1.9.4=checkstyle
commons-collections:commons-collections:3.2.2=checkstyle
info.picocli:picocli:4.6.2=checkstyle
junit:junit:4.13.2=testCompileClasspath,testRuntimeClasspath
net.sf.saxon:Saxon-HE:10.6=checkstyle
org.antlr:antlr4-runtime:4.9.3=checkstyle
org.checkerframework:checker-qual:3.12.0=checkstyle
org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath
org.javassist:javassist:3.28.0-GA=checkstyle
org.reflections:reflections:0.10.2=checkstyle
empty=annotationProcessor,testAnnotationProcessor
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=vSANDBOX
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 @@
#Mon Jul 02 21:26:44 ADT 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-6.5.1-bin.zip
Loading