Remove pom.xml and RedisClipSync.java files; update README.md to reflect new project structure and build instructions.
This commit is contained in:
6
.cursor/rules/Chinese.mdc
Normal file
6
.cursor/rules/Chinese.mdc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
alwaysApply: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Please execute the generate commit message command in Chinese.
|
||||||
|
生成 Git 提交信息(Commit Message)时,必须强制使用中文。
|
||||||
68
README.md
68
README.md
@@ -2,23 +2,62 @@
|
|||||||
|
|
||||||
基于 Redis 的双向剪切板同步:主机将本地剪切板广播到从机,从机将本地剪切板上传到主机并按从机 ID 追加写入 TXT 文件。
|
基于 Redis 的双向剪切板同步:主机将本地剪切板广播到从机,从机将本地剪切板上传到主机并按从机 ID 追加写入 TXT 文件。
|
||||||
|
|
||||||
## 构建
|
## 目录结构
|
||||||
|
|
||||||
```bash
|
```
|
||||||
mvn clean package
|
RedisClipSync/
|
||||||
|
code/ # 代码与构建
|
||||||
|
pom.xml
|
||||||
|
src/main/java/
|
||||||
|
target/ # 打包输出 redis-clip-sync.jar
|
||||||
|
windows/ # Windows 脚本
|
||||||
|
build-and-run.bat # 一键打包并运行
|
||||||
|
run.bat # 仅运行(需已打包)
|
||||||
|
linux/ # Linux 脚本
|
||||||
|
build-and-run.sh # 一键打包并运行
|
||||||
|
run.sh # 仅运行(需已打包)
|
||||||
|
config.master.properties.example
|
||||||
|
config.slave.properties.example
|
||||||
|
config.properties # 运行前从 example 复制并修改
|
||||||
|
README.md
|
||||||
|
剪切板同步.md
|
||||||
```
|
```
|
||||||
|
|
||||||
在 `target/` 下生成 `redis-clip-sync.jar`(已包含 Jedis 依赖,可直接运行)。
|
## 构建与运行
|
||||||
|
|
||||||
## 运行
|
### 一键脚本(推荐)
|
||||||
|
|
||||||
确保工作目录包含 `config.properties`,或通过参数/系统属性指定配置路径:
|
脚本会从各自目录自动切换到项目根目录再执行,配置与 `clipboard_logs/` 均在根目录。
|
||||||
|
|
||||||
|
**Windows**(在项目根目录或 `windows/` 下执行均可)
|
||||||
|
- **windows/build-and-run.bat**:先打包再启动。
|
||||||
|
双击运行,或:`windows\build-and-run.bat [配置文件路径]`(默认 `config.properties`)。
|
||||||
|
- **windows/run.bat**:不重新打包,直接运行。
|
||||||
|
用法:`windows\run.bat [配置文件路径]`。
|
||||||
|
|
||||||
|
**Linux**(需先赋予执行权限:`chmod +x linux/*.sh`)
|
||||||
|
- **linux/build-and-run.sh**:先打包再启动。
|
||||||
|
`./linux/build-and-run.sh [配置文件路径]`(默认 `config.properties`)。
|
||||||
|
- **linux/run.sh**:不重新打包,直接运行。
|
||||||
|
用法:`./linux/run.sh [配置文件路径]`。
|
||||||
|
|
||||||
|
运行前请将 `config.master.properties.example` 或 `config.slave.properties.example` 复制为 `config.properties` 并修改。
|
||||||
|
|
||||||
|
### 手动构建与运行
|
||||||
|
|
||||||
|
在项目根目录执行:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
java -jar target/redis-clip-sync.jar
|
mvn -f code/pom.xml clean package
|
||||||
# 或指定配置
|
```
|
||||||
java -jar target/redis-clip-sync.jar /path/to/config.properties
|
|
||||||
java -Dconfig=/path/to/config.properties -jar target/redis-clip-sync.jar
|
在 `code/target/` 下生成 `redis-clip-sync.jar`(已包含 Jedis 依赖)。
|
||||||
|
|
||||||
|
确保工作目录为项目根目录并包含 `config.properties`,或通过参数指定配置路径:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
java -jar code/target/redis-clip-sync.jar
|
||||||
|
java -jar code/target/redis-clip-sync.jar /path/to/config.properties
|
||||||
```
|
```
|
||||||
|
|
||||||
## 配置
|
## 配置
|
||||||
@@ -50,15 +89,14 @@ slave.id=192.168.1.50
|
|||||||
|
|
||||||
`slave.id` 决定主机端生成的文件名(如 `192.168.1.50.txt`)。
|
`slave.id` 决定主机端生成的文件名(如 `192.168.1.50.txt`)。
|
||||||
|
|
||||||
## 目录结构
|
## 运行目录说明
|
||||||
|
|
||||||
主机启动后会自动创建保存目录:
|
主机启动后会在配置的 `master.save.dir`(默认 `./clipboard_logs/`)下自动创建保存目录。建议在项目根目录运行脚本,这样 `config.properties` 与 `clipboard_logs/` 均在根目录下:
|
||||||
|
|
||||||
```
|
```
|
||||||
/
|
RedisClipSync/
|
||||||
- redis-clip-sync.jar
|
|
||||||
- config.properties
|
- config.properties
|
||||||
- clipboard_logs/ # 自动创建
|
- clipboard_logs/ # 自动创建(Master)
|
||||||
- 192.168.1.50.txt # 从机 A 的记录
|
- 192.168.1.50.txt # 从机 A 的记录
|
||||||
- 192.168.1.51.txt # 从机 B 的记录
|
- 192.168.1.51.txt # 从机 B 的记录
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -43,18 +43,27 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>3.6.0</version>
|
<version>3.6.0</version>
|
||||||
<configuration>
|
<executions>
|
||||||
<archive>
|
<execution>
|
||||||
<manifest>
|
<id>make-assembly</id>
|
||||||
<mainClass>RedisClipSync</mainClass>
|
<phase>package</phase>
|
||||||
</manifest>
|
<goals>
|
||||||
</archive>
|
<goal>single</goal>
|
||||||
<descriptorRefs>
|
</goals>
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
<configuration>
|
||||||
</descriptorRefs>
|
<archive>
|
||||||
<finalName>redis-clip-sync</finalName>
|
<manifest>
|
||||||
<appendAssemblyId>false</appendAssemblyId>
|
<mainClass>RedisClipSync</mainClass>
|
||||||
</configuration>
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
<finalName>redis-clip-sync</finalName>
|
||||||
|
<appendAssemblyId>false</appendAssemblyId>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
25
linux/build-and-run.sh
Normal file
25
linux/build-and-run.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
|
echo "========================================"
|
||||||
|
echo " Redis 剪切板同步 - 一键打包并运行"
|
||||||
|
echo "========================================"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "[1/2] 正在打包..."
|
||||||
|
if ! mvn -f code/pom.xml -q clean package -DskipTests; then
|
||||||
|
echo "打包失败,请确保已安装 Maven 且可执行 mvn。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "打包完成: code/target/redis-clip-sync.jar"
|
||||||
|
echo
|
||||||
|
|
||||||
|
CONFIG="${1:-config.properties}"
|
||||||
|
echo "[2/2] 正在启动(配置文件: $CONFIG)..."
|
||||||
|
echo "提示: 按 Ctrl+C 可退出程序"
|
||||||
|
echo
|
||||||
|
exec java -jar code/target/redis-clip-sync.jar "$CONFIG"
|
||||||
16
linux/run.sh
Normal file
16
linux/run.sh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||||
|
cd "$PROJECT_ROOT"
|
||||||
|
|
||||||
|
CONFIG="${1:-config.properties}"
|
||||||
|
|
||||||
|
if [[ ! -f code/target/redis-clip-sync.jar ]]; then
|
||||||
|
echo "未找到 code/target/redis-clip-sync.jar,请先运行 linux/build-and-run.sh 进行打包。"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "启动 Redis 剪切板同步(配置: $CONFIG)..."
|
||||||
|
exec java -jar code/target/redis-clip-sync.jar "$CONFIG"
|
||||||
33
windows/build-and-run.bat
Normal file
33
windows/build-and-run.bat
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
:: 切换到项目根目录(脚本在 windows\ 下)
|
||||||
|
cd /d "%~dp0.."
|
||||||
|
|
||||||
|
echo ========================================
|
||||||
|
echo Redis 剪切板同步 - 一键打包并运行
|
||||||
|
echo ========================================
|
||||||
|
echo.
|
||||||
|
|
||||||
|
:: 1. 打包
|
||||||
|
echo [1/2] 正在打包...
|
||||||
|
call mvn -f code\pom.xml -q clean package -DskipTests
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo 打包失败,请确保已安装 Maven 且可执行 mvn。
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
echo 打包完成: code\target\redis-clip-sync.jar
|
||||||
|
echo.
|
||||||
|
|
||||||
|
:: 2. 运行(配置文件可选,默认 config.properties)
|
||||||
|
set CONFIG=config.properties
|
||||||
|
if not "%~1"=="" set CONFIG=%~1
|
||||||
|
|
||||||
|
echo [2/2] 正在启动(配置文件: %CONFIG%)...
|
||||||
|
echo 提示: 按 Ctrl+C 可退出程序
|
||||||
|
echo.
|
||||||
|
java -jar code\target\redis-clip-sync.jar %CONFIG%
|
||||||
|
|
||||||
|
pause
|
||||||
18
windows/run.bat
Normal file
18
windows/run.bat
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001 >nul
|
||||||
|
|
||||||
|
:: 切换到项目根目录(脚本在 windows\ 下)
|
||||||
|
cd /d "%~dp0.."
|
||||||
|
|
||||||
|
set CONFIG=config.properties
|
||||||
|
if not "%~1"=="" set CONFIG=%~1
|
||||||
|
|
||||||
|
if not exist "code\target\redis-clip-sync.jar" (
|
||||||
|
echo 未找到 code\target\redis-clip-sync.jar,请先运行 windows\build-and-run.bat 进行打包。
|
||||||
|
pause
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo 启动 Redis 剪切板同步(配置: %CONFIG%)...
|
||||||
|
java -jar code\target\redis-clip-sync.jar %CONFIG%
|
||||||
|
pause
|
||||||
Reference in New Issue
Block a user