-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
144 lines (126 loc) · 3.67 KB
/
build.gradle
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
plugins {
id "application";
}
def defaultMainClassName = "cosc202.andie.Andie";
application {
mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : defaultMainClassName;
}
repositories {
mavenCentral();
}
// use a project layout that is compatible with the standard VS Code java extension
sourceSets {
main {
resources {
srcDirs = ['src']
}
java{
srcDirs = ['src']
}
}
}
dependencies {
// https://mavenlibs.com/maven/dependency/com.formdev/flatlaf
implementation 'com.formdev:flatlaf:3.2'
}
run {
standardInput = System.in;
}
// adds location of javadocs to /docs dir
javadoc {
destinationDir = file("/docs")
}
/* convenience tasks for working with a project */
tasks.register("createMissingSourceDirs") {
group = "Project";
description = "Create all of the missing source directories for this project.";
doFirst {
sourceSets.each { def sourceRoot ->
sourceRoot.allSource.srcDirTrees.each { def sourceDir ->
if(!sourceDir.dir.exists()) {
println "Creating source ${sourceDir}";
mkdir sourceDir.dir;
}
}
}
}
}
tasks.register("deleteEmptySourceDirs") {
group = "Project";
description = "Delete empty source directories.";
doFirst {
sourceSets.each { def sourceRoot ->
sourceRoot.allSource.srcDirTrees.each { def sourceDir ->
if(sourceDir.dir.exists() && sourceDir.dir.isDirectory() && sourceDir.dir.list().length == 0) {
println "Removing empty source ${sourceDir}";
sourceDir.dir.delete();
}
}
}
}
}
tasks.register("openProjectDir") {
group = "Project";
description = "Open the project directory in the system file manager.";
doFirst {
println("Opening: " + file(projectDir));
java.awt.Desktop.getDesktop().open(file(projectDir));
}
}
tasks.register("openBuildDir") {
group = "Project";
description = "Open the project build directory in the system file manager.";
doFirst {
println("Opening: " + file(buildDir));
java.awt.Desktop.getDesktop().open(file(buildDir));
}
}
tasks.register("createGitIgnore") {
group = "Project";
description = "Create the project's .gitignore file.";
def gitIgnored="""
.gradle/
.nb-gradle/
.settings/
nbproject/
build/
bin/
dist/
tmp/
.classpath
.project
*.zip
*.tgz
*.tar.gz
*.class
*.jar
.DS_Store
!gradle-wrapper.jar
""";
doLast {
def file = new File(projectDir, ".gitignore");
if ( !file.exists() ) {
println("Creating .gitignore");
gitIgnored.lines().each { f ->
if(!f.trim().isBlank()) {
file.append(f.trim()+"\n");
}
}
} else {
println(".gitignore already exists");
}
}
}
tasks.register("info") {
group = "Project";
description = "Show version and location information for Java, Gradle, and project.";
doLast {
println "Java Version: " + org.gradle.internal.jvm.Jvm.current();
println "Java Home: " + org.gradle.internal.jvm.Jvm.current().getJavaHome();
println "Gradle Version: ${gradle.gradleVersion}";
println "Gradle Home: ${gradle.gradleHomeDir}";
println "Gradle User Home: ${gradle.gradleUserHomeDir}";
println "Project Location: ${projectDir}";
println "Project Build Location: ${buildDir}";
}
}