Skip to content

Commit

Permalink
SONARGO-71 Extend "code-style-convention" to optionally support Go, a…
Browse files Browse the repository at this point in the history
…dd to common Gradle modules
  • Loading branch information
petertrr committed Dec 16, 2024
1 parent 9e1a9d1 commit 1115ea2
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
[submodule "build-logic"]
path = build-logic
url = https://github.com/SonarSource/cloud-native-gradle-modules
branch = SONARGO-71
15 changes: 0 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
id 'com.jfrog.artifactory' version '4.28.2'
id 'org.sonarqube' version '6.0.1.5171'
id 'de.thetaphi.forbiddenapis' version '3.0' apply false
id 'com.diffplug.spotless' version '6.15.0'
}

allprojects {
Expand Down Expand Up @@ -51,8 +50,6 @@ subprojects {
// do not publish to Artifactory by default
artifactoryPublish.skip = true

apply plugin: 'com.diffplug.spotless'

configurations {
// include compileOnly dependencies during test
testCompile.extendsFrom compileOnly
Expand All @@ -68,18 +65,6 @@ subprojects {
}
}

// license updater
spotless {
java {
targetExclude "**/src/test/resources/**", "**/build/**", "its/sources/**", "its/plugin/projects/**"
licenseHeaderFile(rootProject.file("LICENSE_HEADER")).updateYearWithLatest(true)
}
format("javaMisc") {
target("src/**/package-info.java")
licenseHeaderFile(rootProject.file("LICENSE_HEADER"), "(@javax.annotation|@ParametersAreNonnullByDefault)").updateYearWithLatest(true)
}
}

publishing {
publications {
mavenJava(MavenPublication) {
Expand Down
1 change: 1 addition & 0 deletions its/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("org.sonarsource.cloud-native.java-conventions")
id("org.sonarsource.cloud-native.code-style-conventions")
id("org.sonarsource.cloud-native.integration-test")
}

Expand Down
1 change: 1 addition & 0 deletions its/ruling/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("org.sonarsource.cloud-native.java-conventions")
id("org.sonarsource.cloud-native.code-style-conventions")
id("org.sonarsource.cloud-native.integration-test")
}

Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pluginManagement {

plugins {
id("com.gradle.develocity") version "3.18.2"
id("com.diffplug.blowdryerSetup") version "1.7.1"
}

develocity {
Expand Down
1 change: 1 addition & 0 deletions sonar-go-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.util.jar.JarInputStream

plugins {
id("org.sonarsource.cloud-native.java-conventions")
id("org.sonarsource.cloud-native.code-style-conventions")
id("com.github.johnrengelman.shadow") version "7.1.0"
}

Expand Down
23 changes: 23 additions & 0 deletions sonar-go-to-slang/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id("org.sonarsource.cloud-native.code-style-conventions")
}

sonarqube {
properties {
property("sonar.sources", ".")
Expand Down Expand Up @@ -44,3 +48,22 @@ generateTestReport {
tasks.build {
dependsOn(generateTestReport)
}

if (System.getenv("CI") == "true") {
// spotless is enabled only for CI, because spotless relies on Go installation being available on the machine
spotless {
go {
val goVersion = providers.environmentVariable("GO_VERSION").getOrElse("1.23.4")
gofmt("go$goVersion").withGoExecutable(System.getenv("HOME") + "/go/bin/go")
target("*.go", "**/*.go")
targetExclude("*_generated.go")
}
}
// For now, these tasks rely on installation of Go performed by the call to make.sh
tasks.spotlessCheck {
dependsOn(generateParserAndBuild)
}
tasks.spotlessApply {
dependsOn(generateParserAndBuild)
}
}

0 comments on commit 1115ea2

Please sign in to comment.