-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle
More file actions
179 lines (162 loc) · 4.69 KB
/
build.gradle
File metadata and controls
179 lines (162 loc) · 4.69 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
plugins {
id 'java'
}
sourceSets {
chapitre_2 {
java {
srcDirs = ['chapitre_2']
}
}
chapitre_3 {
java {
srcDirs = ['chapitre_3']
}
}
chapitre_4 {
java {
srcDirs = ['chapitre_4']
exclude '**/ExempleVariablesLocalesErreur.java'
}
}
chapitre_5 {
java {
srcDirs = ['chapitre_5']
}
}
chapitre_6 {
java {
srcDirs = ['chapitre_6']
}
}
chapitre_7 {
java {
srcDirs = ['chapitre_7']
}
}
chapitre_8 {
java {
srcDirs = ['chapitre_8']
}
}
chapitre_9 {
java {
srcDirs = ['chapitre_9']
}
}
extra {
java {
srcDirs = ['extra']
}
}
}
// Ensure UTF-8 encoding
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Dependencies (if needed)
dependencies {
// Add dependencies here if required
}
tasks.register('runMain', JavaExec) {
group = 'application'
description = 'Run a specific main class from any chapter.'
doFirst {
if (!project.hasProperty('mainClass')) {
throw new GradleException("Please specify the main class using -PmainClass=<className>")
}
mainClass.set(project.mainClass)
}
}
tasks.register('listMainClasses') {
group = 'application'
description = 'List all Java classes with a main method.'
doLast {
def mainClasses = []
sourceSets.each { sourceSet ->
sourceSet.allSource.matching {
include '**/*.java'
}.each { file ->
def content = file.text
if (content.contains('public static void main(')) {
mainClasses << file.path.replace('/', '.').replace('.java', '')
}
}
}
println 'Main classes detected:'
mainClasses.each { println it }
}
}
tasks.register('buildChapitre_2', JavaCompile) {
group = 'build'
description = 'Compile only chapitre_2.'
source = sourceSets.chapitre_2.java
classpath = sourceSets.chapitre_2.compileClasspath
destinationDirectory = file("${buildDir}/classes/chapitre_2")
options.encoding = 'UTF-8'
}
tasks.register('buildChapitre_3', JavaCompile) {
group = 'build'
description = 'Compile only chapitre_3.'
source = sourceSets.chapitre_3.java
classpath = sourceSets.chapitre_3.compileClasspath
destinationDirectory = file("${buildDir}/classes/chapitre_3")
options.encoding = 'UTF-8'
}
tasks.register('buildChapitre_4', JavaCompile) {
group = 'build'
description = 'Compile only chapitre_4.'
source = sourceSets.chapitre_4.java
classpath = sourceSets.chapitre_4.compileClasspath
destinationDirectory = file("${buildDir}/classes/chapitre_4")
options.encoding = 'UTF-8'
}
tasks.register('buildChapitre_5', JavaCompile) {
group = 'build'
description = 'Compile only chapitre_5.'
source = sourceSets.chapitre_5.java
classpath = sourceSets.chapitre_5.compileClasspath
destinationDirectory = file("${buildDir}/classes/chapitre_5")
options.encoding = 'UTF-8'
}
tasks.register('buildChapitre_6', JavaCompile) {
group = 'build'
description = 'Compile only chapitre_6.'
source = sourceSets.chapitre_6.java
classpath = sourceSets.chapitre_6.compileClasspath
destinationDirectory = file("${buildDir}/classes/chapitre_6")
options.encoding = 'UTF-8'
}
tasks.register('buildChapitre_7', JavaCompile) {
group = 'build'
description = 'Compile only chapitre_7.'
source = sourceSets.chapitre_7.java
classpath = sourceSets.chapitre_7.compileClasspath
destinationDirectory = file("${buildDir}/classes/chapitre_7")
options.encoding = 'UTF-8'
}
tasks.register('buildChapitre_8', JavaCompile) {
group = 'build'
description = 'Compile only chapitre_8.'
source = sourceSets.chapitre_8.java
classpath = sourceSets.chapitre_8.compileClasspath
destinationDirectory = file("${buildDir}/classes/chapitre_8")
options.encoding = 'UTF-8'
}
tasks.register('buildChapitre_9', JavaCompile) {
group = 'build'
description = 'Compile only chapitre_9.'
source = sourceSets.chapitre_9.java
classpath = sourceSets.chapitre_9.compileClasspath
destinationDirectory = file("${buildDir}/classes/chapitre_9")
options.encoding = 'UTF-8'
}
tasks.register('copyNonJavaFilesChapitre9', Copy) {
group = 'build'
description = 'Copie tous les fichiers non-Java de tous les chapitres vers le répertoire racine.'
[2,3,4,5,6,7,8,9].each { num ->
from("chapitre_${num}") {
exclude '**/*.java'
}
}
into '.'
}