Skip to content

Commit d8b212c

Browse files
authored
Refactoring and upgrades
1 parent e6fb852 commit d8b212c

File tree

20 files changed

+1077
-253
lines changed

20 files changed

+1077
-253
lines changed

.editorconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# .editorconfig
2+
# http://editorconfig.org/
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
indent_size = 2
10+
indent_style = space
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.{js,py,java,xml}]
15+
indent_size = 4
16+
17+
[*.go]
18+
indent_style = tab
19+
indent_size = 4
20+
21+
[*.md]
22+
# Preserve trailing whitespace for Markdown files
23+
trim_trailing_whitespace = false

.github/workflows/publish.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: publish
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
publish-to-sonatype:
7+
name: Publish Maven distribution 📦 to Sonatype
8+
runs-on: ubuntu-latest
9+
permissions:
10+
id-token: write
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up JDK
14+
uses: actions/setup-java@v4
15+
with:
16+
distribution: temurin
17+
java-version: '17'
18+
- name: Publish
19+
env:
20+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SEGENCE_SIGNINGKEY }}
21+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SEGENCE_SIGNINGPASSWORD }}
22+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
23+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
24+
run: make publish

.github/workflows/tag.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: tag
2+
on:
3+
workflow_run:
4+
workflows:
5+
- test
6+
branches:
7+
- main
8+
- dev
9+
types:
10+
- completed
11+
jobs:
12+
tag:
13+
name: Tag the repository
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
16+
permissions:
17+
contents: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: '0'
22+
- name: Bump version and push tag
23+
uses: anothrNick/github-tag-action@v1
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
WITH_V: true
27+
PRERELEASE_SUFFIX: dev
28+
PRERELEASE: ${{ github.ref_name != 'main' }}

.github/workflows/test.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- dev
7+
paths-ignore:
8+
- 'README.md'
9+
pull_request:
10+
jobs:
11+
test:
12+
name: Run tests
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
java-version: [ "17" ]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up JDK ${{ matrix.java-version }}
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: temurin
23+
java-version: ${{ matrix.java-version }}
24+
- name: Unit testing
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
28+
run: make unit-test-publish-report
29+
- name: Static Analysis
30+
run: make static-analysis
31+
# - name: Security Analysis
32+
# env:
33+
# NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
34+
# run: make security-analysis

.travis.yml

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

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
FONT_ESC := $(shell printf '\033')
2+
FONT_BOLD := ${FONT_ESC}[1m
3+
FONT_NC := ${FONT_ESC}[0m # No colour
4+
5+
VERSION := $(shell git describe --tags --match 'v*' --abbrev=0 | cut -c2-)
6+
7+
all:
8+
@echo "Use a specific goal. To list all goals, type 'make help'"
9+
10+
.PHONY: version # Prints project version
11+
version:
12+
@echo $(VERSION)
13+
14+
.PHONY: dependencies # Lists project dependencies
15+
dependencies:
16+
@./gradlew clean dependencies
17+
18+
.PHONY: unit-test # Runs unit tests
19+
unit-test:
20+
@./gradlew clean unitTest
21+
22+
.PHONY: unit-test-publish-report # Runs unit tests and publishes report
23+
unit-test-publish-report:
24+
@./gradlew clean unitTest coveralls
25+
26+
.PHONY: build # Builds artifacts
27+
build:
28+
@./gradlew clean build
29+
30+
.PHONY: static-analysis # Analyzes the build
31+
static-analysis:
32+
@./gradlew clean check
33+
34+
.PHONY: security-analysis # Runs security analysis looking for vulnerabilities in code
35+
security-analysis:
36+
@./gradlew clean dependencyCheckAnalyze
37+
38+
.PHONY: publish # Publishes artifacts to the configured remote repository
39+
publish:
40+
@./gradlew clean signMavenPublication -Pversion=$(VERSION)
41+
@./gradlew publishMavenPublicationToMavenCentralRepository -Pversion=$(VERSION)
42+
43+
.PHONY: help # Generate list of goals with descriptions
44+
help:
45+
@echo "Available goals:\n"
46+
@grep '^.PHONY: .* #' Makefile | sed "s/\.PHONY: \(.*\) # \(.*\)/${FONT_BOLD}\1:${FONT_NC}\2~~/" | sed $$'s/~~/\\\n/g' | sed $$'s/~/\\\n\\\t/g'

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
JMX Collector
22
=============
33

4-
[![Build Status](https://travis-ci.org/Segence/jmx-collector.svg?branch=master)](https://travis-ci.org/Segence/jmx-collector)
5-
[ ![Download](https://api.bintray.com/packages/segence/maven-oss-releases/jmx-collector/images/download.svg) ](https://bintray.com/segence/maven-oss-releases/jmx-collector/_latestVersion)
4+
![Workflow Status](https://github.com/segence/jmx-collector/actions/workflows/test.yaml/badge.svg)
5+
[![Coverage Status](https://coveralls.io/repos/github/Segence/jmx-collector/badge.svg?branch=main)](https://coveralls.io/github/Segence/jmx-collector?branch=main)
66

77
A library to collect JMX metrics.
88

@@ -32,4 +32,4 @@ Map<ObjectName, Set<String>> mbeansAndAttributesToQuery = new HashMap<ObjectName
3232
}};
3333

3434
Set<MBeanMetricResult> results = JmxCollector.queryAsSet(mbeansAndAttributesToQuery);
35-
```
35+
```

build.gradle

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,38 @@
11
plugins {
2-
id 'com.palantir.jacoco-full-report' version '0.4.0'
3-
id 'com.jfrog.bintray' version '1.7.3'
2+
id 'com.github.spotbugs' version '6.0.26' apply false
3+
id 'checkstyle'
4+
id 'org.owasp.dependencycheck' version '11.1.0'
5+
id 'com.github.kt3k.coveralls' version '2.12.2'
6+
id 'com.vanniktech.maven.publish' version '0.30.0'
47
}
58

6-
apply plugin: 'java'
7-
apply plugin: 'maven'
8-
apply plugin: 'maven-publish'
9-
apply plugin: 'com.palantir.jacoco-full-report'
10-
apply plugin: 'com.jfrog.bintray'
11-
12-
sourceCompatibility = 1.8
13-
targetCompatibility = 1.8
14-
15-
group = 'com.segence.commons'
9+
apply plugin: 'org.owasp.dependencycheck'
1610

1711
repositories {
18-
mavenCentral()
19-
}
20-
21-
bintray {
22-
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
23-
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
24-
publications = ['ProjectPublication']
25-
pkg {
26-
repo = 'maven-oss-releases'
27-
name = 'jmx-collector'
28-
userOrg = 'segence'
29-
licenses = ['Apache-2.0']
30-
vcsUrl = 'https://github.com/segence/jmx-collector.git'
12+
mavenLocal()
13+
maven {
14+
url = "https://repo.maven.apache.org/maven2"
15+
}
16+
maven {
17+
url = "https://repo1.maven.org/maven2"
3118
}
3219
}
3320

34-
task wrapper(type: Wrapper) {
35-
gradleVersion = gradleWrapperVersion
21+
tasks.withType(Copy).all {
22+
duplicatesStrategy 'exclude'
3623
}
3724

38-
task printVersion {
39-
doLast {
40-
println project.version
41-
}
25+
dependencyCheck {
26+
nvd.apiKey = System.getenv("NVD_API_KEY")
27+
nvd.datafeedUrl = "https://mirror.cveb.in/nvd/json/cve/1.1/nvdcve-1.1-{0}.json.gz"
4228
}
4329

44-
task sourceJar(type: Jar) {
45-
from sourceSets.main.allJava
46-
}
30+
apply from: 'gradle/java.gradle'
4731

4832
dependencies {
49-
testCompile(
50-
"junit:junit:${junitVersion}",
51-
"org.hamcrest:hamcrest-all:${hamcrestVersion}"
33+
testImplementation (
34+
"org.junit.jupiter:junit-jupiter-api:${junitVersion}",
35+
"org.junit.jupiter:junit-jupiter:${junitVersion}",
36+
"org.junit.platform:junit-platform-runner:${junitPlatformVersion}"
5237
)
5338
}
54-
55-
test {
56-
testLogging {
57-
events = ["passed", "failed", "skipped"]
58-
showStandardStreams = true
59-
}
60-
}
61-
62-
publishing {
63-
publications {
64-
ProjectPublication(MavenPublication) {
65-
from components.java
66-
67-
artifact sourceJar {
68-
classifier "sources"
69-
}
70-
}
71-
}
72-
}

0 commit comments

Comments
 (0)