diff --git a/.cirrus.yml b/.cirrus.yml index bd717c3..8f15718 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -87,6 +87,7 @@ build_task: SONAR_TOKEN: VAULT[development/kv/data/next data.token] SONAR_HOST_URL: VAULT[development/kv/data/next data.url] DEPLOY_PULL_REQUEST: "true" + FORCE_SIGNING: "true" build_script: - git submodule update --init --depth 1 -- build-logic - source cirrus-env BUILD diff --git a/.gitmodules b/.gitmodules index 73aed1c..ab6b5ce 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,4 @@ [submodule "build-logic"] path = build-logic url = https://github.com/SonarSource/cloud-native-gradle-modules + branch = SONARGO-82 diff --git a/build-logic b/build-logic index 3a87c25..522ed40 160000 --- a/build-logic +++ b/build-logic @@ -1 +1 @@ -Subproject commit 3a87c2511f6809b708685b09c5170a2fc25a5349 +Subproject commit 522ed404ac5dc9dd6c7d47c11c5e48e7ae17e880 diff --git a/build.gradle b/build.gradle deleted file mode 100644 index f29ea2e..0000000 --- a/build.gradle +++ /dev/null @@ -1,177 +0,0 @@ -/* - * SonarSource Go - * Copyright (C) 2018-2024 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the Sonar Source-Available License for more details. - * - * You should have received a copy of the Sonar Source-Available License - * along with this program; if not, see https://sonarsource.com/license/ssal/ - */ -import java.util.jar.JarInputStream - -plugins { - id("org.sonarsource.cloud-native.code-style-conventions") - 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 -} - -allprojects { - apply plugin: 'java' - apply plugin: 'com.jfrog.artifactory' - apply plugin: 'maven-publish' - apply plugin: 'signing' - - ext { - sonarLinksCi = 'https://cirrus-ci.com/github/SonarSource/sonar-go' - sonarLinksScm = 'https://github.com/SonarSource/sonar-go' - - artifactsToPublish = '' - artifactsToDownload = '' - } - - repositories { - mavenCentral() - def artifactoryBearerToken = System.getenv("ARTIFACTORY_PRIVATE_PASSWORD") ?: project.findProperty("artifactoryPassword") - if (artifactoryBearerToken) { - maven { - url "https://repox.jfrog.io/repox/sonarsource" - authentication { - header(HttpHeaderAuthentication) - } - credentials(HttpHeaderCredentials) { - name = "Authorization" - value = "Bearer $artifactoryBearerToken" - } - } - } - } -} - -subprojects { - // do not publish to Artifactory by default - artifactoryPublish.skip = true - - configurations { - // include compileOnly dependencies during test - testCompile.extendsFrom compileOnly - } - - tasks.withType(Test).configureEach { - def propKeys = System.properties.findAll { - it.key.startsWith("orchestrator") || it.key.startsWith("sonar") || it.key == "buildNumber" || it.key == "slangVersion" - }.collect { it.key } - systemProperties = System.properties.subMap(propKeys) - if (propKeys.contains("buildNumber") && !propKeys.contains("slangVersion")) { - systemProperties["slangVersion"] = version - } - } - - publishing { - publications { - mavenJava(MavenPublication) { - pom { - name = projectTitle - description = project.description - url = 'http://www.sonarqube.org/' - organization { - name = 'SonarSource' - url = 'http://www.sonarsource.com' - } - licenses { - license { - name = 'SSALv1' - url = 'https://sonarsource.com/license/ssal/' - distribution = 'repo' - } - } - scm { - url = 'https://github.com/SonarSource/sonar-go' - } - developers { - developer { - id = 'sonarsource-team' - name = 'SonarSource Team' - } - } - } - } - } - } - - signing { - def signingKeyId = findProperty("signingKeyId") - def signingKey = findProperty("signingKey") - def signingPassword = findProperty("signingPassword") - useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) - required { - def branch = System.getenv()["CIRRUS_BRANCH"] - return (branch == 'master' || branch ==~ 'branch-[\\d.]+') && - gradle.taskGraph.hasTask(":artifactoryPublish") - } - sign publishing.publications - } - - tasks.withType(Sign) { - onlyIf { - def branch = System.getenv()["CIRRUS_BRANCH"] - return !artifactoryPublish.skip && - (branch == 'master' || branch ==~ 'branch-[\\d.]+') && - gradle.taskGraph.hasTask(":artifactoryPublish") - } - } -} - -sonar { - properties { - property 'sonar.organization', 'sonarsource' - property 'sonar.projectKey', 'SonarSource_sonar-go' - property 'sonar.projectName', projectTitle - property 'sonar.links.ci', "${sonarLinksCi}" - property 'sonar.links.scm', "${sonarLinksScm}" - property 'sonar.links.issue', 'https://jira.sonarsource.com/browse/SONARGO' - property 'sonar.exclusions', '**/build/**/*' - } -} - -artifactory { - clientConfig.setIncludeEnvVars(true) - clientConfig.setEnvVarsExcludePatterns('*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command,*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*,*PASSPHRASE*,*signing*') - contextUrl = System.getenv('ARTIFACTORY_URL') - publish { - repository { - repoKey = System.getenv('ARTIFACTORY_DEPLOY_REPO') - username = System.getenv('ARTIFACTORY_DEPLOY_USERNAME') - password = System.getenv('ARTIFACTORY_DEPLOY_PASSWORD') - } - defaults { - properties = [ - 'build.name' : 'sonar-go', - 'build.number' : System.getenv('BUILD_NUMBER'), - 'pr.branch.target': System.getenv('PULL_REQUEST_BRANCH_TARGET'), - 'pr.number' : System.getenv('PULL_REQUEST_NUMBER'), - 'vcs.branch' : System.getenv('GIT_BRANCH'), - 'vcs.revision' : System.getenv('GIT_COMMIT'), - 'version' : version - ] - publications('mavenJava') - publishPom = true - publishIvy = false - } - } - - clientConfig.info.setBuildName('sonar-go') - clientConfig.info.setBuildNumber(System.getenv('BUILD_NUMBER')) - // Define the artifacts to be deployed to https://binaries.sonarsource.com on releases - clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_PUBLISH', artifactsToPublish) - clientConfig.info.addEnvironmentProperty('ARTIFACTS_TO_DOWNLOAD', artifactsToDownload) - // The name of this variable is important because it's used by the delivery process when extracting version from Artifactory build info. - clientConfig.info.addEnvironmentProperty('PROJECT_VERSION', "${version}") -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..63d12e0 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,49 @@ +/* + * SonarSource Go + * Copyright (C) 2018-2024 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the Sonar Source-Available License for more details. + * + * You should have received a copy of the Sonar Source-Available License + * along with this program; if not, see https://sonarsource.com/license/ssal/ + */ +plugins { + id("org.sonarsource.cloud-native.code-style-conventions") + id("org.sonarsource.cloud-native.artifactory-configuration") + id("org.sonarqube") version "6.0.1.5171" +} + +artifactoryConfiguration { + buildName = "sonar-go" + artifactsToPublish = "org.sonarsource.slang:sonar-go-plugin:jar" + artifactsToDownload = "" + repoKeyEnv = "ARTIFACTORY_DEPLOY_REPO" + usernameEnv = "ARTIFACTORY_DEPLOY_USERNAME" + passwordEnv = "ARTIFACTORY_DEPLOY_PASSWORD" +} + +spotless { + java { + // no Java sources in the root project + target("") + } +} + +sonar { + properties { + property("sonar.organization", "sonarsource") + property("sonar.projectKey", "SonarSource_sonar-go") + property("sonar.projectName", properties["projectTitle"] as String) + property("sonar.links.ci", "https://cirrus-ci.com/github/SonarSource/sonar-go") + property("sonar.links.scm", "https://github.com/SonarSource/sonar-go") + property("sonar.links.issue", "https://jira.sonarsource.com/browse/SONARGO") + property("sonar.exclusions", "**/build/**/*") + } +} diff --git a/sonar-go-plugin/build.gradle.kts b/sonar-go-plugin/build.gradle.kts index 1b00ad0..c940d1f 100644 --- a/sonar-go-plugin/build.gradle.kts +++ b/sonar-go-plugin/build.gradle.kts @@ -22,6 +22,7 @@ import java.util.jar.JarInputStream plugins { id("org.sonarsource.cloud-native.java-conventions") id("org.sonarsource.cloud-native.code-style-conventions") + id("org.sonarsource.cloud-native.artifactory-configuration") id("com.github.johnrengelman.shadow") version "7.1.0" } @@ -117,8 +118,20 @@ artifacts { archives(tasks.shadowJar) } -tasks.artifactoryPublish { - skip = false +artifactoryConfiguration { + pomName = properties["projectTitle"] as String + scmUrl = "https://github.com/SonarSource/sonar-go" + + license { + name = "SSALv1" + url = "https://sonarsource.com/license/ssal/" + distribution = "repo" + } + + buildName = "sonar-go" + repoKeyEnv = "ARTIFACTORY_DEPLOY_REPO" + usernameEnv = "ARTIFACTORY_DEPLOY_USERNAME" + passwordEnv = "ARTIFACTORY_DEPLOY_PASSWORD" } publishing { diff --git a/sonar-go-to-slang/build.gradle.kts b/sonar-go-to-slang/build.gradle.kts index 503354b..155feda 100644 --- a/sonar-go-to-slang/build.gradle.kts +++ b/sonar-go-to-slang/build.gradle.kts @@ -68,6 +68,13 @@ tasks.build { dependsOn(generateTestReport) } +spotless { + java { + // No Java sources in this project + target("") + } +} + if (System.getenv("CI") == "true") { // spotless is enabled only for CI, because spotless relies on Go installation being available on the machine spotless {