Skip to content

Commit f166496

Browse files
authored
Merge pull request #16 from devatherock/generic-publish
chore: Made publish.gradle generic
2 parents b4c8be7 + 2c33902 commit f166496

4 files changed

Lines changed: 69 additions & 27 deletions

File tree

.circleci/config.yml

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ slack_image: &slack_image
44
auth:
55
username: $DOCKER_USERNAME
66
password: $DOCKER_PASSWORD
7-
8-
orbs:
9-
gradle: circleci/gradle@2.2.0
107

118
work_directory: &work_directory
129
working_directory: ~/jul-jsonformatter
@@ -43,6 +40,51 @@ jobs:
4340
steps:
4441
- checkout
4542
- run: sh /scripts/entry-point.sh
43+
44+
test:
45+
executor: jdk-executor
46+
steps:
47+
- checkout
48+
- attach_workspace:
49+
at: ~/jul-jsonformatter
50+
- restore_cache:
51+
keys:
52+
- v1-dependencies-{{ checksum "build.gradle" }}
53+
- v1-dependencies
54+
- run: |
55+
./gradlew check coveralls -x test
56+
- store_test_results:
57+
path: build/test-results
58+
build:
59+
executor: jdk-executor
60+
steps:
61+
- checkout
62+
- attach_workspace:
63+
at: ~/jul-jsonformatter
64+
- restore_cache:
65+
keys:
66+
- v1-dependencies-{{ checksum "build.gradle" }}
67+
- v1-dependencies
68+
- run: |
69+
./gradlew build publishToSonatype coveralls sonarqube -Dsnapshot=true -Dsonar.login=$SONAR_TOKEN -x test
70+
- save_cache:
71+
paths:
72+
- ~/.gradle
73+
key: v1-dependencies-{{ checksum "build.gradle" }}
74+
- store_test_results:
75+
path: build/test-results
76+
publish:
77+
executor: jdk-executor
78+
steps:
79+
- checkout
80+
- attach_workspace:
81+
at: ~/jul-jsonformatter
82+
- restore_cache:
83+
keys:
84+
- v1-dependencies-{{ checksum "build.gradle" }}
85+
- v1-dependencies
86+
- run: |
87+
./gradlew build publishToSonatype -x test
4688
4789
notify:
4890
<<: *slack_image
@@ -58,17 +100,14 @@ workflows:
58100
version: 2.1
59101
build_test:
60102
jobs:
61-
- gradle/run:
62-
name: build
63-
executor: jdk-executor
103+
- build:
64104
context:
65105
- docker-credentials
66106
- sonatype-credentials
67107
- sonar-credentials
68108
filters:
69109
branches:
70110
only: master
71-
command: build publishToSonatype coveralls sonarqube -Dsnapshot=true -Dsonar.login=$SONAR_TOKEN -x test
72111
- notify:
73112
context:
74113
- docker-credentials
@@ -77,9 +116,7 @@ workflows:
77116
- build
78117
publish_artifacts:
79118
jobs:
80-
- gradle/run:
81-
name: publish
82-
executor: jdk-executor
119+
- publish:
83120
context:
84121
- docker-credentials
85122
- sonatype-credentials
@@ -88,7 +125,6 @@ workflows:
88125
only: non-existent-branch
89126
tags:
90127
only: /^v[0-9\.]+$/
91-
command: build publishToSonatype -x test
92128
- notify:
93129
context:
94130
- docker-credentials
@@ -102,12 +138,9 @@ workflows:
102138
- docker-credentials
103139
- changelog-updater-credentials
104140
<<: *pr_filter
105-
- gradle/test:
106-
name: test
107-
executor: jdk-executor
141+
- test:
108142
context:
109143
- docker-credentials
110144
<<: *pr_filter
111-
test_command: check coveralls -x test
112145
requires:
113146
- changelog_updater

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
### Changed
88
- Publication of artifacts to Sonatype Nexus due to bintray sunset
99
- Upgraded dependency versions
10+
- Made `publish.gradle` generic so that it can be moved to `gradle-includes`
11+
- Refactored CI pipeline with proper gradle caching
1012

1113
## [1.1.0] - 2020-10-06
1214
### Added

build.gradle

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ plugins {
1212

1313
sourceCompatibility = 1.7
1414
targetCompatibility = 1.7
15-
group = "io.github.devatherock"
16-
version = '1.2.0' + (Boolean.valueOf(System.getProperty("snapshot")) ? "-SNAPSHOT" : "")
15+
group = 'io.github.devatherock'
16+
description = 'java.util.logging.Formatter to log messages as JSON, compatible with Logstash'
17+
version = (System.env.CIRCLE_TAG ? System.env.CIRCLE_TAG.substring(1): '1.2.0') +
18+
(Boolean.valueOf(System.getProperty("snapshot")) ? "-SNAPSHOT" : "")
1719

1820
repositories {
1921
mavenCentral()
2022
}
2123

22-
project.ext.jsonSimpleVersion = '1.1.1'
23-
project.ext.gsonVersion = '2.9.0'
24-
project.ext.jacksonVersion = '2.13.2.2'
24+
ext {
25+
jsonSimpleVersion = '1.1.1'
26+
gsonVersion = '2.9.0'
27+
jacksonVersion = '2.13.2.2'
28+
29+
// Properties for publishing
30+
licenseUrl = 'https://github.com/devatherock/jul-jsonformatter/blob/master/LICENSE.txt'
31+
scmUrl = 'https://github.com/devatherock/jul-jsonformatter/'
32+
}
2533

2634
dependencies {
2735
compileOnly group: 'com.googlecode.json-simple', name: 'json-simple', version: jsonSimpleVersion

publish.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ artifacts {
1717
def pomConfig = {
1818
licenses {
1919
license {
20-
name 'MIT License'
21-
url 'https://github.com/devatherock/jul-jsonformatter/blob/master/LICENSE.txt'
20+
name (project.ext.has('licenseType') ? project['licenseType'] : 'MIT License')
21+
url (project.ext.has('licenseUrl') ? project['licenseUrl'] : 'https://mit-license.org/')
2222
}
2323
}
2424

@@ -31,11 +31,10 @@ def pomConfig = {
3131
}
3232

3333
scm {
34-
url 'https://github.com/devatherock/jul-jsonformatter/'
34+
url project['scmUrl']
3535
}
3636
}
3737

38-
def projectDescription = 'java.util.logging.Formatter to log messages as JSON, compatible with Logstash'
3938
project.afterEvaluate {
4039
publishing {
4140
publications {
@@ -52,9 +51,9 @@ project.afterEvaluate {
5251
version "${project.version}"
5352
pom.withXml {
5453
def root = asNode()
55-
root.appendNode('description', projectDescription)
56-
root.appendNode('name', "${project.name}")
57-
root.appendNode('url', 'https://github.com/devatherock/jul-jsonformatter')
54+
root.appendNode('description', project.description)
55+
root.appendNode('name', project.name)
56+
root.appendNode('url', project['scmUrl'])
5857
root.children().last() + pomConfig
5958
}
6059
}

0 commit comments

Comments
 (0)