Skip to content

Commit 3888325

Browse files
authored
SONARGO-54 Change build of the Go executable to be in line with sonar-iac (#13)
1 parent b8568ad commit 3888325

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

gradle-modules/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ gradlePlugin {
3838
}
3939
}
4040

41-
val kotlinGradleDelimiter = "(package|import|plugins|pluginManagement|dependencyResolutionManagement|repositories) "
4241
spotless {
4342
kotlin {
4443
ktlint().setEditorConfigPath("$rootDir/.editorconfig")
45-
targetExclude("build/**")
44+
target("src/**/*.kt")
4645
licenseHeaderFile(rootProject.file("LICENSE_HEADER")).updateYearWithLatest(true)
4746
}
4847

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* SonarSource Cloud Native Gradle Modules
3+
* Copyright (C) 2024-2025 SonarSource SA
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
* See the Sonar Source-Available License for more details.
13+
*
14+
* You should have received a copy of the Sonar Source-Available License
15+
* along with this program; if not, see https://sonarsource.com/license/ssal/
16+
*/
17+
import org.gradle.kotlin.dsl.registering
18+
19+
val goBinaries: Configuration by configurations.creating
20+
val goBinariesJar by tasks.registering(Jar::class) {
21+
group = "build"
22+
dependsOn("compileGo")
23+
archiveClassifier.set("binaries")
24+
from("build/executable")
25+
}
26+
artifacts.add(goBinaries.name, goBinariesJar)

gradle-modules/src/main/kotlin/org/sonarsource/cloudnative/gradle/BuildUtils.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import org.gradle.api.artifacts.dsl.RepositoryHandler
2121
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
2222
import org.gradle.api.internal.file.FileOperations
2323
import org.gradle.api.provider.ProviderFactory
24+
import org.gradle.api.tasks.Exec
25+
import org.gradle.internal.os.OperatingSystem
2426

2527
fun Project.signingCondition(): Boolean {
2628
val branch = System.getenv()["CIRRUS_BRANCH"] ?: ""
@@ -52,3 +54,14 @@ internal fun RepositoryHandler.repox(
5254
}
5355
}
5456
}
57+
58+
/**
59+
* Configures this `Exec` task to call `make.sh` or `make.bat` depending on the operating system.
60+
*/
61+
fun Exec.callMake(arg: String) {
62+
if (OperatingSystem.current().isWindows) {
63+
commandLine("cmd", "/c", "make.bat", arg)
64+
} else {
65+
commandLine("./make.sh", arg)
66+
}
67+
}

0 commit comments

Comments
 (0)