|
|
<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> |