Skip to content

Commit 564e4d4

Browse files
authored
Lift restriction of artifactory-configuration script (#55)
1 parent 2281f3c commit 564e4d4

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

gradle-modules/src/main/kotlin/org.sonarsource.cloud-native.artifactory-configuration.gradle.kts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,23 @@ plugins {
2222
id("com.jfrog.artifactory")
2323
}
2424

25-
if (project.path != ":" && "-plugin" !in project.path) {
26-
throw GradleException(
27-
"This build script configures Artifactory connection for a build of a SonarQube plugin. " +
28-
"This script must be applied either to the root project or in a \"-plugin\" project."
29-
)
30-
}
31-
3225
// this value is present on CI
3326
val buildNumber: String? = System.getProperty("buildNumber")
3427

3528
val artifactoryConfiguration = extensions.create<ArtifactoryConfiguration>("artifactoryConfiguration")
29+
artifactoryConfiguration.acknowledgePublicationOfNonPlugin.convention(false)
3630

3731
val projectVersion = project.version as String
3832

3933
// `afterEvaluate` is required to inject configurable properties; see https://github.com/jfrog/artifactory-gradle-plugin/issues/71#issuecomment-1734977528
4034
project.afterEvaluate {
35+
if (!artifactoryConfiguration.acknowledgePublicationOfNonPlugin.get() && project.path != ":" && "-plugin" !in project.path) {
36+
throw GradleException(
37+
"This build script configures Artifactory connection for a build of a SonarQube plugin. " +
38+
"This script must be applied either to the root project or in a \"-plugin\" project."
39+
)
40+
}
41+
4142
artifactory {
4243
if (artifactoryConfiguration.artifactsToPublish.isPresent) {
4344
clientConfig.info.addEnvironmentProperty(

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,11 @@ interface ArtifactoryConfiguration {
4747
val repoKeyEnv: Property<String>
4848
val usernameEnv: Property<String>
4949
val passwordEnv: Property<String>
50+
51+
/**
52+
* Set this to `true` to acknowledge that the publication is deliberately enabled for a project that is not a plugin.
53+
* Normally, only plugins should be published to Artifactory. If there is a specific reason to publish a non-plugin project,
54+
* this property acts a safety net to ensure that the user is aware of this decision.
55+
*/
56+
val acknowledgePublicationOfNonPlugin: Property<Boolean>
5057
}

0 commit comments

Comments
 (0)