Skip to content

Commit

Permalink
SONARPHP-1522 Migrate ruleApi to Gradle (#1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
GabinL21 authored Nov 5, 2024
1 parent 2646a20 commit b6e30f6
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ build_task:
memory: 3G
env:
<<: *BUILD_SECRETS
ORG_GRADLE_PROJECT_signingKey: VAULT[development/kv/data/sign data.key]
ORG_GRADLE_PROJECT_signingPassword: VAULT[development/kv/data/sign data.passphrase]
ORG_GRADLE_PROJECT_signingKeyId: VAULT[development/kv/data/sign data.key_id]
#allow deployment of pull request artifacts to repox
DEPLOY_PULL_REQUEST: true
CIRRUS_CLONE_DEPTH: 50
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,30 @@ into the directory with the expected issues
sonar-php/its/ruling/src/test/resources/expected/
```

### Rule Descriptions

#### Update Rule Descriptions

To update all rule descriptions:

```shell
./gradlew ruleApiUpdate
```

#### Generate New Rule Description

To fetch static files for a rule SXXXX from [RSPEC](https://github.com/SonarSource/rspec):

```shell
./gradlew ruleApiGenerateRule -Prule=SXXXX
```

Same for a specific RSPEC branch (`master` by default):

```shell
./gradlew ruleApiGenerateRule -Prule=SXXXX -Pbranch=my-branch
```

### License

Copyright 2010-2024 SonarSource.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
val ruleApiVersion = "2.9.0.4061"

repositories {
maven {
url = project.uri("https://repox.jfrog.io/repox/sonarsource-private-releases")
authentication {
credentials {
val artifactoryUsername: String? by project
val artifactoryPassword: String? by project
username = artifactoryUsername
password = artifactoryPassword
}
}
}
mavenCentral()
}

val ruleApi: Configuration = configurations.create("ruleApi")

dependencies {
ruleApi("com.sonarsource.rule-api:rule-api:$ruleApiVersion")
}

tasks.register<JavaExec>("ruleApiUpdate") {
description = "Update PHP rules description"
group = "Rule API"
workingDir = file("$projectDir")
classpath = configurations.getByName("ruleApi")

args("com.sonarsource.ruleapi.Main", "update")
}

val rule = providers.gradleProperty("rule")
val branch = providers.gradleProperty("branch")

tasks.register<JavaExec>("ruleApiGenerateRule") {
description = "Generate PHP rule description"
group = "Rule API"
workingDir = file("$projectDir")
classpath = configurations.getByName("ruleApi")

args(
buildList {
add("com.sonarsource.ruleapi.Main")
add("generate")
add("-rule")
add(rule.getOrElse(""))
if (branch.isPresent) {
add("-branch")
add(branch.get())
}
},
)
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.spotless)
id("org.sonarsource.php.artifactory-configuration")
id("org.sonarsource.php.rule-api")
id("org.sonarsource.php.sonarqube")
}

Expand Down

0 comments on commit b6e30f6

Please sign in to comment.