Skip to content

Commit 906effb

Browse files
Merge pull request #3 from sailthru/LT-1633-update-gradle-and-circleci-config
[LT-1633] update Gradle build and CircleCI config
2 parents ec34971 + 27cd1c1 commit 906effb

File tree

12 files changed

+386
-343
lines changed

12 files changed

+386
-343
lines changed

.circleci/config.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
version: '2.1'
2+
orbs:
3+
jvm: sailthru/[email protected]
4+
5+
parameters:
6+
publish_snapshot:
7+
description: Flag indicating a SNAPSHOT version should be built for this branch
8+
type: boolean
9+
default: false
10+
11+
workflows:
12+
build:
13+
unless: << pipeline.parameters.publish_snapshot >>
14+
jobs:
15+
- jvm/test:
16+
context:
17+
- Docker Hub
18+
- Nexus Credentials
19+
filters:
20+
branches:
21+
only: /.*/
22+
tags:
23+
ignore: /.*/
24+
25+
publish:
26+
jobs:
27+
- jvm/publish_jar:
28+
context:
29+
- Docker Hub
30+
- Nexus Credentials
31+
filters:
32+
branches:
33+
ignore: /.*/
34+
tags:
35+
only: /^v\d+.\d+.\d+$/
36+
version: ${CIRCLE_TAG}
37+
38+
publish_snapshot:
39+
when: << pipeline.parameters.publish_snapshot >>
40+
jobs:
41+
- jvm/publish_jar:
42+
name: Publish SNAPSHOT JAR
43+
context:
44+
- Docker Hub
45+
filters:
46+
branches:
47+
only: /.*/
48+
tags:
49+
ignore: /.*/
50+
# add "v" in front so the branch is > than actual version tags
51+
version: v${CIRCLE_BRANCH}-SNAPSHOT

.github/workflows/build.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

README.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ JsonLogic is documented extensively at [JsonLogic.com](http://jsonlogic.com), in
99

1010
```xml
1111
<dependency>
12-
<groupId>io.github.jamsesso</groupId>
12+
<groupId>com.sailthru</groupId>
1313
<artifactId>json-logic-java</artifactId>
14-
<version>1.1.0</version>
14+
<version>2.0.0</version>
1515
</dependency>
1616
```
1717

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

5757
// etc...
5858
```
59+
60+
## Usage:
61+
62+
### Update dependencies:
63+
```bash
64+
./gradlew dependencies --write-locks
65+
```
66+
67+
### Local testing
68+
To "publish" a version locally for testing run:
69+
```bash
70+
./gradlew publishToMavenLocal
71+
```
72+
73+
This will publish a copy of the library to maven local that will be accessible within other libraries/services.
74+
75+
Inside your other project update the version of the dependency to `vSANDBOX` to access the library.
76+
77+
For example:
78+
```
79+
implementation("com.sailthru:json-logic-java:v2.0.0")
80+
// Becomes
81+
implementation("com.sailthru:json-logic-java:vSANDBOX")
82+
```
83+
84+
## Contents:
85+
This template contains the bare minimal requirements to create and publish a Java library.
86+
87+
### CI/CD
88+
CI/CD is provided by CircleCI. Specifically the [Sailthru JVM orb](https://circleci.com/developer/orbs/orb/sailthru/jvm).
89+
90+
Every branch is tested using the `./gradlew check` command.
91+
92+
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).
93+
Within this release you will need to create a semantic version tag in the format `vMAJOR.MINOR.PATCH` for example `v1.0.1`.
94+
95+
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).
96+
97+
### Gradle
98+
Most Gradle logic will be contained within our [Sailthru gradle plugin (gradle-config)](https://github.com/sailthru/gradle-config).
99+
100+
All projects require dependency locking, connecting to CodeArtifact as a source, and to use Checkstyle (this can be disabled if required).
101+
102+
Library projects also include support to publish to CodeArtifact.

build.gradle

Lines changed: 11 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,19 @@
1+
import com.sailthru.gradle.ProjectType
2+
13
plugins {
2-
id "java"
3-
id "maven"
4-
id "signing"
4+
id("java-library")
5+
id("com.sailthru.gradle") version("v0.16.0")
56
}
67

7-
group "io.github.jamsesso"
8-
version "1.1.1-SNAPSHOT"
9-
10-
sourceCompatibility = 1.8
11-
targetCompatibility = 1.8
12-
13-
repositories {
14-
mavenCentral()
15-
}
8+
group "com.sailthru"
169

1710
dependencies {
18-
compile "com.google.code.gson:gson:2.8.5"
19-
testCompile "junit:junit:4.12"
20-
}
21-
22-
task javadocJar(type: Jar, dependsOn: javadoc) {
23-
classifier = "javadoc"
24-
from javadoc.destinationDir
25-
}
26-
27-
task sourcesJar(type: Jar) {
28-
classifier = "sources"
29-
from sourceSets.main.allSource
30-
}
31-
32-
test {
33-
testLogging {
34-
events "passed", "skipped", "failed"
35-
exceptionFormat "full"
36-
showStandardStreams = true
37-
}
38-
}
39-
40-
artifacts {
41-
archives jar, javadocJar, sourcesJar
42-
}
43-
44-
def getSonatypeUsername() {
45-
return System.getenv('SONATYPE_USERNAME')
46-
}
47-
48-
def getSonatypePassword() {
49-
return System.getenv('SONATYPE_PASSWORD')
50-
}
51-
52-
def hasCredentials() {
53-
def result = getSonatypeUsername() != null && getSonatypePassword() != null
54-
if (!result) {
55-
println "Cannot publish package since Sonatype credentials are not set. Please set SONATYPE_USERNAME and SONATYPE_PASSWORD environment variables."
56-
}
57-
return result
58-
}
59-
60-
signing {
61-
required { gradle.taskGraph.hasTask("uploadArchives") }
62-
useInMemoryPgpKeys(System.getenv('SIGNING_KEY'), System.getenv('SIGNING_PASSWORD'))
63-
sign configurations.archives
11+
implementation('com.google.code.gson:gson:2.13.1')
12+
testImplementation('junit:junit:4.13.2')
6413
}
6514

66-
uploadArchives {
67-
repositories {
68-
mavenDeployer {
69-
beforeDeployment { deployment -> signing.signPom(deployment) }
70-
71-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
72-
authentication(userName: getSonatypeUsername(), password: getSonatypePassword())
73-
}
74-
75-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
76-
authentication(userName: getSonatypeUsername(), password: getSonatypePassword())
77-
}
78-
79-
pom.project {
80-
name "json-logic-java"
81-
artifactId "json-logic-java"
82-
packaging "jar"
83-
description "A native Java implementation of the json-logic project"
84-
url "https://github.com/jamsesso/json-logic-java"
85-
86-
scm {
87-
connection "scm:[email protected]:jamsesso/json-logic-java.git"
88-
developerConnection "scm:[email protected]:jamsesso/json-logic-java.git"
89-
url "https://github.com/jamsesso/json-logic-java.git"
90-
}
91-
92-
licenses {
93-
license {
94-
name "MIT License"
95-
url "https://github.com/jamsesso/json-logic-java/blob/master/LICENSE"
96-
}
97-
}
98-
99-
developers {
100-
developer {
101-
id "jamsesso"
102-
name "Sam Jesso"
103-
104-
}
105-
}
106-
}
107-
}
108-
}
109-
onlyIf { hasCredentials() }
15+
sailthru {
16+
type = ProjectType.LIBRARY
17+
javaVersion = JavaVersion.VERSION_1_8
18+
checkstyleEnabled = false
11019
}

gradle.lockfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This is a Gradle generated file for dependency locking.
2+
# Manual edits can break the build and are not advised.
3+
# This file is expected to be part of source control.
4+
com.google.code.findbugs:jsr305:3.0.2=checkstyle
5+
com.google.code.gson:gson:2.13.1=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
6+
com.google.errorprone:error_prone_annotations:2.38.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
7+
com.google.errorprone:error_prone_annotations:2.7.1=checkstyle
8+
com.google.guava:failureaccess:1.0.1=checkstyle
9+
com.google.guava:guava:31.0.1-jre=checkstyle
10+
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=checkstyle
11+
com.google.j2objc:j2objc-annotations:1.3=checkstyle
12+
com.puppycrawl.tools:checkstyle:9.3=checkstyle
13+
commons-beanutils:commons-beanutils:1.9.4=checkstyle
14+
commons-collections:commons-collections:3.2.2=checkstyle
15+
info.picocli:picocli:4.6.2=checkstyle
16+
junit:junit:4.13.2=testCompileClasspath,testRuntimeClasspath
17+
net.sf.saxon:Saxon-HE:10.6=checkstyle
18+
org.antlr:antlr4-runtime:4.9.3=checkstyle
19+
org.checkerframework:checker-qual:3.12.0=checkstyle
20+
org.hamcrest:hamcrest-core:1.3=testCompileClasspath,testRuntimeClasspath
21+
org.javassist:javassist:3.28.0-GA=checkstyle
22+
org.reflections:reflections:0.10.2=checkstyle
23+
empty=annotationProcessor,testAnnotationProcessor

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=vSANDBOX

gradle/wrapper/gradle-wrapper.jar

-10.3 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
#Mon Jul 02 21:26:44 ADT 2018
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip

0 commit comments

Comments
 (0)