fix: 修复打包配置

This commit is contained in:
octopus_yan 2024-11-15 22:33:17 +08:00
parent 9edc015af0
commit 1dc6e95340
5 changed files with 59 additions and 15 deletions

View File

@ -53,7 +53,7 @@
```
2. 运行
```bash
mvn clean javafx:run
mvn clean javafx:run -Pdev
```
#### 打包
@ -64,7 +64,7 @@
```
2. 运行
```bash
mvn clean package
mvn clean package -Pbuild
```
### 可能会用到

45
pom.xml
View File

@ -6,7 +6,7 @@
<groupId>cn.octopusyan</groupId>
<artifactId>dmt</artifactId>
<version>0.0.2</version>
<version>0.1.2</version>
<name>dmt</name>
<organization>
@ -172,14 +172,41 @@
</pluginRepository>
</pluginRepositories>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<profiles>
<profile>
<id>dev</id>
<properties>
<debug.option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</debug.option>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</profile>
<profile>
<id>build</id>
<properties>
<debug.option/>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>bin/</exclude>
</excludes>
</resource>
</resources>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -233,7 +260,7 @@
<configuration>
<options>
<option>--enable-preview</option>
<!-- <option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005</option>-->
<option>${debug.option}</option>
</options>
</configuration>
</execution>

View File

@ -16,6 +16,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@ -39,11 +41,15 @@ public class Context {
@Getter
private static final Map<String, BaseController<?>> controllers = new HashMap<>();
private Context() {
throw new IllegalStateException("Utility class");
}
public static boolean isDebugMode() {
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
return runtimeMXBean.getInputArguments().toString().contains("-agentlib:jdwp");
}
// 获取控制工厂
public static Callback<Class<?>, Object> getControlFactory() {
return type -> {

View File

@ -1,12 +1,15 @@
package cn.octopusyan.dmt.utils;
import cn.octopusyan.dmt.common.config.Constants;
import cn.octopusyan.dmt.common.config.Context;
import cn.octopusyan.dmt.common.util.ProcessesUtil;
import cn.octopusyan.dmt.model.WordItem;
import cn.octopusyan.dmt.view.ConsoleLog;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.LineIterator;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@ -24,6 +27,7 @@ import java.util.stream.Collectors;
* @author octopus_yan
*/
public class PBOUtil {
private static final Logger log = LoggerFactory.getLogger(PBOUtil.class);
public static final ConsoleLog consoleLog = ConsoleLog.getInstance(PBOUtil.class);
private static final ProcessesUtil processesUtil = ProcessesUtil.init(Constants.BIN_DIR_PATH);
@ -42,14 +46,20 @@ public class PBOUtil {
public static void init() {
String srcFilePath = Objects.requireNonNull(PBOUtil.class.getResource("/bin")).getPath();
try {
File destDir = new File(Constants.BIN_DIR_PATH);
if (destDir.exists()) return;
if (!Context.isDebugMode())
throw new RuntimeException("Util 初始化失败");
String srcFilePath = Resources.getResource("bin").getPath();
FileUtils.forceMkdir(destDir);
FileUtils.copyDirectory(new File(srcFilePath), destDir);
} catch (IOException e) {
consoleLog.error("Util 初始化失败", e);
log.error("Util 初始化失败", e);
}
}

View File

@ -17,6 +17,7 @@ module cn.octopusyan.dmt {
requires java.prefs;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.feather;
requires java.management;
exports cn.octopusyan.dmt;
exports cn.octopusyan.dmt.model to com.fasterxml.jackson.databind;