-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpom.xml
More file actions
208 lines (200 loc) · 9.14 KB
/
pom.xml
File metadata and controls
208 lines (200 loc) · 9.14 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
>
<modelVersion>4.0.0</modelVersion>
<groupId>LeetCode.qubhjava</groupId>
<artifactId>qubhjava</artifactId>
<version>2.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>21</maven.compiler.release>
<javafx.version>21</javafx.version>
<javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
</properties>
<dependencies>
<!-- log -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.13</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>[1.5.13,)</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>[1.5.13,)</version>
</dependency>
<!-- json -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.31</version>
</dependency>
<!-- javafx Pair -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<!-- test -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.7.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<scope>compile</scope>
</dependency>
<!-- dot env -->
<dependency>
<groupId>io.github.cdimascio</groupId>
<artifactId>dotenv-java</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Groovy脚本执行器 -->
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>4.2.0</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.25</version>
<type>pom</type>
</dependency>
</dependencies>
<executions>
<execution>
<id>parse-config</id>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<scripts>
<script><![CDATA[
import groovy.json.JsonSlurper
import java.nio.file.*
// 1. 读取.env文件
def envFile = Paths.get(project.basedir.toString(), ".env").toFile()
def baseDir = "problems"
if (envFile.exists()) {
envFile.eachLine { line ->
if (line.startsWith("PROBLEM_FOLDER=")) {
baseDir = line.split("=")[1].trim()
baseDir = baseDir.replaceAll('"', '')
}
}
println "Using base directory from .env file: ${baseDir}"
} else {
println "Error: ${envFile.absolutePath} not found, using default base directory: ${baseDir}"
}
// 2. 读取config.json
def configFile = Paths.get(project.basedir.toString(), "daily-${baseDir}.json").toFile()
if (!configFile.exists()) {
throw new RuntimeException("Config file not found: ${configFile.absolutePath}")
}
def config = new JsonSlurper().parse(configFile)
// 3. 构建源目录列表
def sources = [] as Set
sources.add(Paths.get(project.basedir.toString(), baseDir, "${baseDir}_${config.daily}").toFile().absolutePath)
// config.plans might be null or empty, handle it gracefully
if (config.plans == null || config.plans.isEmpty()) {
println "Warning: No plans found in config, using only daily source."
} else {
for (int i = 0; i < config.plans.size(); i += 2) {
def problem = config.plans[i]
def folder = config.plans[i + 1]
sources.add(Paths.get(project.basedir.toString(), folder, "${folder}_${problem}").toFile().absolutePath)
}
}
println "==> Add dynamic source roots:"
sources.each { println " - $it" }
// 4. 设置Maven属性
sources.eachWithIndex { source, index ->
project.properties["dynamic.source${index + 1}"] = source
}
// 5. 补全10个
(sources.size()..9).each { index ->
project.properties["dynamic.source${index + 1}"] = "qubhjava"
}
]]></script>
</scripts>
</configuration>
</execution>
</executions>
</plugin>
<!-- 添加动态源目录插件 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>add-problem-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${dynamic.source1}</source>
<source>${dynamic.source2}</source>
<source>${dynamic.source3}</source>
<source>${dynamic.source4}</source>
<source>${dynamic.source5}</source>
<source>${dynamic.source6}</source>
<source>${dynamic.source7}</source>
<source>${dynamic.source8}</source>
<source>${dynamic.source9}</source>
<source>${dynamic.source10}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.maven.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>21</source>
<target>21</target>
<excludes>
<exclude>bazel-*/**</exclude>
<exclude>external/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<sourceDirectory>qubhjava</sourceDirectory>
<testSourceDirectory>qubhjava/test</testSourceDirectory>
</build>
</project>