-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
63 lines (49 loc) · 1.52 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
group 'me.antonle.algs4j'
version '1.0-SNAPSHOT'
apply plugin: 'java'
apply plugin: 'groovy'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile files('libs/algs4.jar')
testCompile 'junit:junit:4.12'
// mandatory dependencies for using Spock
compile "org.codehaus.groovy:groovy-all:2.4.1"
testCompile "org.spockframework:spock-core:1.0-groovy-2.4"
}
String submissionsDir = 'submissions'
String srcDir = 'src/main/java/me/antonle/algs4j'
task deleteCopySrc(type: Delete) {
delete(submissionsDir)
}
task copySrc(type: Copy, dependsOn: 'deleteCopySrc') {
from(srcDir)
include('**/*.java')
filter { String line ->
line.replaceAll($/package me.antonle.algs4j.*/$, "")
}
into("$submissionsDir/src")
}
task submitAll(dependsOn: tasks.matching { Task task -> task.name.startsWith("submit-") })
createZipTasks(submissionsDir, srcDir)
private void createZipTasks(String submissionsDir, String srcDir) {
FileTree tree = fileTree(srcDir).include('**/*.java') as FileTree
def dirs = []
tree.visit { FileVisitDetails element ->
if (element.isDirectory()) {
dirs << element.name
}
}
dirs.each { dirName ->
tasks.create(name: "submit-$dirName", dependsOn: 'copySrc', type: Zip) {
from("$submissionsDir/src/$dirName")
include('**/*.java')
destinationDir = file(submissionsDir)
baseName = dirName
version = null
}
}
}