/
ClojureBuild.java
65 lines (49 loc) · 1.84 KB
/
ClojureBuild.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package dev.clojurephant.plugin.clojure;
import java.util.Set;
import dev.clojurephant.plugin.clojure.tasks.ClojureCompileOptions;
import dev.clojurephant.plugin.common.internal.Namespaces;
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.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.SetProperty;
import org.gradle.api.tasks.Nested;
public abstract class ClojureBuild implements Named {
public abstract DirectoryProperty getOutputDir();
public abstract ConfigurableFileCollection getClasspath();
public abstract ConfigurableFileCollection getSourceRoots();
public FileTree getSourceTree() {
return getSourceRoots().getAsFileTree();
}
Provider<Set<String>> getAllNamespaces() {
return Namespaces.findNamespaces(getSourceTree());
}
public abstract SetProperty<String> getCheckNamespaces();
public void checkAll() {
getCheckNamespaces().set(getAllNamespaces());
}
public abstract Property<String> getReflection();
boolean isCompilerConfigured() {
return getAotNamespaces().map(set -> !set.isEmpty()).getOrElse(false);
}
public abstract SetProperty<String> getAotNamespaces();
public void aotAll() {
getAotNamespaces().set(getAllNamespaces());
}
@Nested
public abstract ClojureCompileOptions getCompiler();
public void compiler(Action<? super ClojureCompileOptions> configureAction) {
configureAction.execute(getCompiler());
}
String getTaskName(String task) {
if ("main".equals(getName())) {
return String.format("%sClojure", task);
} else {
return String.format("%s%sClojure", task, WordUtils.capitalize(getName()));
}
}
}