forked from JakeWharton/paraphrase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
124 lines (111 loc) · 3.79 KB
/
build.gradle.kts
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
123
124
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.gradle.plugins.ide.idea.model.IdeaModel
import org.gradle.plugins.ide.idea.model.IdeaProject
import org.jetbrains.gradle.ext.ProjectSettings
import org.jetbrains.gradle.ext.TaskTriggersConfig
plugins {
id("org.jetbrains.kotlin.jvm") version "1.4.30"
`kotlin-dsl`
groovy
maven
`java-gradle-plugin`
id("com.gradle.plugin-publish") version "0.13.0"
id("org.jetbrains.gradle.plugin.idea-ext") version "1.0"
}
/*
* Some classpath manipulation magic in order for the test fixtures to be able to find/see the actual plugin,
* otherwise the GradleRunner will fail with "plugin com.whatever not found"
*/
val testSourceSet = sourceSets["test"].apply {
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
runtimeClasspath += output + compileClasspath
}
tasks.named<Test>("test").configure {
testClassesDirs += testSourceSet.output.classesDirs
classpath += testSourceSet.runtimeClasspath
}
///*
// * Extra configuration needed to enable the text fixtures classpath to see the plugin's classpath
// *
// * See:
// * https://stackoverflow.com/a/54393454/1452741
// */
//val fixIdeaPluginClasspath = task("fixIdeaPluginClasspath") {
// doFirst {
// tasks.withType<PluginUnderTestMetadata>().configureEach {
// val ideaClassesPath = project.buildDir.toPath().resolveSibling("out").resolve("production")
// val newClasspath = project.files().map { it.toPath() }.toMutableList()
// newClasspath.add(0, ideaClassesPath)
// pluginClasspath.setFrom(newClasspath)
// }
// }
//}
//
//tasks.withType<PluginUnderTestMetadata>().configureEach {
// mustRunAfter(fixIdeaPluginClasspath)
// pluginClasspath.from(configurations.compileOnly)
//}
//
//
//// Below is from:
//// https://github.com/JetBrains/gradle-idea-ext-plugin/issues/76#issuecomment-483373014
//fun Project.idea(block: IdeaModel.() -> Unit) =
// (this as ExtensionAware).extensions.configure("idea", block)
//
//fun IdeaProject.settings(block: ProjectSettings.() -> Unit) =
// (this@settings as ExtensionAware).extensions.configure(block)
//
//fun ProjectSettings.taskTriggers(block: TaskTriggersConfig.() -> Unit) =
// (this@taskTriggers as ExtensionAware).extensions.configure("taskTriggers", block)
//
//rootProject.idea {
// project {
// settings {
// taskTriggers {
// val pluginUnderTestMetadata = tasks.withType<PluginUnderTestMetadata>().first()
// beforeBuild(fixIdeaPluginClasspath, pluginUnderTestMetadata)
// }
// }
// }
//}
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven("https://plugins.gradle.org/m2/")
}
dependencies {
compileOnly(gradleApi())
implementation(localGroovy())
implementation("com.android.tools.build:gradle:3.6.1")
testRuntimeOnly("com.android.tools.build:gradle:3.6.1")
implementation("com.android.tools:sdk-common:27.0.2")
implementation("com.squareup:javawriter:2.4.0")
implementation("com.google.guava:guava:16.0.1")
testImplementation("junit:junit:4.12")
testImplementation("com.google.truth:truth:1.0.1")
testImplementation(gradleTestKit())
}
gradlePlugin {
plugins {
create("paraphrase") {
id = "com.jakewharton.paraphrase"
implementationClass = "com.jakewharton.paraphrase.ParaphrasePlugin"
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
}
group = "com.jakewharton.paraphrase"
version = "1.0.0-SNAPSHOT"
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
languageVersion = "1.4"
}