build: 优化打包流程

This commit is contained in:
wushuo
2025-12-12 23:04:03 +08:00
parent b2a2ab28a5
commit d51efcb1e7
12 changed files with 271 additions and 72 deletions

View File

@@ -18,10 +18,32 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>ani.rss</groupId> <groupId>ani.rss</groupId>
<artifactId>ani-rss-commons</artifactId> <artifactId>ani-rss-commons</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@@ -0,0 +1,27 @@
#!/bin/bash
if [ -d ../ani-rss-ui/dist ]; then
if [ -d ./src/main/resources/dist ]; then
rm -rf ./src/main/resources/dist
fi
mv ../ani-rss-ui/dist ./src/main/resources/dist
echo "move dist ..."
fi
# build_info 位置
build_info_path=./src/main/resources/build_info
rm -rf ${build_info_path}
git rev-parse --short HEAD >> ${build_info_path}
git branch --show-current >> ${build_info_path}
# 更新程序位置
update_exe_path=./src/main/resources/ani-rss-update.exe
if [ ! -e ${update_exe_path} ]; then
echo "下载 ani-rss-update.exe"
wget https://github.com/wushuo894/ani-rss-update/releases/download/latest/ani-rss-update.exe
mv ani-rss-update.exe ${update_exe_path}
else
echo -e "${YELLOW}已存在 ani-rss-update.exe${NC}"
fi

View File

@@ -18,6 +18,10 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>ani.rss</groupId>
<artifactId>ani-rss-ui</artifactId>
</dependency>
<dependency> <dependency>
<groupId>ani.rss</groupId> <groupId>ani.rss</groupId>
<artifactId>ani-rss-web</artifactId> <artifactId>ani-rss-web</artifactId>
@@ -30,6 +34,7 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -39,7 +44,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration> <configuration>
<descriptorRefs> <descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <descriptorRef>jar-with-dependencies</descriptorRef>
@@ -64,7 +68,6 @@
<plugin> <plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId> <groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId> <artifactId>launch4j-maven-plugin</artifactId>
<version>2.6.0</version>
<executions> <executions>
<execution> <execution>
<id>l4j</id> <id>l4j</id>
@@ -109,8 +112,53 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>bash</executable>
<arguments>
<argument>./generate-resources.sh</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>generate-md5sum</id>
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>ani.rss.build.Md5Sum</mainClass>
<systemProperties>
<systemProperty>
<key>basedir</key>
<value>${project.basedir}</value>
</systemProperty>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@@ -89,6 +89,7 @@ public class FileAction implements BaseAction {
BufferedInputStream inputStream = FileUtil.getInputStream(imgFile); BufferedInputStream inputStream = FileUtil.getInputStream(imgFile);
@Cleanup @Cleanup
OutputStream out = response.getOut(); OutputStream out = response.getOut();
response.setContentLength((int) file.length());
IoUtil.copy(inputStream, out); IoUtil.copy(inputStream, out);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
@@ -102,6 +103,7 @@ public class FileAction implements BaseAction {
BufferedInputStream inputStream = FileUtil.getInputStream(imgFile); BufferedInputStream inputStream = FileUtil.getInputStream(imgFile);
@Cleanup @Cleanup
OutputStream out = response.getOut(); OutputStream out = response.getOut();
response.setContentLength((int) file.length());
IoUtil.copy(inputStream, out); IoUtil.copy(inputStream, out);
} catch (Exception ignored) { } catch (Exception ignored) {
} }
@@ -183,11 +185,9 @@ public class FileAction implements BaseAction {
InputStream inputStream = Channels.newInputStream(channel); InputStream inputStream = Channels.newInputStream(channel);
IoUtil.copy(inputStream, out, 40960, end - start, null); IoUtil.copy(inputStream, out, 40960, end - start, null);
} else { } else {
@Cleanup
OutputStream out = response.getOut();
@Cleanup @Cleanup
InputStream inputStream = FileUtil.getInputStream(file); InputStream inputStream = FileUtil.getInputStream(file);
IoUtil.copy(inputStream, out, 40960); response.write(inputStream, (int) file.length());
} }
} catch (Exception e) { } catch (Exception e) {
String message = ExceptionUtil.getMessage(e); String message = ExceptionUtil.getMessage(e);

View File

@@ -0,0 +1,51 @@
package ani.rss.build;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.Objects;
@Slf4j
public class Md5Sum implements Runnable {
@Override
public void run() {
String basedir = System.getProperty("basedir");
File target = new File(basedir + "/target");
Assert.isTrue(target.exists(), "target not exists");
File[] files = target.listFiles();
Assert.notEmpty(files, "files not found");
Objects.requireNonNull(files, "files not found");
for (File file : files) {
if (file.isDirectory()) {
continue;
}
String extName = FileUtil.extName(file);
if (StrUtil.isBlank(extName)) {
continue;
}
if ("md5".equals(extName)) {
continue;
}
generate(file);
}
}
private void generate(File file) {
File md5File = new File(file + ".md5");
if (md5File.exists()) {
return;
}
String md5 = SecureUtil.md5(file);
FileUtil.writeUtf8String(md5, md5File);
log.info("md5 {} {}", file, md5);
}
}

View File

@@ -21,6 +21,7 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
@@ -36,4 +37,21 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@@ -25,12 +25,10 @@
<dependency> <dependency>
<groupId>org.eclipse</groupId> <groupId>org.eclipse</groupId>
<artifactId>bittorrent</artifactId> <artifactId>bittorrent</artifactId>
<version>0.3.0-v20070627-1030</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.xerial</groupId> <groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId> <artifactId>sqlite-jdbc</artifactId>
<version>3.50.3.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.mail</groupId> <groupId>com.sun.mail</groupId>
@@ -48,6 +46,28 @@
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@@ -21,8 +21,8 @@
"vue": "^3.5.25" "vue": "^3.5.25"
}, },
"devDependencies": { "devDependencies": {
"@vitejs/plugin-vue": "^6.0.2", "@vitejs/plugin-vue": "^6.0.3",
"shiki": "^3.19.0", "shiki": "^3.20.0",
"terser": "^5.44.1", "terser": "^5.44.1",
"unplugin-auto-import": "^20.3.0", "unplugin-auto-import": "^20.3.0",
"unplugin-vue-components": "^30.0.0", "unplugin-vue-components": "^30.0.0",

View File

@@ -78,6 +78,18 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@@ -25,7 +25,25 @@
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@@ -1,61 +1,10 @@
#!/bin/bash #!/bin/bash
# 起始位置
base_path=$(pwd)
# ui 位置
ui_path=${base_path}/ani-rss-ui
# ani-rss-application 路径
application_path=${base_path}/ani-rss-application
# dist 位置
dist_path=${application_path}/src/main/resources/dist
# 更新程序位置
update_exe_path=${application_path}/src/main/resources/ani-rss-update.exe
# build_info 位置
build_info_path=${application_path}/src/main/resources/build_info
# target 位置
target_path=${application_path}/target
rm -rf ${build_info_path}
git rev-parse --short HEAD >> ${build_info_path}
git branch --show-current >> ${build_info_path}
# 定义颜色代码 # 定义颜色代码
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[0;32m' GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' NC='\033[0m'
cd ${ui_path}
mvn -B install -DskipTests --file pom.xml
if [ $? -eq 1 ]; then
echo -e "${RED}web编译失败${NC}"
exit 1
fi
echo -e "${GREEN}web编译完成${NC}"
if [ -d ${dist_path} ]; then
echo -e "${YELLOW}清理 ${dist_path}${NC}"
rm -rf ${dist_path}/*
else
echo -e "${YELLOW}创建文件夹 ${dist_path}${NC}"
mkdir -p ${dist_path}
fi
cp -r dist/* ${dist_path}
if [ ! -e ${update_exe_path} ]; then
echo "下载 ani-rss-update.exe"
wget https://github.com/wushuo894/ani-rss-update/releases/download/latest/ani-rss-update.exe
mv ani-rss-update.exe ${update_exe_path}
else
echo -e "${YELLOW}已存在 ani-rss-update.exe${NC}"
fi
cd ..
mvn -B package -DskipTests --file pom.xml mvn -B package -DskipTests --file pom.xml
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
@@ -64,12 +13,3 @@ if [ $? -eq 1 ]; then
fi fi
echo -e "${GREEN}jar编译完成${NC}" echo -e "${GREEN}jar编译完成${NC}"
md5sum ${target_path}/ani-rss-jar-with-dependencies.jar | awk '{print $1}' > ${target_path}/ani-rss-jar-with-dependencies.jar.md5
md5sum ${target_path}/ani-rss-launcher.exe | awk '{print $1}' > ${target_path}/ani-rss-launcher.exe.md5
echo "md5"
echo "ani-rss-jar-with-dependencies.jar $(cat ${target_path}/ani-rss-jar-with-dependencies.jar.md5)"
echo "ani-rss-launcher.exe $(cat ${target_path}/ani-rss-launcher.exe.md5)"

45
pom.xml
View File

@@ -13,11 +13,11 @@
</organization> </organization>
<modules> <modules>
<module>ani-rss-commons</module> <module>ani-rss-commons</module>
<module>ani-rss-ui</module>
<module>ani-rss-application</module> <module>ani-rss-application</module>
<module>ani-rss-web</module> <module>ani-rss-web</module>
<module>ani-rss-core</module> <module>ani-rss-core</module>
<module>ani-rss-api</module> <module>ani-rss-api</module>
<module>ani-rss-ui</module>
</modules> </modules>
<inceptionYear>2025</inceptionYear> <inceptionYear>2025</inceptionYear>
<description>基于RSS自动追番、订阅、下载、刮削</description> <description>基于RSS自动追番、订阅、下载、刮削</description>
@@ -35,6 +35,11 @@
<artifactId>ani-rss-commons</artifactId> <artifactId>ani-rss-commons</artifactId>
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
</dependency> </dependency>
<dependency>
<groupId>ani.rss</groupId>
<artifactId>ani-rss-ui</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency> <dependency>
<groupId>ani.rss</groupId> <groupId>ani.rss</groupId>
<artifactId>ani-rss-api</artifactId> <artifactId>ani-rss-api</artifactId>
@@ -54,6 +59,7 @@
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.42</version> <version>1.18.42</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
@@ -85,6 +91,16 @@
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.21.2</version> <version>1.21.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>bittorrent</artifactId>
<version>0.3.0-v20070627-1030</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.50.3.0</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@@ -94,4 +110,31 @@
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>2.6.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.6.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project> </project>