Skip to content

Commit

Permalink
SONARPHP-1519 Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GabinL21 committed Nov 4, 2024
1 parent 083319f commit 3d88d2e
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 38 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ Before running any of the integration tests make sure the submodules are checked
#### Plugin Test
The "Plugin Test" is an additional integration test that verifies plugin features such as metric calculation, coverage, etc. To launch it:
```shell
./gradlew build -p its/plugin
./gradlew its:plugin:tests:test
```

#### Ruling Test
The "Ruling Test" is a special integration test that launches the analysis of a large code base, saves the issues created by the plugin in report files, and then compares those results to the set of expected issues (stored as JSON files). To launch the ruling test:
```shell
./gradlew build -p its/ruling
./gradlew its:ruling:test
```

This test gives you the opportunity to examine the issues created by each rule and make sure they're what you expect. You can inspect new/lost issues by checking the SonarQube local URL mentioned in the logs at the end of the analysis.
Expand Down
4 changes: 2 additions & 2 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ dependencyResolutionManagement {

pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url = uri("https://repox.jfrog.io/repox/sonarsource")

Expand All @@ -49,7 +51,5 @@ pluginManagement {
}
}
}
mavenCentral()
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@ tasks.withType<Test> {
events(SKIPPED, FAILED)
}
}

jacoco {
toolVersion = "0.8.12"
}

tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(providers.environmentVariable("CI").map { it.toBoolean().not() }.orElse(true))
}
}

plugins.withType<JacocoPlugin> {
tasks["test"].finalizedBy("jacocoTestReport")
}
17 changes: 17 additions & 0 deletions build-logic/src/main/kotlin/org/sonarsource/php/BuildUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package org.sonarsource.php

import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.register
import java.io.File

fun enforceJarSize(
Expand All @@ -22,3 +25,17 @@ fun Project.signingCondition(): Boolean {
return (branch == "master" || branch.matches("branch-[\\d.]+".toRegex())) &&
gradle.taskGraph.hasTask(":artifactoryPublish")
}

fun Project.registerCleanupTask(): TaskProvider<Delete> {
return tasks.register<Delete>("cleanupOldVersion") {
group = "build"
description = "Clean up jars of old plugin version"

delete(
fileTree(project.layout.buildDirectory.dir("libs")).matching {
include("${project.name}-*.jar")
exclude("${project.name}-${project.version}-*.jar")
}
)
}
}
1 change: 0 additions & 1 deletion php-checks/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies {
implementation(libs.sonar.plugin.api)
implementation(libs.sonar.analyzer.commons)
implementation(libs.commons.lang)
compileOnly(libs.slf4j.api)

testImplementation(libs.junit.jupiter)
testImplementation(libs.assertj.core)
Expand Down
1 change: 0 additions & 1 deletion php-frontend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies {

implementation(libs.sonar.plugin.api)
implementation(libs.commons.lang)
compileOnly(libs.slf4j.api)

testImplementation(libs.junit.jupiter)
testImplementation(libs.mockito.core)
Expand Down
34 changes: 2 additions & 32 deletions sonar-php-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.sonarsource.php.enforceJarSize
import org.sonarsource.php.registerCleanupTask

plugins {
id("org.sonarsource.php.java-conventions")
Expand All @@ -15,7 +16,6 @@ dependencies {
implementation(libs.sonar.xml.parsing)
implementation(libs.staxmate)
implementation(libs.commons.lang)
compileOnly(libs.slf4j.api)

testImplementation(testFixtures(project(":php-frontend")))
testImplementation(libs.junit.jupiter)
Expand All @@ -29,24 +29,6 @@ dependencies {

description = "SonarSource PHP Analyzer :: Sonar Plugin"

jacoco {
toolVersion = "0.8.12"
}

tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(false)
}
}

// when subproject has Jacoco plugin applied we want to generate XML report for coverage
plugins.withType<JacocoPlugin> {
tasks["test"].finalizedBy("jacocoTestReport")
}

tasks.jar {
manifest {
attributes(
Expand Down Expand Up @@ -74,19 +56,7 @@ tasks.jar {
}
}

val cleanupTask =
tasks.register<Delete>("cleanupOldVersion") {
group = "build"
description = "Clean up jars of old plugin version"

delete(
fileTree(project.layout.buildDirectory.dir("libs")).matching {
include("${project.name}-*.jar")
exclude("${project.name}-${project.version}-*.jar")
exclude("${project.name}-${project.version}.jar")
},
)
}
val cleanupTask = registerCleanupTask()

tasks.shadowJar {
dependsOn(cleanupTask)
Expand Down

0 comments on commit 3d88d2e

Please sign in to comment.