|
|
|
|
@ -1,367 +1,383 @@
|
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
|
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
|
|
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
|
|
|
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
|
|
|
<modelVersion>4.0.0</modelVersion>
|
|
|
|
|
<groupId>com.coproject</groupId>
|
|
|
|
|
<artifactId>math-learning</artifactId>
|
|
|
|
|
<version>0.1.2</version>
|
|
|
|
|
|
|
|
|
|
<properties>
|
|
|
|
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
|
|
|
<maven.compiler.source>17</maven.compiler.source>
|
|
|
|
|
<maven.compiler.target>17</maven.compiler.target>
|
|
|
|
|
<maven.compiler.release>17</maven.compiler.release>
|
|
|
|
|
<javafx.version>21.0.3</javafx.version>
|
|
|
|
|
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
|
|
|
|
|
</properties>
|
|
|
|
|
|
|
|
|
|
<dependencies>
|
|
|
|
|
<!-- JavaFX UI -->
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>org.openjfx</groupId>
|
|
|
|
|
<artifactId>javafx-controls</artifactId>
|
|
|
|
|
<version>${javafx.version}</version>
|
|
|
|
|
<classifier>win</classifier>
|
|
|
|
|
</dependency>
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>org.openjfx</groupId>
|
|
|
|
|
<artifactId>javafx-fxml</artifactId>
|
|
|
|
|
<version>${javafx.version}</version>
|
|
|
|
|
<classifier>win</classifier>
|
|
|
|
|
</dependency>
|
|
|
|
|
|
|
|
|
|
<!-- JSON storage -->
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>com.fasterxml.jackson.core</groupId>
|
|
|
|
|
<artifactId>jackson-databind</artifactId>
|
|
|
|
|
<version>2.17.1</version>
|
|
|
|
|
</dependency>
|
|
|
|
|
|
|
|
|
|
<!-- Mail sending (Jakarta Mail implementation) -->
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>com.sun.mail</groupId>
|
|
|
|
|
<artifactId>jakarta.mail</artifactId>
|
|
|
|
|
<version>2.0.1</version>
|
|
|
|
|
</dependency>
|
|
|
|
|
|
|
|
|
|
<!-- Commons Lang for utilities -->
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>org.apache.commons</groupId>
|
|
|
|
|
<artifactId>commons-lang3</artifactId>
|
|
|
|
|
<version>3.14.0</version>
|
|
|
|
|
</dependency>
|
|
|
|
|
</dependencies>
|
|
|
|
|
|
|
|
|
|
<build>
|
|
|
|
|
<finalName>${artifactId}-${version}</finalName>
|
|
|
|
|
<plugins>
|
|
|
|
|
<!-- 编译器插件 -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-compiler-plugin</artifactId>
|
|
|
|
|
<version>3.11.0</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<source>${maven.compiler.source}</source>
|
|
|
|
|
<target>${maven.compiler.target}</target>
|
|
|
|
|
</configuration>
|
|
|
|
|
</plugin>
|
|
|
|
|
|
|
|
|
|
<!-- Enable `mvn javafx:run` for local development -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.openjfx</groupId>
|
|
|
|
|
<artifactId>javafx-maven-plugin</artifactId>
|
|
|
|
|
<version>0.0.8</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<mainClass>com.coproject.MainApp</mainClass>
|
|
|
|
|
</configuration>
|
|
|
|
|
</plugin>
|
|
|
|
|
|
|
|
|
|
<!-- 生成主 JAR -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-jar-plugin</artifactId>
|
|
|
|
|
<version>3.3.0</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist</outputDirectory>
|
|
|
|
|
<archive>
|
|
|
|
|
<manifest>
|
|
|
|
|
<addClasspath>true</addClasspath>
|
|
|
|
|
<classpathPrefix>lib/</classpathPrefix>
|
|
|
|
|
<mainClass>com.coproject.MainApp</mainClass>
|
|
|
|
|
</manifest>
|
|
|
|
|
</archive>
|
|
|
|
|
</configuration>
|
|
|
|
|
</plugin>
|
|
|
|
|
|
|
|
|
|
<!-- 复制依赖到 lib 目录 -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-dependency-plugin</artifactId>
|
|
|
|
|
<version>3.6.1</version>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>copy-dependencies</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>copy-dependencies</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist/lib</outputDirectory>
|
|
|
|
|
<includeScope>runtime</includeScope>
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
|
|
|
|
|
<!-- 复制 JavaFX Windows JAR 和配置文件 -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-resources-plugin</artifactId>
|
|
|
|
|
<version>3.3.1</version>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>copy-javafx-win</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>copy-resources</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist/lib</outputDirectory>
|
|
|
|
|
<resources>
|
|
|
|
|
<resource>
|
|
|
|
|
<directory>${project.basedir}/lib/javafx-win</directory>
|
|
|
|
|
<includes>
|
|
|
|
|
<include>*.jar</include>
|
|
|
|
|
</includes>
|
|
|
|
|
</resource>
|
|
|
|
|
</resources>
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>copy-config-files</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>copy-resources</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist</outputDirectory>
|
|
|
|
|
<resources>
|
|
|
|
|
<resource>
|
|
|
|
|
<directory>${project.basedir}</directory>
|
|
|
|
|
<includes>
|
|
|
|
|
<include>smtp.env.example</include>
|
|
|
|
|
<include>README.md</include>
|
|
|
|
|
<include>configure_smtp_qq.ps1</include>
|
|
|
|
|
</includes>
|
|
|
|
|
</resource>
|
|
|
|
|
</resources>
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
|
|
|
|
|
<!-- 创建数据目录 -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-antrun-plugin</artifactId>
|
|
|
|
|
<version>3.1.0</version>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>create-data-directories</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<configuration>
|
|
|
|
|
<target>
|
|
|
|
|
<mkdir dir="${project.build.directory}/dist/data"/>
|
|
|
|
|
<mkdir dir="${project.build.directory}/dist/data/papers"/>
|
|
|
|
|
<copy file="${project.basedir}/smtp.env.example"
|
|
|
|
|
tofile="${project.build.directory}/dist/data/smtp.env"
|
|
|
|
|
overwrite="true"/>
|
|
|
|
|
<echo file="${project.build.directory}/dist/data/papers/README.txt">试卷存储目录
|
|
|
|
|
将生成的试卷PDF文件保存在此目录中。
|
|
|
|
|
</echo>
|
|
|
|
|
</target>
|
|
|
|
|
</configuration>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>run</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
</execution>
|
|
|
|
|
|
|
|
|
|
<!-- 自动生成分发包 -->
|
|
|
|
|
<execution>
|
|
|
|
|
<id>create-distribution</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<configuration>
|
|
|
|
|
<target>
|
|
|
|
|
<echo>=== 开始生成分发包 ===</echo>
|
|
|
|
|
|
|
|
|
|
<!-- 创建分发目录 -->
|
|
|
|
|
<mkdir dir="${project.build.directory}/数学学习软件-${project.version}"/>
|
|
|
|
|
|
|
|
|
|
<!-- 生成正确的启动脚本 -->
|
|
|
|
|
<echo file="${project.build.directory}/数学学习软件-${project.version}/run.bat">@echo off
|
|
|
|
|
chcp 65001 >nul
|
|
|
|
|
title 数学学习软件
|
|
|
|
|
echo 启动数学学习软件...
|
|
|
|
|
|
|
|
|
|
REM 检查JAR文件是否存在
|
|
|
|
|
if not exist "math-learning-0.1.2.jar" (
|
|
|
|
|
echo 错误: 找不到主程序文件 math-learning-0.1.2.jar
|
|
|
|
|
echo 请确保所有文件在同一个目录下
|
|
|
|
|
pause
|
|
|
|
|
exit /b 1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
REM 检查lib目录是否存在
|
|
|
|
|
if not exist "lib" (
|
|
|
|
|
echo 错误: 找不到依赖库目录 lib
|
|
|
|
|
echo 请确保lib目录存在且完整
|
|
|
|
|
pause
|
|
|
|
|
exit /b 1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
REM 运行程序
|
|
|
|
|
echo 正在启动程序...
|
|
|
|
|
java --module-path "lib" --add-modules javafx.controls,javafx.fxml -jar "math-learning-0.1.2.jar"
|
|
|
|
|
|
|
|
|
|
REM 如果程序退出,暂停窗口
|
|
|
|
|
echo.
|
|
|
|
|
echo 程序已退出。
|
|
|
|
|
pause
|
|
|
|
|
</echo>
|
|
|
|
|
|
|
|
|
|
<!-- 生成简化版启动脚本 -->
|
|
|
|
|
<echo file="${project.build.directory}/数学学习软件-${project.version}/start.bat">@echo off
|
|
|
|
|
chcp 65001 >nul
|
|
|
|
|
cd /d %~dp0
|
|
|
|
|
java --module-path "lib" --add-modules javafx.controls,javafx.fxml -jar "math-learning-0.1.2.jar"
|
|
|
|
|
</echo>
|
|
|
|
|
|
|
|
|
|
<!-- 生成测试脚本 -->
|
|
|
|
|
<echo file="${project.build.directory}/数学学习软件-${project.version}/测试运行.bat">@echo off
|
|
|
|
|
echo 正在测试程序是否能正常运行...
|
|
|
|
|
cd /d %~dp0
|
|
|
|
|
|
|
|
|
|
if exist "math-learning-0.1.2.jar" (
|
|
|
|
|
echo ✓ 找到主程序文件
|
|
|
|
|
) else (
|
|
|
|
|
echo ✗ 找不到主程序文件
|
|
|
|
|
pause
|
|
|
|
|
exit /b 1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if exist "lib" (
|
|
|
|
|
echo ✓ 找到依赖库目录
|
|
|
|
|
) else (
|
|
|
|
|
echo ✗ 找不到依赖库目录
|
|
|
|
|
pause
|
|
|
|
|
exit /b 1
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
echo 正在启动程序...
|
|
|
|
|
start start.bat
|
|
|
|
|
</echo>
|
|
|
|
|
|
|
|
|
|
<!-- 复制主程序 JAR -->
|
|
|
|
|
<copy todir="${project.build.directory}/数学学习软件-${project.version}">
|
|
|
|
|
<fileset dir="${project.build.directory}/dist">
|
|
|
|
|
<include name="math-learning-${project.version}.jar"/>
|
|
|
|
|
<include name="README.md"/>
|
|
|
|
|
<include name="smtp.env.example"/>
|
|
|
|
|
<include name="configure_smtp_qq.ps1"/>
|
|
|
|
|
</fileset>
|
|
|
|
|
</copy>
|
|
|
|
|
|
|
|
|
|
<!-- 复制依赖库 -->
|
|
|
|
|
<copy todir="${project.build.directory}/数学学习软件-${project.version}/lib">
|
|
|
|
|
<fileset dir="${project.build.directory}/dist/lib"/>
|
|
|
|
|
</copy>
|
|
|
|
|
|
|
|
|
|
<!-- 复制数据目录 -->
|
|
|
|
|
<copy todir="${project.build.directory}/数学学习软件-${project.version}/data">
|
|
|
|
|
<fileset dir="${project.build.directory}/dist/data"/>
|
|
|
|
|
</copy>
|
|
|
|
|
|
|
|
|
|
<!-- 生成详细使用说明 -->
|
|
|
|
|
<echo file="${project.build.directory}/数学学习软件-${project.version}/使用说明.txt">数学学习软件 v${project.version}
|
|
|
|
|
|
|
|
|
|
=== 基本信息 ===
|
|
|
|
|
版本号: ${project.version}
|
|
|
|
|
生成时间: ${maven.build.timestamp}
|
|
|
|
|
开发者: Coproject 团队
|
|
|
|
|
|
|
|
|
|
=== 系统要求 ===
|
|
|
|
|
- 操作系统: Windows 7/10/11
|
|
|
|
|
- Java版本: Java 17 或更高版本
|
|
|
|
|
- 内存: 至少 2GB 可用内存
|
|
|
|
|
|
|
|
|
|
=== 启动方法 ===
|
|
|
|
|
推荐使用以下方式启动:
|
|
|
|
|
1. 双击运行 run.bat (推荐,有错误提示)
|
|
|
|
|
2. 双击 start.bat (简洁版)
|
|
|
|
|
3. 双击 测试运行.bat (先检查环境再启动)
|
|
|
|
|
|
|
|
|
|
=== 功能特点 ===
|
|
|
|
|
✓ 小学数学题目生成
|
|
|
|
|
✓ 初中数学题目生成(含平方根号)
|
|
|
|
|
✓ 高中数学题目生成(含三角函数)
|
|
|
|
|
✓ 选择题答题系统
|
|
|
|
|
✓ 邮件发送验证码功能
|
|
|
|
|
✓ 试卷PDF导出功能
|
|
|
|
|
|
|
|
|
|
=== 目录说明 ===
|
|
|
|
|
math-learning-0.1.2.jar - 主程序文件
|
|
|
|
|
lib/ - 程序依赖库(请勿删除或移动)
|
|
|
|
|
data/ - 数据存储目录
|
|
|
|
|
├── smtp.env - 邮箱配置文件
|
|
|
|
|
└── papers/ - 试卷存储目录
|
|
|
|
|
run.bat - Windows启动脚本(详细版)
|
|
|
|
|
start.bat - Windows启动脚本(简洁版)
|
|
|
|
|
测试运行.bat - 环境测试脚本
|
|
|
|
|
README.md - 项目说明文档
|
|
|
|
|
|
|
|
|
|
=== 配置说明 ===
|
|
|
|
|
1. 首次运行会自动创建配置文件
|
|
|
|
|
2. 邮箱配置请参考 smtp.env.example
|
|
|
|
|
3. 生成的试卷保存在 data/papers/ 目录
|
|
|
|
|
|
|
|
|
|
=== 常见问题 ===
|
|
|
|
|
Q: 启动时提示"缺少JavaFX运行时组件"
|
|
|
|
|
A: 请确保使用 .bat 文件启动,不要直接双击JAR文件
|
|
|
|
|
|
|
|
|
|
Q: 邮件发送失败
|
|
|
|
|
A: 请检查 data/smtp.env 中的邮箱配置
|
|
|
|
|
|
|
|
|
|
Q: 程序无法启动
|
|
|
|
|
A: 请先运行"测试运行.bat"检查环境
|
|
|
|
|
|
|
|
|
|
=== 技术支持 ===
|
|
|
|
|
如有问题请联系开发团队。
|
|
|
|
|
|
|
|
|
|
注意:请保持所有文件在同一个目录下,不要单独移动文件!
|
|
|
|
|
</echo>
|
|
|
|
|
|
|
|
|
|
<!-- 创建ZIP压缩包 -->
|
|
|
|
|
<zip destfile="${project.build.directory}/数学学习软件-${project.version}.zip"
|
|
|
|
|
basedir="${project.build.directory}/数学学习软件-${project.version}"/>
|
|
|
|
|
|
|
|
|
|
<echo>=== 分发包生成完成 ===</echo>
|
|
|
|
|
<echo>分发包位置: ${project.build.directory}/数学学习软件-${project.version}.zip</echo>
|
|
|
|
|
<echo>目录位置: ${project.build.directory}/数学学习软件-${project.version}/</echo>
|
|
|
|
|
<echo> </echo>
|
|
|
|
|
<echo>用户运行说明:</echo>
|
|
|
|
|
<echo>- 解压ZIP文件到任意位置</echo>
|
|
|
|
|
<echo>- 进入"数学学习软件-0.1.2"文件夹</echo>
|
|
|
|
|
<echo>- 双击 run.bat 启动程序</echo>
|
|
|
|
|
</target>
|
|
|
|
|
</configuration>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>run</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
</plugins>
|
|
|
|
|
</build>
|
|
|
|
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
|
|
|
<modelVersion>4.0.0</modelVersion>
|
|
|
|
|
<groupId>com.coproject</groupId>
|
|
|
|
|
<artifactId>math-learning</artifactId>
|
|
|
|
|
<version>0.1.4</version>
|
|
|
|
|
<properties>
|
|
|
|
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
|
|
|
<maven.compiler.source>17</maven.compiler.source>
|
|
|
|
|
<maven.compiler.target>17</maven.compiler.target>
|
|
|
|
|
<javafx.version>21.0.3</javafx.version>
|
|
|
|
|
<!-- 允许通过 -DskipJlink=true 跳过 jlink,避免 javafx:run 时误触发 -->
|
|
|
|
|
<skipJlink>false</skipJlink>
|
|
|
|
|
</properties>
|
|
|
|
|
|
|
|
|
|
<dependencies>
|
|
|
|
|
<!-- JavaFX UI -->
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>org.openjfx</groupId>
|
|
|
|
|
<artifactId>javafx-controls</artifactId>
|
|
|
|
|
<version>${javafx.version}</version>
|
|
|
|
|
<classifier>win</classifier>
|
|
|
|
|
</dependency>
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>org.openjfx</groupId>
|
|
|
|
|
<artifactId>javafx-fxml</artifactId>
|
|
|
|
|
<version>${javafx.version}</version>
|
|
|
|
|
<classifier>win</classifier>
|
|
|
|
|
</dependency>
|
|
|
|
|
|
|
|
|
|
<!-- JSON storage -->
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>com.fasterxml.jackson.core</groupId>
|
|
|
|
|
<artifactId>jackson-databind</artifactId>
|
|
|
|
|
<version>2.17.1</version>
|
|
|
|
|
</dependency>
|
|
|
|
|
|
|
|
|
|
<!-- Mail sending (Jakarta Mail implementation) -->
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>com.sun.mail</groupId>
|
|
|
|
|
<artifactId>jakarta.mail</artifactId>
|
|
|
|
|
<version>2.0.1</version>
|
|
|
|
|
</dependency>
|
|
|
|
|
|
|
|
|
|
<!-- Commons Lang for utilities -->
|
|
|
|
|
<dependency>
|
|
|
|
|
<groupId>org.apache.commons</groupId>
|
|
|
|
|
<artifactId>commons-lang3</artifactId>
|
|
|
|
|
<version>3.14.0</version>
|
|
|
|
|
</dependency>
|
|
|
|
|
</dependencies>
|
|
|
|
|
|
|
|
|
|
<build>
|
|
|
|
|
<finalName>${project.artifactId}</finalName>
|
|
|
|
|
<plugins>
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-compiler-plugin</artifactId>
|
|
|
|
|
<version>3.11.0</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<source>${maven.compiler.source}</source>
|
|
|
|
|
<target>${maven.compiler.target}</target>
|
|
|
|
|
</configuration>
|
|
|
|
|
</plugin>
|
|
|
|
|
<!-- Enable `mvn javafx:run` for local development -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.openjfx</groupId>
|
|
|
|
|
<artifactId>javafx-maven-plugin</artifactId>
|
|
|
|
|
<version>0.0.8</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<mainClass>com.coproject.MainApp</mainClass>
|
|
|
|
|
</configuration>
|
|
|
|
|
</plugin>
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-jlink-plugin</artifactId>
|
|
|
|
|
<version>3.2.0</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<image>${project.build.directory}/jlink-image</image>
|
|
|
|
|
<jlinkExecutable>${env.JAVA_HOME}/bin/jlink</jlinkExecutable>
|
|
|
|
|
<modulePaths>
|
|
|
|
|
<modulePath>${env.JAVA_HOME}/jmods</modulePath>
|
|
|
|
|
<modulePath>${project.basedir}/lib/javafx-jmods-21.0.8/javafx-jmods-21.0.8</modulePath>
|
|
|
|
|
</modulePaths>
|
|
|
|
|
<!-- 仅包含 JDK 与 JavaFX 模块,第三方库不参与 jlink -->
|
|
|
|
|
<addModules>javafx.base,javafx.graphics,javafx.controls,javafx.fxml</addModules>
|
|
|
|
|
<noHeaderFiles>true</noHeaderFiles>
|
|
|
|
|
<noManPages>true</noManPages>
|
|
|
|
|
<stripDebug>true</stripDebug>
|
|
|
|
|
<skip>${skipJlink}</skip>
|
|
|
|
|
</configuration>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>make-jlink-image</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>jlink</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<!-- 在 execution 级别也应用 skip,确保 -DskipJlink=true 生效 -->
|
|
|
|
|
<skip>${skipJlink}</skip>
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-jar-plugin</artifactId>
|
|
|
|
|
<version>3.3.0</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist</outputDirectory>
|
|
|
|
|
<archive>
|
|
|
|
|
<!-- 使用我们在 antrun 中生成的 manifest 文件,显式包含 lib 下所有依赖 -->
|
|
|
|
|
<manifestFile>${project.build.directory}/dist/manifest.mf</manifestFile>
|
|
|
|
|
</archive>
|
|
|
|
|
</configuration>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>force-jar</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>jar</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
<!-- 备用方案:生成 jar-with-dependencies(胖包) -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-assembly-plugin</artifactId>
|
|
|
|
|
<version>3.6.0</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<archive>
|
|
|
|
|
<manifest>
|
|
|
|
|
<mainClass>com.coproject.MainApp</mainClass>
|
|
|
|
|
</manifest>
|
|
|
|
|
</archive>
|
|
|
|
|
<descriptorRefs>
|
|
|
|
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
|
|
|
|
</descriptorRefs>
|
|
|
|
|
<finalName>${project.artifactId}-${project.version}</finalName>
|
|
|
|
|
<appendAssemblyId>true</appendAssemblyId>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist</outputDirectory>
|
|
|
|
|
</configuration>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>make-assembly</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>single</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
<!-- 生成包含所有依赖的可运行 JAR,避免安装版缺失类路径导致启动失败 -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-shade-plugin</artifactId>
|
|
|
|
|
<version>3.5.0</version>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>shade</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<skip>true</skip>
|
|
|
|
|
<!-- 将产物写入 dist 并与 finalName 保持一致 -->
|
|
|
|
|
<outputFile>${project.build.directory}/dist/${project.build.finalName}.jar</outputFile>
|
|
|
|
|
<shadedArtifactAttached>false</shadedArtifactAttached>
|
|
|
|
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
|
|
|
|
<transformers>
|
|
|
|
|
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
|
|
|
|
<mainClass>com.coproject.MainApp</mainClass>
|
|
|
|
|
</transformer>
|
|
|
|
|
</transformers>
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-dependency-plugin</artifactId>
|
|
|
|
|
<version>3.6.1</version>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>copy-runtime-deps</id>
|
|
|
|
|
<phase>prepare-package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>copy-dependencies</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist/lib</outputDirectory>
|
|
|
|
|
<includeScope>runtime</includeScope>
|
|
|
|
|
<!-- 复制全部运行时依赖,包含 JavaFX win JAR 到 dist/lib -->
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
<!-- Prepare external config file: copy and rename smtp.env.example -> data/smtp.env into dist -->
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-antrun-plugin</artifactId>
|
|
|
|
|
<version>3.1.0</version>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>generate-manifest-with-classpath</id>
|
|
|
|
|
<phase>prepare-package</phase>
|
|
|
|
|
<configuration>
|
|
|
|
|
<target>
|
|
|
|
|
<!-- 确保 dist 与 dist/lib 目录存在 -->
|
|
|
|
|
<mkdir dir="${project.build.directory}/dist"/>
|
|
|
|
|
<mkdir dir="${project.build.directory}/dist/lib"/>
|
|
|
|
|
<property name="dist.lib" value="${project.build.directory}/dist/lib"/>
|
|
|
|
|
<path id="deps.jars">
|
|
|
|
|
<fileset dir="${dist.lib}" includes="*.jar"/>
|
|
|
|
|
</path>
|
|
|
|
|
<pathconvert refid="deps.jars" property="deps.cp" pathsep=" ">
|
|
|
|
|
<map from="${project.build.directory}/dist/lib/" to="lib/"/>
|
|
|
|
|
<map from="${project.build.directory}/dist/lib\" to="lib/"/>
|
|
|
|
|
</pathconvert>
|
|
|
|
|
<echo file="${project.build.directory}/dist/manifest.mf">
|
|
|
|
|
Manifest-Version: 1.0
|
|
|
|
|
Main-Class: com.coproject.MainApp
|
|
|
|
|
Class-Path: ${deps.cp}
|
|
|
|
|
</echo>
|
|
|
|
|
</target>
|
|
|
|
|
</configuration>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>run</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
</execution>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>prepare-smtp-env</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<configuration>
|
|
|
|
|
<target>
|
|
|
|
|
<mkdir dir="${project.build.directory}/dist/data"/>
|
|
|
|
|
<copy file="${project.basedir}/smtp.env.example" tofile="${project.build.directory}/dist/data/smtp.env" overwrite="true"/>
|
|
|
|
|
<mkdir dir="${project.build.directory}/dist/data/papers"/>
|
|
|
|
|
</target>
|
|
|
|
|
</configuration>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>run</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
</execution>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>cleanup-dist-jars</id>
|
|
|
|
|
<phase>post-package</phase>
|
|
|
|
|
<configuration>
|
|
|
|
|
<target>
|
|
|
|
|
<delete>
|
|
|
|
|
<fileset dir="${project.build.directory}/dist" includes="math-learning-*.jar" excludes="${project.build.finalName}.jar"/>
|
|
|
|
|
</delete>
|
|
|
|
|
</target>
|
|
|
|
|
</configuration>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>run</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.apache.maven.plugins</groupId>
|
|
|
|
|
<artifactId>maven-resources-plugin</artifactId>
|
|
|
|
|
<version>3.3.1</version>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>copy-javafx-win</id>
|
|
|
|
|
<phase>prepare-package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>copy-resources</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist/lib</outputDirectory>
|
|
|
|
|
<resources>
|
|
|
|
|
<resource>
|
|
|
|
|
<directory>${project.basedir}/lib/javafx-win</directory>
|
|
|
|
|
<includes>
|
|
|
|
|
<include>javafx-*-win.jar</include>
|
|
|
|
|
</includes>
|
|
|
|
|
</resource>
|
|
|
|
|
</resources>
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>copy-app-README</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>copy-resources</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist</outputDirectory>
|
|
|
|
|
<resources>
|
|
|
|
|
<resource>
|
|
|
|
|
<directory>${project.basedir}</directory>
|
|
|
|
|
<includes>
|
|
|
|
|
<include>README.md</include>
|
|
|
|
|
</includes>
|
|
|
|
|
</resource>
|
|
|
|
|
</resources>
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>copy-config-guides</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>copy-resources</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
<configuration>
|
|
|
|
|
<outputDirectory>${project.build.directory}/dist</outputDirectory>
|
|
|
|
|
<resources>
|
|
|
|
|
<resource>
|
|
|
|
|
<directory>${project.basedir}</directory>
|
|
|
|
|
<includes>
|
|
|
|
|
<include>configure_smtp_qq.ps1</include>
|
|
|
|
|
</includes>
|
|
|
|
|
</resource>
|
|
|
|
|
</resources>
|
|
|
|
|
</configuration>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
<plugin>
|
|
|
|
|
<groupId>org.panteleyev</groupId>
|
|
|
|
|
<artifactId>jpackage-maven-plugin</artifactId>
|
|
|
|
|
<version>1.7.1</version>
|
|
|
|
|
<configuration>
|
|
|
|
|
<input>${project.build.directory}/dist</input>
|
|
|
|
|
<resourceDir>${project.build.directory}/dist</resourceDir>
|
|
|
|
|
<destination>${project.build.directory}/jpackage</destination>
|
|
|
|
|
<type>msi</type>
|
|
|
|
|
<name>数学学习软件</name>
|
|
|
|
|
<vendor>Coproject</vendor>
|
|
|
|
|
<appVersion>0.1.4</appVersion>
|
|
|
|
|
<winConsole>true</winConsole>
|
|
|
|
|
<winDirChooser>true</winDirChooser>
|
|
|
|
|
<winMenu>true</winMenu>
|
|
|
|
|
<winShortcut>true</winShortcut>
|
|
|
|
|
<verbose>true</verbose>
|
|
|
|
|
<!-- 与 maven-jar-plugin 输出一致:固定为 artifactId.jar -->
|
|
|
|
|
<mainJar>${project.artifactId}.jar</mainJar>
|
|
|
|
|
<mainClass>com.coproject.MainApp</mainClass>
|
|
|
|
|
<!-- 让启动器包含 dist/lib 下所有依赖 -->
|
|
|
|
|
<classPath>lib/*</classPath>
|
|
|
|
|
<!-- JavaFX 模块所在路径 -->
|
|
|
|
|
<modulePath>app/lib</modulePath>
|
|
|
|
|
<!-- 类路径由主 JAR 的 MANIFEST.MF 提供(antrun 生成 Class-Path) -->
|
|
|
|
|
<removeDestination>true</removeDestination>
|
|
|
|
|
<!-- 显式添加 JavaFX 模块,避免运行期缺失导致退出码 1 -->
|
|
|
|
|
<javaOptions>
|
|
|
|
|
<javaOption>--module-path</javaOption>
|
|
|
|
|
<javaOption>app/lib</javaOption>
|
|
|
|
|
<javaOption>--add-modules</javaOption>
|
|
|
|
|
<javaOption>javafx.controls,javafx.fxml</javaOption>
|
|
|
|
|
</javaOptions>
|
|
|
|
|
<!-- 不强制使用 jlink 镜像,默认使用当前 JDK 的 jpackage -->
|
|
|
|
|
</configuration>
|
|
|
|
|
<executions>
|
|
|
|
|
<execution>
|
|
|
|
|
<id>make-installer</id>
|
|
|
|
|
<phase>package</phase>
|
|
|
|
|
<goals>
|
|
|
|
|
<goal>jpackage</goal>
|
|
|
|
|
</goals>
|
|
|
|
|
</execution>
|
|
|
|
|
</executions>
|
|
|
|
|
</plugin>
|
|
|
|
|
</plugins>
|
|
|
|
|
</build>
|
|
|
|
|
<profiles>
|
|
|
|
|
<!-- 使用 -P no-jlink 强制跳过 jlink(某些环境下 -DskipJlink=true 未被采纳) -->
|
|
|
|
|
<profile>
|
|
|
|
|
<id>no-jlink</id>
|
|
|
|
|
<activation>
|
|
|
|
|
<activeByDefault>false</activeByDefault>
|
|
|
|
|
</activation>
|
|
|
|
|
<properties>
|
|
|
|
|
<skipJlink>true</skipJlink>
|
|
|
|
|
</properties>
|
|
|
|
|
</profile>
|
|
|
|
|
</profiles>
|
|
|
|
|
</project>
|