-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
177 lines (149 loc) · 4.52 KB
/
build.gradle
File metadata and controls
177 lines (149 loc) · 4.52 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
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'eclipse'
id 'idea'
}
group = 'com.algodesigner.eclipseformat'
version = '0.1'
sourceCompatibility = '15'
targetCompatibility = '15'
repositories {
mavenCentral()
maven {
url 'https://repo.eclipse.org/content/repositories/eclipse-releases/'
}
maven {
url 'https://repo.eclipse.org/content/groups/releases/'
}
}
dependencies {
implementation 'info.picocli:picocli:4.7.5'
annotationProcessor 'info.picocli:picocli-codegen:4.7.5'
// Eclipse JDT Core - includes the formatter
implementation 'org.eclipse.jdt:org.eclipse.jdt.core:3.40.0'
// Explicitly add eclipse.text to help IDEs resolve dependencies
implementation 'org.eclipse.platform:org.eclipse.text:3.14.200'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
testImplementation 'org.assertj:assertj-core:3.24.2'
testImplementation 'org.mockito:mockito-core:5.7.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.7.0'
}
application {
mainClass = 'com.algodesigner.eclipseformat.cli.EclipseFormatCli'
}
jar {
manifest {
attributes(
'Main-Class': 'com.algodesigner.eclipseformat.cli.EclipseFormatCli'
)
}
}
shadowJar {
archiveBaseName = 'eclipse-format'
archiveClassifier = ''
archiveVersion = ''
}
test {
useJUnitPlatform()
}
compileJava {
options.compilerArgs += ["-Aproject=${project.group}/eclipseformat"]
}
eclipse {
classpath {
downloadSources = true
downloadJavadoc = true
}
jdt {
// Set UTF-8 encoding for source files
file {
withProperties { properties ->
properties.put('encoding/<project>', 'UTF-8')
}
}
}
// Create project-specific settings
project {
// This ensures the .settings directory is created with proper files
file {
// Create org.eclipse.core.resources.prefs with UTF-8 encoding
withXml { xmlProvider ->
// This is a workaround to ensure the .settings directory exists
// The actual file creation happens through the eclipse task
}
}
}
}
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}
tasks.register('setupEclipse') {
group = 'IDE'
description = 'Setup Eclipse project files'
dependsOn 'eclipse'
doLast {
println 'Eclipse project files generated. Import project using File → Import → Existing Gradle Project'
}
}
tasks.register('setupIntelliJ') {
group = 'IDE'
description = 'Setup IntelliJ IDEA project files'
dependsOn 'idea'
doLast {
println 'IntelliJ IDEA project files generated. Open project using File → Open'
}
}
tasks.register('cleanIDE') {
group = 'IDE'
description = 'Clean IDE project files'
doLast {
delete '.idea'
delete '.classpath'
delete '.project'
delete '.settings'
println 'Cleaned IDE project files'
}
}
// Task to format the project's own source code using the built formatter
task formatSource(type: JavaExec) {
group = 'Formatting'
description = 'Format the project\'s own source code using the Eclipse formatter'
dependsOn shadowJar
classpath = files("build/libs/eclipse-format.jar")
mainClass = 'com.algodesigner.eclipseformat.cli.EclipseFormatCli'
args = ['-r', 'src/', '--config', 'eclipse-format.xml']
doFirst {
println 'Formatting project source code...'
}
doLast {
println 'Project source code formatting complete'
}
}
// Task to check formatting without making changes (dry run)
task checkFormat(type: JavaExec) {
group = 'Formatting'
description = 'Check if project source code needs formatting (dry run)'
dependsOn shadowJar
classpath = files("build/libs/eclipse-format.jar")
mainClass = 'com.algodesigner.eclipseformat.cli.EclipseFormatCli'
args = ['-r', 'src/', '--config', 'eclipse-format.xml', '--dry-run']
doFirst {
println 'Checking project source code formatting...'
}
doLast {
println 'Format check complete - files that would be formatted are listed above'
}
}
// Make the build task depend on format check to ensure code is properly formatted
tasks.named('build') {
dependsOn checkFormat
}
// Make the test task also depend on format check
tasks.named('test') {
dependsOn checkFormat
}