Skip to content

Commit

Permalink
Gradle 5.6 (detekt#1833)
Browse files Browse the repository at this point in the history
* Gradle 5.6

* Define plugin versions in gradle.properties

* Work around Gradle 6 behaviour change

In Gradle 6 the default DuplicateStrategy is FAIL. This reverts to previous
behaviour to avoid an error due to two ktlint rulesets declaring a
RuleSetProvider service which, when merged, results in duplicate paths.
These files have no effect in detekt so the duplication can be ignored.

The duplicate path is "META-INF/services/com.pinterest.ktlint.core.RuleSetProvider"

* Fix issues found by :detekt-gradle-plugin:validateTaskProperties
  • Loading branch information
3flex authored Aug 25, 2019
1 parent 09e7a14 commit 383a1e0
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 38 deletions.
20 changes: 11 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
import java.util.Date

plugins {
id("com.gradle.build-scan") version "2.4"
kotlin("jvm") version "1.3.50"
id("com.jfrog.bintray") version "1.8.4"
id("com.jfrog.artifactory") version "4.9.8" apply false
id("com.github.ben-manes.versions") version "0.22.0"
id("com.github.johnrengelman.shadow") version "5.1.0" apply false
id("org.sonarqube") version "2.7"
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka") version "0.9.18" apply false
jacoco
`maven-publish`
// Plugin versions for these plugins are defined in gradle.properties and applied in settings.gradle.kts
id("com.jfrog.artifactory") apply false
id("com.jfrog.bintray")
id("com.gradle.build-scan")
id("org.jetbrains.dokka") apply false
id("com.github.ben-manes.versions")
kotlin("jvm")
id("com.github.johnrengelman.shadow") apply false
id("org.sonarqube")
}

buildScan {
Expand All @@ -28,7 +29,8 @@ buildScan {
}

tasks.wrapper {
gradleVersion = "5.4"
val gradleVersion: String by project
this.gradleVersion = gradleVersion
distributionType = Wrapper.DistributionType.ALL
doLast {
/*
Expand Down
1 change: 1 addition & 0 deletions detekt-formatting/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
}

tasks.withType<Jar>().configureEach {
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
from(
configurations.implementation.get()
.filter { "com.pinterest.ktlint" in it.toString() }
Expand Down
1 change: 0 additions & 1 deletion detekt-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ tasks.test {

tasks.validateTaskProperties {
enableStricterValidation = true
failOnWarning = true
}

pluginBundle {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.gradle.api.provider.Provider
import org.gradle.api.reporting.ReportingExtension
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.Console
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.InputFiles
Expand Down Expand Up @@ -107,15 +108,13 @@ open class Detekt : SourceTask(), VerificationTask {
var plugins: Property<String> = project.objects.property(String::class.java)

@get:Internal
@get:Optional
internal val debugProp: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)
var debug: Boolean
@Internal
@Console
get() = debugProp.get()
set(value) = debugProp.set(value)

@get:Internal
@get:Optional
internal val parallelProp: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)
var parallel: Boolean
@Internal
Expand Down Expand Up @@ -149,7 +148,6 @@ open class Detekt : SourceTask(), VerificationTask {
@get:Internal
internal val ignoreFailuresProp: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)
@Input
@Optional
override fun getIgnoreFailures(): Boolean = ignoreFailuresProp.getOrElse(false)
override fun setIgnoreFailures(value: Boolean) = ignoreFailuresProp.set(value)

Expand All @@ -167,7 +165,6 @@ open class Detekt : SourceTask(), VerificationTask {
fun reports(configure: Action<DetektReports>) = configure.execute(reports)

@Internal
@Optional
var reportsDir: Property<File> = project.objects.property(File::class.java)

val xmlReportFile: Provider<RegularFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import org.gradle.api.file.FileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.Console
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.Internal
Expand All @@ -39,7 +40,6 @@ open class DetektCreateBaselineTask : SourceTask() {
}

@OutputFile
@PathSensitive(PathSensitivity.RELATIVE)
var baseline: RegularFileProperty = project.fileProperty()

@Deprecated("Replace with getSource/setSource")
Expand Down Expand Up @@ -72,24 +72,19 @@ open class DetektCreateBaselineTask : SourceTask() {
@Classpath
val pluginClasspath = project.configurableFileCollection()

@Internal
@Optional
@Console
var debug: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)

@Internal
@Optional
var parallel: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)

@Internal
@Optional
var disableDefaultRuleSets: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)

@Internal
@Optional
var buildUponDefaultConfig: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)

@Internal
@Optional
var failFast: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)

@Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.gitlab.arturbosch.detekt.extensions.IdeaExtension
import io.gitlab.arturbosch.detekt.invoke.ProcessExecutor.startProcess
import org.gradle.api.file.FileCollection
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Console
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.SourceTask
Expand All @@ -23,8 +24,7 @@ open class DetektIdeaFormatTask : SourceTask() {
get() = source
set(value) = setSource(value)

@Internal
@Optional
@Console
var debug: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)

@Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import io.gitlab.arturbosch.detekt.extensions.IdeaExtension
import io.gitlab.arturbosch.detekt.invoke.ProcessExecutor
import org.gradle.api.file.FileCollection
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Console
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.SourceTask
import org.gradle.api.tasks.TaskAction
import org.gradle.language.base.plugins.LifecycleBasePlugin
Expand All @@ -23,8 +23,7 @@ open class DetektIdeaInspectionTask : SourceTask() {
get() = source
set(value) = setSource(value)

@Internal
@Optional
@Console
var debug: Property<Boolean> = project.objects.property(Boolean::class.javaObjectType)

@Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.spekframework.spek2.style.specification.describe

object MultiVersionTest : Spek({

val testedGradleVersions = listOf("4.9", "5.4")
val testedGradleVersions = listOf("4.9", "5.6")

describe("detekt plugin running on different Gradle versions") {
listOf(groovy().dryRun(), kotlin().dryRun()).forEach { builder ->
Expand Down
23 changes: 19 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
detektVersion=1.0.1

# Project dependencies
assertjVersion=3.12.2
jcommanderVersion=1.78
junitPlatformVersion=1.4.1
ktlintVersion=0.34.2
reflectionsVersion=0.9.11
spekVersion=2.0.2
junitPlatformVersion=1.4.1
yamlVersion=1.24
jcommanderVersion=1.78
assertjVersion=3.13.2
reflectionsVersion=0.9.11

# Gradle plugins
artifactoryVersion=4.9.8
bintrayVersion=1.8.4
buildScanVersion=2.4
dokkaVersion=0.9.18
gradleVersionsPluginVersion=0.22.0
jacocoVersion=0.8.4
kotlinVersion=1.3.50
shadowVersion=5.1.0
sonarQubeVersion=2.7

# Gradle version
gradleVersion=5.6

kotlin.code.style=official

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
22 changes: 22 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,25 @@ include("detekt-api",
"detekt-formatting")

includeBuild("detekt-gradle-plugin")

val artifactoryVersion: String by settings
val bintrayVersion: String by settings
val buildScanVersion: String by settings
val dokkaVersion: String by settings
val gradleVersionsPluginVersion: String by settings
val kotlinVersion: String by settings
val shadowVersion: String by settings
val sonarQubeVersion: String by settings

pluginManagement {
plugins {
id("com.jfrog.artifactory") version artifactoryVersion
id("com.jfrog.bintray") version bintrayVersion
id("com.gradle.build-scan") version buildScanVersion
id("org.jetbrains.dokka") version dokkaVersion
id("com.github.ben-manes.versions") version gradleVersionsPluginVersion
kotlin("jvm") version kotlinVersion
id("com.github.johnrengelman.shadow") version shadowVersion
id("org.sonarqube") version sonarQubeVersion
}
}

0 comments on commit 383a1e0

Please sign in to comment.