-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
122 lines (105 loc) · 3.92 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
122 lines (105 loc) · 3.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("groovy")
id("kotlin")
id("java-gradle-plugin")
id("jacoco")
// id("com.github.johnrengelman.shadow")
}
// ------------------------------------------------------------------------------------------------
// Compilation Tweaks
//
// The plugin currently consists of a codebase wherein Groovy & Kotlin coexist.
// Therefore, the compilation chain has to be well-defined to allow Kotlin
// to call into Groovy code.
//
// The other way around ("call Kotlin from Groovy") is prohibited explicitly.
// ------------------------------------------------------------------------------------------------
val javaVersion = JavaVersion.VERSION_11.toString()
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = javaVersion
}
tasks.withType<JavaCompile> {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
project.fixCompileTaskChain()
kotlin {
explicitApi()
}
// ------------------------------------------------------------------------------------------------
// Plugin Resource Setup
//
// This block generates the required resource files
// containing the identifiers with which the plugin can be applied to consumer projects.
// ------------------------------------------------------------------------------------------------
val pluginClassName = "de.mannodermaus.gradle.plugins.junit5.AndroidJUnitPlatformPlugin"
gradlePlugin {
plugins {
create("plugin") {
id = "de.mannodermaus.android-junit5"
implementationClass = pluginClassName
}
}
}
// ------------------------------------------------------------------------------------------------
// Task Setup
// ------------------------------------------------------------------------------------------------
// Allow building fat JARs if necessary
//tasks.withType<ShadowJar> {
// isZip64 = true
// enabled = project.hasProperty("enableFatJar")
// archiveAppendix.set("fat")
//}
// Use JUnit 5
tasks.withType<Test> {
useJUnitPlatform()
failFast = true
testLogging {
events = setOf(TestLogEvent.STARTED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
exceptionFormat = TestExceptionFormat.FULL
}
}
// Setup environment & versions for test projects
project.configureTestResources()
// Generate a file with the latest versions of the plugin & instrumentation
val genFolder = "build/generated/sources/plugin"
val versionClassTask = tasks.register<Copy>(
"createVersionClass",
Copy::configureCreateVersionClassTask,
)
sourceSets {
main {
kotlin.srcDir(genFolder)
}
}
// ------------------------------------------------------------------------------------------------
// Dependency Definitions
// ------------------------------------------------------------------------------------------------
dependencies {
compileOnly(libs.plugins.android(SupportedAgp.oldest))
compileOnly(libs.androidTools)
compileOnly(libs.plugins.kotlin)
implementation(gradleApi())
implementation(libs.kotlinStdLib)
implementation(libs.junitPlatformCommons)
testImplementation(gradleTestKit())
testImplementation(libs.plugins.android(SupportedAgp.oldest))
testImplementation(libs.korte)
testImplementation(libs.konfToml)
testImplementation(libs.truth)
testImplementation(libs.junitJupiterApi)
testImplementation(libs.junitJupiterParams)
testRuntimeOnly(libs.junitJupiterEngine)
testRuntimeOnly(libs.junitPlatformLauncher)
}
project.configureDeployment(Artifacts.Plugin)
// Register source-processing tasks as dependants of the custom source generation task
listOf("compileKotlin", "androidSourcesJar", "dokkaGeneratePublicationHtml").forEach { taskName ->
tasks.named(taskName).configure {
dependsOn(versionClassTask)
}
}