blob: 90609607736a088574c0d79c2fb25e655d0b6d96 (
plain)
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
|
import com.moowork.gradle.node.NodeExtension
import com.pitchedapps.frost.gradle.WebGenInstallTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.internal.file.FileResolver
import javax.inject.Inject
class WebGenPlugin implements Plugin<Project> {
private static final String NODE_VERSION = "12.4.0"
private Project project
private final FileResolver fileResolver
@Inject
WebGenPlugin(FileResolver fileResolver) {
this.fileResolver = fileResolver
}
/**
* Based on https://github.com/apollographql/apollo-android/blob/master/apollo-gradle-plugin/src/main/groovy/com/apollographql/apollo/gradle/ApolloPlugin.groovy
* @param target
*/
@Override
void apply(Project target) {
this.project = project
project.plugins.withId("java-base") {
applyWebGenPlugin()
}
project.gradle.getTaskGraph().whenReady {
if (!project.plugins.hasPlugin("java-base")) {
throw new IllegalArgumentException(
"Frost Web Gen plugin can't be applied without Android or Java or Kotlin plugin.")
}
}
}
private void applyWebGenPlugin() {
setupNode()
project.tasks.create(WebGenInstallTask.NAME, WebGenInstallTask.class)
}
private void setupNode() {
project.plugins.apply NodePlugin
NodeExtension nodeConfig = project.extensions.findByName("node") as NodeExtension
nodeConfig.download = true
nodeConfig.version = NODE_VERSION
}
}
|