File tree 6 files changed +62
-4
lines changed
src/main/kotlin/org/cqfn/save/buildutils
6 files changed +62
-4
lines changed Original file line number Diff line number Diff line change 35
35
# additional files to calculate key for dependency cache
36
36
gradle-dependencies-cache-key : |
37
37
buildSrc/**/Versions.kt
38
- # Until https://github.com/burrunan/gradle-cache-action/issues/42 is addressed, gradle should be run as a separate step
39
- - name : Run gradle command
40
- run : ./gradlew build --build-cache
38
+ # Note: https://github.com/burrunan/gradle-cache-action/issues/42 can possible break this
39
+ arguments : |
40
+ build
41
+ -PdisableRedundantTargets
42
+ -x linkReleaseExecutableLinuxX64
43
+ -x linkReleaseExecutableMingwX64
44
+ -x linkReleaseExecutableMacosX64
45
+ properties : |
46
+ org.gradle.caching=true
41
47
- name : Upload gradle reports
42
48
if : ${{ always() }}
43
49
uses : actions/upload-artifact@v2
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import org.cqfn.save.buildutils.configurePublishing
4
4
import org.cqfn.save.buildutils.configureVersioning
5
5
import org.cqfn.save.buildutils.createDetektTask
6
6
import org.cqfn.save.buildutils.createDiktatTask
7
+ import org.cqfn.save.buildutils.disableRedundantKmpTargets
7
8
import org.cqfn.save.buildutils.installGitHooks
8
9
9
10
plugins {
@@ -26,6 +27,8 @@ allprojects {
26
27
}
27
28
configureDiktat()
28
29
configureDetekt()
30
+
31
+ disableRedundantKmpTargets()
29
32
}
30
33
createDiktatTask()
31
34
createDetektTask()
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ repositories {
8
8
9
9
dependencies {
10
10
implementation(" org.cqfn.diktat:diktat-gradle-plugin:1.0.0-rc.1" )
11
- implementation(" io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.16.0 " )
11
+ implementation(" io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.17.1 " )
12
12
runtimeOnly(kotlin(" gradle-plugin" , " 1.5.0" ))
13
13
implementation(" io.github.gradle-nexus:publish-plugin:1.1.0" )
14
14
implementation(" org.ajoberstar.reckon:reckon-gradle:0.13.0" )
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import io.gitlab.arturbosch.detekt.Detekt
8
8
import io.gitlab.arturbosch.detekt.DetektPlugin
9
9
import io.gitlab.arturbosch.detekt.extensions.DetektExtension
10
10
import org.gradle.api.Project
11
+ import org.gradle.api.tasks.TaskProvider
11
12
import org.gradle.kotlin.dsl.apply
12
13
import org.gradle.kotlin.dsl.configure
13
14
import org.gradle.kotlin.dsl.withType
@@ -21,6 +22,21 @@ fun Project.configureDetekt() {
21
22
config = rootProject.files(" detekt.yml" )
22
23
buildUponDefaultConfig = true
23
24
}
25
+ // extremely awful hack to get to the point, when `DetektMultiplatform` has registered all the tasks
26
+ afterEvaluate {
27
+ // detekt registers tasks after Kotlin plugin has set up all targets
28
+ afterEvaluate {
29
+ // but they also use a nested `afterEvaluate` for interop with Android Gradle Plugin
30
+ afterEvaluate {
31
+ // so we need a third `afterEvaluate`, so that all detekt tasks are already registered
32
+ tasks.matching { it.name == " check" }.configureEach {
33
+ dependsOn.removeIf {
34
+ it is TaskProvider <* > && it.name.startsWith(" detekt" )
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
24
40
}
25
41
26
42
/* *
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Utility functions to configure Kotlin in Gradle
3
+ */
4
+
5
+ package org.cqfn.save.buildutils
6
+
7
+ import org.gradle.api.GradleException
8
+ import org.gradle.api.Project
9
+ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
10
+
11
+ /* *
12
+ * Some Kotlin Multiplatform targets are available on multiple OS.
13
+ *
14
+ * @throws GradleException if executed on some exotic OS
15
+ */
16
+ fun Project.disableRedundantKmpTargets () {
17
+ if (hasProperty(" disableRedundantTargets" ) && (property(" disableRedundantTargets" ) as String? ) != " false" ) {
18
+ afterEvaluate {
19
+ val currentOs = DefaultNativePlatform .getCurrentOperatingSystem()
20
+ val redundantTarget: String? = when {
21
+ currentOs.isWindows -> " linuxX64"
22
+ currentOs.isMacOsX -> " linuxX64"
23
+ currentOs.isLinux -> null
24
+ else -> throw GradleException (" Unknown operating system ${currentOs.name} " )
25
+ }
26
+ tasks.matching { redundantTarget != null && it.name.contains(redundantTarget, ignoreCase = true ) }
27
+ .configureEach {
28
+ enabled = false
29
+ }
30
+ }
31
+ }
32
+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ group=org.cqfn.save
4
4
org.gradle.parallel =true
5
5
org.gradle.vfs.watch =true
6
6
org.gradle.jvmargs =-Xmx1g -XX:MaxMetaspaceSize=512m
7
+ org.gradle.caching =true
7
8
8
9
# Kotlin
9
10
kotlin.code.style =official
You can’t perform that action at this time.
0 commit comments