Skip to content

Commit 8f1d572

Browse files
committed
migrate to gradle
1 parent bc729df commit 8f1d572

File tree

318 files changed

+33878
-30314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

318 files changed

+33878
-30314
lines changed

.github/scripts/version.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
VERSION=$(grep 'version=' "$@" | awk -F= '{ print $2 }')
2+
echo "$VERSION"

.github/workflows/codeql.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ on:
2020
schedule:
2121
- cron: '0 7 * * 1'
2222

23+
env:
24+
GITHUB_USERNAME: ${{ github.actor }}
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
2327
jobs:
2428
analyze:
2529
name: Analyze
@@ -55,16 +59,17 @@ jobs:
5559
queries: +security-extended,security-and-quality
5660

5761
# Autobuild fails so use custom build steps
58-
- name: Set up JDK 17
62+
- name: Set up JDK
5963
uses: actions/setup-java@v4
6064
with:
61-
java-version: '8.0.302'
65+
java-version: 17
6266
distribution: 'temurin'
6367

64-
- name: Run maven package
65-
run: mvn -s .github/m2/settings.xml clean package
66-
env:
67-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
- name: Setup Gradle
69+
uses: gradle/actions/setup-gradle@v4
70+
71+
- name: Run Gradle build
72+
run: ./gradlew assemble
6873

6974
- name: Perform CodeQL Analysis
7075
uses: github/codeql-action/analyze@v3

.github/workflows/maven.yml

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

.github/workflows/push.yml

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,45 @@ permissions:
88
contents: write
99
id-token: write
1010

11+
env:
12+
GITHUB_USERNAME: ${{ github.actor }}
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
1115
jobs:
1216
test:
1317
runs-on: ubuntu-latest
1418
steps:
1519
- uses: actions/checkout@v4
1620

17-
- name: Set up JDK 8
21+
- name: Set up JDK
1822
uses: actions/setup-java@v4
1923
with:
20-
java-version: 8.0.302
24+
java-version: 17
2125
distribution: 'temurin'
2226

23-
- name: Run maven verify
24-
run: |
25-
mvn -s .github/m2/settings.xml clean verify
26-
env:
27-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v4
29+
30+
- name: Run Gradle build
31+
run: ./gradlew build
2832

2933
- uses: actions/upload-artifact@v4
3034
if: always()
3135
with:
32-
path: core/target/coverage-report
36+
path: core/build/reports
3337
name: coverage report
3438

3539
- uses: actions/upload-artifact@v4
3640
if: always()
3741
with:
38-
path: core/target/surefire-reports
42+
path: core/build/reports/tests
3943
name: unit test report
4044

4145
- name: Check shading(core)
4246
run: |
43-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
47+
VERSION=$(grep 'projectVersion=' gradle.properties | cut -d= -f2)
4448
code=0
45-
for path in $(jar tf "core/target/core-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))')
46-
do
47-
PACKAGE=$(echo "$path" | awk -F/ '{print $2}')
48-
if [ -n "$PACKAGE" ]; then
49-
echo "Package ($path) is not shaded"
50-
code=1
51-
fi
52-
done
53-
exit $code
54-
55-
- name: Check shading(metric)
56-
run: |
57-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
58-
code=0
59-
for path in $(jar tf "metrics/target/metrics-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))')
49+
for path in $(jar tf "core/build/libs/core-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))')
6050
do
6151
PACKAGE=$(echo "$path" | awk -F/ '{print $2}')
6252
if [ -n "$PACKAGE" ]; then
@@ -68,9 +58,9 @@ jobs:
6858
6959
- name: Check shading(sampling)
7060
run: |
71-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
61+
VERSION=$(grep 'projectVersion=' gradle.properties | cut -d= -f2)
7262
code=0
73-
for path in $(jar tf "sampling/target/sampling-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))')
63+
for path in $(jar tf "sampling/build/libs/sampling-$VERSION.jar" | grep -E -v '^((com/solarwinds|META))')
7464
do
7565
PACKAGE=$(echo "$path" | awk -F/ '{print $2}')
7666
if [ -n "$PACKAGE" ]; then
@@ -85,20 +75,22 @@ jobs:
8575
steps:
8676
- uses: actions/checkout@v4
8777

88-
- name: Set up JDK 8
78+
- name: Set up JDK
8979
uses: actions/setup-java@v4
9080
with:
91-
java-version: 8.0.302
81+
java-version: 17
9282
distribution: 'temurin'
9383

84+
- name: Setup Gradle
85+
uses: gradle/actions/setup-gradle@v4
86+
9487
- name: Deploy snapshot
9588
run: |
96-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
89+
VERSION=$(.github/scripts/version.sh gradle.properties)
9790
BRANCH=$(echo -n "${GITHUB_REF_NAME}" | sed -e 's/[^0-9a-zA-Z\._\-]/./g' | tr '[:upper:]' '[:lower:]')
9891
GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
99-
92+
10093
NEW_VERSION=${VERSION%%-SNAPSHOT}-$BRANCH-$GIT_HASH-SNAPSHOT
101-
mvn versions:set -DnewVersion=$NEW_VERSION
102-
mvn -s .github/m2/settings.xml -T 8 deploy -DskipTests
94+
./gradlew publish -DreleaseVersion=$NEW_VERSION
10395
env:
10496
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
packages: write
8+
contents: write
9+
id-token: write
10+
11+
env:
12+
GITHUB_USERNAME: ${{ github.actor }}
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up JDK
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: 17
25+
distribution: 'temurin'
26+
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v4
29+
30+
- name: Set version env
31+
run: |
32+
VERSION=$(.github/scripts/version.sh gradle.properties)
33+
RELEASE_VERSION=${VERSION%%-SNAPSHOT}
34+
echo "RELEASE_VERSION=v$RELEASE_VERSION" >> $GITHUB_ENV
35+
echo "VERSION_NUMBER=$RELEASE_VERSION" >> $GITHUB_ENV
36+
37+
- name: Publish package
38+
run: ./gradlew publish -DreleaseVersion=${{ env.VERSION_NUMBER }}
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
out/
1010
**/.flattened-pom.xml
1111
.spotless/
12+
.gradle
13+
**/build

build.gradle.kts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import com.diffplug.gradle.spotless.SpotlessExtension
2+
import org.gradle.kotlin.dsl.provideDelegate
3+
4+
plugins {
5+
`java-library`
6+
id("com.diffplug.spotless") version "6.25.0" apply false
7+
id("io.freefair.lombok") version "8.13" apply false
8+
id("com.gradleup.shadow") version "8.3.9" apply false
9+
}
10+
11+
val projectVersion = System.getProperty("releaseVersion") ?: property("version").toString()
12+
rootProject.extra["projectVersion"] = projectVersion
13+
14+
allprojects {
15+
val projectVersion: String by rootProject.extra
16+
group = "com.solarwinds.joboe"
17+
version = projectVersion
18+
}
19+
20+
subprojects {
21+
apply(plugin = "java-library")
22+
apply(plugin = "io.freefair.lombok")
23+
apply(plugin = "com.diffplug.spotless")
24+
apply(plugin = "maven-publish")
25+
26+
configure<JavaPluginExtension> {
27+
toolchain {
28+
languageVersion.set(JavaLanguageVersion.of(8))
29+
}
30+
withSourcesJar()
31+
}
32+
33+
dependencies {
34+
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
35+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
36+
testImplementation("org.junit-pioneer:junit-pioneer:1.9.1")
37+
testImplementation("org.mockito:mockito-core:3.12.4")
38+
testImplementation("org.mockito:mockito-junit-jupiter:3.12.4")
39+
testImplementation("org.mockito:mockito-inline:3.12.4")
40+
}
41+
42+
tasks {
43+
withType<Test>().configureEach {
44+
useJUnitPlatform()
45+
testLogging {
46+
events("passed", "skipped", "failed")
47+
}
48+
}
49+
}
50+
51+
configure<SpotlessExtension> {
52+
java {
53+
googleJavaFormat()
54+
removeUnusedImports()
55+
trimTrailingWhitespace()
56+
endWithNewline()
57+
}
58+
}
59+
60+
configure<PublishingExtension> {
61+
repositories {
62+
maven {
63+
name = "GitHubPackages"
64+
url = uri("https://maven.pkg.github.com/solarwinds/joboe")
65+
credentials {
66+
username = System.getenv("GITHUB_USERNAME")
67+
password = System.getenv("GITHUB_TOKEN")
68+
}
69+
}
70+
}
71+
}
72+
73+
afterEvaluate {
74+
configure<PublishingExtension> {
75+
publications {
76+
create<MavenPublication>("maven") {
77+
val variant = if (plugins.hasPlugin("com.gradleup.shadow")) "shadow" else "java"
78+
from(components[variant])
79+
}
80+
}
81+
}
82+
}
83+
}

config/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
description = "config"
2+
3+
dependencies {
4+
api(project(":logging"))
5+
compileOnly("org.json:json:20250517")
6+
testImplementation("org.json:json:20250517")
7+
}

config/pom.xml

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

0 commit comments

Comments
 (0)