/
ClojureScriptBuild.java
50 lines (39 loc) · 1.58 KB
/
ClojureScriptBuild.java
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
package dev.clojurephant.plugin.clojurescript;
import dev.clojurephant.plugin.clojurescript.tasks.ClojureScriptCompileOptions;
import dev.clojurephant.plugin.clojurescript.tasks.FigwheelOptions;
import org.apache.commons.text.WordUtils;
import org.gradle.api.Action;
import org.gradle.api.Named;
import org.gradle.api.file.ConfigurableFileCollection;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.file.FileTree;
import org.gradle.api.tasks.Nested;
public abstract class ClojureScriptBuild implements Named {
public abstract DirectoryProperty getOutputDir();
public abstract ConfigurableFileCollection getClasspath();
public abstract ConfigurableFileCollection getSourceRoots();
public FileTree getSourceTree() {
return getSourceRoots().getAsFileTree();
}
boolean isCompilerConfigured() {
return getCompiler().getOutputTo().isPresent() || getCompiler().getModules().stream()
.anyMatch(module -> module.getOutputTo().isPresent());
}
@Nested
public abstract ClojureScriptCompileOptions getCompiler();
public void compiler(Action<? super ClojureScriptCompileOptions> configureAction) {
configureAction.execute(getCompiler());
}
@Nested
public abstract FigwheelOptions getFigwheel();
public void figwheel(Action<? super FigwheelOptions> configureAction) {
configureAction.execute(getFigwheel());
}
String getTaskName(String task) {
if ("main".equals(getName())) {
return String.format("%sClojureScript", task);
} else {
return String.format("%s%sClojureScript", task, WordUtils.capitalize(getName()));
}
}
}