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
7 changes: 7 additions & 0 deletions .github/workflows/gradle-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ jobs:
- name: Run tests for 2.4
run: ./gradlew test --info -PsnakeYamlVersion=2.4

# Runs after every test job so all four jacoco reports exist; the paths they are
# read from are declared in build.gradle's sonar block.
- name: SonarCloud analysis
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --info

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v7
with:
Expand Down
17 changes: 15 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,25 @@ publishing {

sonar {
properties {
property "sonar.scm.disabled", "true"
property "sonar.java.binaries", "${layout.buildDirectory.get()}/classes"

// 'main' has no sources of its own (the code lives in common/v1/v2), so the plugin
// infers an empty compile classpath and the Java analyser cannot resolve types from
// SnakeYAML or the annotation jars. Only the SnakeYAML matching this build is added:
// putting 1.x and 2.x on one classpath would make the two ToStringRepresenter
// variants resolve against the wrong API. Mirrors how jacoco already picks a set.
property "sonar.java.libraries",
(sourceSets.common.compileClasspath + (isV1 ? sourceSets.v1 : sourceSets.v2).compileClasspath)
.filter { it.exists() }.files.join(',')
property "sonar.java.test.libraries", sourceSets.test.compileClasspath.filter { it.exists() }.files.join(',')
property "sonar.sources", "src/main"
property "sonar.tests", "src/test"
property "sonar.verbose", "true"

// v1/v2 YamlWrapperImpl are identical on purpose: each version source set compiles
// against its own SnakeYAML major release, and the real API difference between them
// lives in ToStringRepresenter. Sharing the wrapper would force the common source set
// to compile against one pinned SnakeYAML and run against the other.
property "sonar.cpd.exclusions", "**/YamlWrapperImpl.java"

property "sonar.projectKey", "AvarionMC_yaml"
Expand All @@ -233,4 +246,4 @@ sonar {
"${layout.buildDirectory.get()}/reports/jacoco/report-2.4.xml"
].join(',')
}
}
}