-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONARPHP-1519 Migrate sonar-php build to Gradle (#1294)
- Loading branch information
Showing
67 changed files
with
1,095 additions
and
1,273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* text=auto | ||
/gradlew.bat text eol=crlf | ||
/gradlew text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# Maven | ||
target/ | ||
|
||
# Gradle | ||
build/ | ||
.gradle | ||
|
||
# IntelliJ IDEA | ||
*.iws | ||
*.iml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* SonarQube PHP Plugin | ||
* Copyright (C) 2010-$YEAR 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 GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* 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 GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(libs.jfrog.buildinfo.gradle) | ||
implementation(libs.sonar.scanner.gradle) | ||
implementation(libs.diffplug.spotless) | ||
implementation(libs.diffplug.blowdryer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
maven { | ||
url = uri("https://repox.jfrog.io/repox/sonarsource") | ||
val artifactoryUsername = | ||
providers.environmentVariable("ARTIFACTORY_PRIVATE_USERNAME") | ||
.orElse(providers.gradleProperty("artifactoryUsername")) | ||
val artifactoryPassword = | ||
providers.environmentVariable("ARTIFACTORY_PRIVATE_PASSWORD") | ||
.orElse(providers.gradleProperty("artifactoryPassword")) | ||
|
||
if (artifactoryUsername.isPresent && artifactoryPassword.isPresent) { | ||
authentication { | ||
credentials { | ||
username = artifactoryUsername.get() | ||
password = artifactoryPassword.get() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
versionCatalogs { | ||
create("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} | ||
|
||
pluginManagement { | ||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
maven { | ||
url = uri("https://repox.jfrog.io/repox/sonarsource") | ||
|
||
val artifactoryUsername = | ||
providers.environmentVariable("ARTIFACTORY_PRIVATE_USERNAME") | ||
.orElse(providers.gradleProperty("artifactoryUsername")) | ||
val artifactoryPassword = | ||
providers.environmentVariable("ARTIFACTORY_PRIVATE_PASSWORD") | ||
.orElse(providers.gradleProperty("artifactoryPassword")) | ||
|
||
if (artifactoryUsername.isPresent && artifactoryPassword.isPresent) { | ||
authentication { | ||
credentials { | ||
username = artifactoryUsername.get() | ||
password = artifactoryPassword.get() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
build-logic/src/main/kotlin/org.sonarsource.php.artifactory-configuration.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import org.sonarsource.php.signingCondition | ||
|
||
plugins { | ||
id("com.jfrog.artifactory") | ||
signing | ||
`maven-publish` | ||
} | ||
|
||
publishing { | ||
publications.create<MavenPublication>("mavenJava") { | ||
pom { | ||
name.set("SonarSource PHP Analyzer") | ||
description.set(project.description) | ||
url.set("http://www.sonarqube.org/") | ||
organization { | ||
name.set("SonarSource") | ||
url.set("http://www.sonarsource.com/") | ||
} | ||
licenses { | ||
license { | ||
name.set("GNU LGPL 3") | ||
url.set("http://www.gnu.org/licenses/lgpl.txt") | ||
distribution.set("repo") | ||
} | ||
} | ||
scm { | ||
url.set("https://github.com/SonarSource/sonar-php") | ||
} | ||
developers { | ||
developer { | ||
id.set("sonarsource-team") | ||
name.set("SonarSource Team") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
val signingKeyId: String? by project | ||
val signingKey: String? by project | ||
val signingPassword: String? by project | ||
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword) | ||
setRequired { | ||
project.signingCondition() | ||
} | ||
sign(publishing.publications) | ||
} | ||
|
||
tasks.withType<Sign> { | ||
onlyIf { | ||
val artifactorySkip: Boolean = tasks.artifactoryPublish.get().skip | ||
!artifactorySkip && project.signingCondition() | ||
} | ||
} | ||
|
||
artifactory { | ||
val artifactsToPublish = "org.sonarsource.php:sonar-php-plugin:jar" | ||
|
||
clientConfig.info.addEnvironmentProperty("ARTIFACTS_TO_PUBLISH", artifactsToPublish) | ||
clientConfig.info.addEnvironmentProperty("ARTIFACTS_TO_DOWNLOAD", "") | ||
|
||
setContextUrl(System.getenv("ARTIFACTORY_URL")) | ||
publish { | ||
repository { | ||
setRepoKey(System.getenv("ARTIFACTORY_DEPLOY_REPO")) | ||
setUsername(System.getenv("ARTIFACTORY_DEPLOY_USERNAME")) | ||
setPassword(System.getenv("ARTIFACTORY_DEPLOY_PASSWORD")) | ||
} | ||
defaults { | ||
publications("mavenJava") | ||
setProperties( | ||
mapOf( | ||
"build.name" to "sonar-php", | ||
"version" to project.version.toString(), | ||
"build.number" to project.ext["buildNumber"].toString(), | ||
"pr.branch.target" to System.getenv("PULL_REQUEST_BRANCH_TARGET"), | ||
"pr.number" to System.getenv("PULL_REQUEST_NUMBER"), | ||
"vcs.branch" to System.getenv("GIT_BRANCH"), | ||
"vcs.revision" to System.getenv("GIT_COMMIT"), | ||
), | ||
) | ||
setPublishArtifacts(true) | ||
setPublishPom(true) | ||
setPublishIvy(false) | ||
} | ||
} | ||
|
||
clientConfig.info.addEnvironmentProperty("PROJECT_VERSION", project.version.toString()) | ||
clientConfig.info.buildName = "sonar-php" | ||
clientConfig.info.buildNumber = project.ext["buildNumber"].toString() | ||
clientConfig.isIncludeEnvVars = true | ||
clientConfig.envVarsExcludePatterns = | ||
"*password*,*PASSWORD*,*secret*,*MAVEN_CMD_LINE_ARGS*,sun.java.command," + | ||
"*token*,*TOKEN*,*LOGIN*,*login*,*key*,*KEY*,*PASSPHRASE*,*signing*" | ||
} |
Oops, something went wrong.