{"id":19237512,"url":"https://github.com/core-lib/xjar-maven-plugin","last_synced_at":"2025-04-09T19:19:28.300Z","repository":{"id":43088146,"uuid":"160334163","full_name":"core-lib/xjar-maven-plugin","owner":"core-lib","description":"XJar-Maven-Plugin 是对 XJar 的一个Maven Plugin封装，实现可通过Maven命令或绑定在Maven构建的生命周期之中执行，用以更加便捷的方式集成 XJar 。","archived":false,"fork":false,"pushed_at":"2023-08-15T17:42:57.000Z","size":57,"stargazers_count":171,"open_issues_count":19,"forks_count":97,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T19:19:20.625Z","etag":null,"topics":["encryption","maven-plugin","mvn","spring-boot"],"latest_commit_sha":null,"homepage":"https://github.com/core-lib/xjar-maven-plugin","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/core-lib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-04T09:42:45.000Z","updated_at":"2025-03-17T06:39:19.000Z","dependencies_parsed_at":"2024-11-09T16:39:17.268Z","dependency_job_id":null,"html_url":"https://github.com/core-lib/xjar-maven-plugin","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-lib%2Fxjar-maven-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-lib%2Fxjar-maven-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-lib%2Fxjar-maven-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/core-lib%2Fxjar-maven-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/core-lib","download_url":"https://codeload.github.com/core-lib/xjar-maven-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094991,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encryption","maven-plugin","mvn","spring-boot"],"created_at":"2024-11-09T16:27:05.651Z","updated_at":"2025-04-09T19:19:28.269Z","avatar_url":"https://github.com/core-lib.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XJar-Maven-Plugin [![](https://jitpack.io/v/core-lib/xjar-maven-plugin.svg)](https://jitpack.io/#core-lib/xjar-maven-plugin)\n#### XJar-Maven-Plugin 是对 [XJar](https://github.com/core-lib/xjar) 的一个Maven Plugin封装，实现可通过Maven命令或绑定在Maven构建的生命周期之中执行，用以更加便捷的方式集成 [XJar](https://github.com/core-lib/xjar) 。\n\nGitHub: https://github.com/core-lib/xjar-maven-plugin\n\n## 什么是XJar\nXJar 是基于对JAR包内资源的加密以及拓展ClassLoader来构建的一套程序加密启动，动态解密运行的方案，避免源码泄露或反编译，支持Spring Boot JAR 安全加密运行，同时支持的原生JAR。\n更多文档请点击：[XJar](https://github.com/core-lib/xjar)\n\n## 环境依赖\nJDK 1.7 +\n\n## 集成步骤\n```xml\n\u003cproject\u003e\n    \u003c!-- 设置 jitpack.io 插件仓库 --\u003e\n    \u003cpluginRepositories\u003e\n        \u003cpluginRepository\u003e\n            \u003cid\u003ejitpack.io\u003c/id\u003e\n            \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n        \u003c/pluginRepository\u003e\n    \u003c/pluginRepositories\u003e\n    \u003c!-- 添加 XJar Maven 插件 --\u003e\n    \u003cbuild\u003e\n        \u003cplugins\u003e\n            \u003cplugin\u003e\n                \u003cgroupId\u003ecom.github.core-lib\u003c/groupId\u003e\n                \u003cartifactId\u003exjar-maven-plugin\u003c/artifactId\u003e\n                \u003cversion\u003e4.0.2\u003c/version\u003e\n                \u003cexecutions\u003e\n                    \u003cexecution\u003e\n                        \u003cgoals\u003e\n                            \u003cgoal\u003ebuild\u003c/goal\u003e\n                        \u003c/goals\u003e\n                        \u003cphase\u003epackage\u003c/phase\u003e\n                        \u003cconfiguration\u003e\n                            \u003cpassword\u003eio.xjar\u003c/password\u003e\n                            \u003c!-- optional\n                            \u003calgorithm/\u003e\n                            \u003ckeySize/\u003e\n                            \u003civSize/\u003e\n                            \u003cincludes\u003e\n                                \u003cinclude/\u003e\n                            \u003c/includes\u003e\n                            \u003cexcludes\u003e\n                                \u003cexclude/\u003e\n                            \u003c/excludes\u003e\n                            \u003csourceDir/\u003e\n                            \u003csourceJar/\u003e\n                            \u003ctargetDir/\u003e\n                            \u003ctargetJar/\u003e\n                            --\u003e\n                        \u003c/configuration\u003e\n                    \u003c/execution\u003e\n                \u003c/executions\u003e\n            \u003c/plugin\u003e\n        \u003c/plugins\u003e\n    \u003c/build\u003e\n\u003c/project\u003e\n\n```\n#### 也可以通过Maven命令单独执行 XJar 插件\n```text\nmvn xjar:build -Dxjar.password=io.xjar\nmvn xjar:build -Dxjar.password=io.xjar -Dxjar.targetDir=/directory/to/save/target.xjar\n```\n\n#### 但通常情况下是让XJar插件绑定到指定的phase中自动执行，这样就能在项目构建的时候自动构建出加密的包。\n```text\nmvn clean package -Dxjar.password=io.xjar\nmvn clean install -Dxjar.password=io.xjar -Dxjar.targetDir=/directory/to/save/target.xjar\n```\n\n## 强烈建议\n强烈建议不要在 pom.xml 的 xjar-maven-plugin 配置中写上密码，这样会导致打包出来的 xjar 包中的 pom.xml 文件保留着密码，极其容易暴露密码！强烈推荐通过 mvn 命令来指定加密密钥！\n\n## 注意事项\n#### 不兼容 spring-boot-maven-plugin 的 executable = true 以及 embeddedLaunchScript\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.springframework.boot\u003c/groupId\u003e\n    \u003cartifactId\u003espring-boot-maven-plugin\u003c/artifactId\u003e\n    \u003c!-- 需要将executable和embeddedLaunchScript参数删除，目前还不能支持对该模式Jar的加密！后面可能会支持该方式的打包。 \n    \u003cconfiguration\u003e\n        \u003cexecutable\u003etrue\u003c/executable\u003e\n        \u003cembeddedLaunchScript\u003e...\u003c/embeddedLaunchScript\u003e\n    \u003c/configuration\u003e\n    --\u003e\n\u003c/plugin\u003e\n```\n\n## 参数说明\n| 参数名称 | 命令参数名称 | 参数说明 | 参数类型 | 缺省值 | 示例值 |\n| :------ | :----------- | :------ | :------ | :----- | :----- |\n| password | -Dxjar.password | 密码字符串 | String | 必须 | 任意字符串，io.xjar |\n| algorithm | -Dxjar.algorithm | 加密算法名称 | String | AES/CBC/PKCS5Padding | JDK内置加密算法，如：AES/CBC/PKCS5Padding 和 DES/CBC/PKCS5Padding |\n| keySize | -Dxjar.keySize | 密钥长度 | int | 128 | 根据加密算法而定，56，128，256 |\n| ivSize | -Dxjar.ivSize | 密钥向量长度 | int | 128 | 根据加密算法而定，128 |\n| sourceDir | -Dxjar.sourceDir | 源jar所在目录 | File | ${project.build.directory} | 文件目录 |\n| sourceJar | -Dxjar.sourceJar | 源jar名称 | String | ${project.build.finalName}.jar | 文件名称 |\n| targetDir | -Dxjar.targetDir | 目标jar存放目录 | File | ${project.build.directory} | 文件目录 |\n| targetJar | -Dxjar.targetJar | 目标jar名称 | String | ${project.build.finalName}.xjar | 文件名称 |\n| includes | -Dxjar.includes | 需要加密的资源路径表达式 | String[] | 无 | com/company/project/** , mapper/*Mapper.xml , 支持Ant表达式 |\n| excludes | -Dxjar.excludes | 无需加密的资源路径表达式 | String[] | 无 | static/** , META-INF/resources/** , 支持Ant表达式 |\n| deletes | -Dxjar.deletes | 加密后删除指定资源路径表达式 | String[] | 无 | target/\\*.jar, ../module/target/\\*.jar, 支持Ant表达式 |\n\n* 指定加密算法的时候密钥长度以及向量长度必须在算法可支持范围内, 具体加密算法的密钥及向量长度请自行百度或谷歌.\n* 当 includes 和 excludes 同时使用时即加密在includes的范围内且排除了excludes的资源。\n\n## 版本记录\n* 4.0.2\n    1. 安全性升级\n* 4.0.1\n    1. 兼容JDK-9及以上版本\n* 4.0.0\n    1. 加解密支持填充模式\n    2. 加解密支持IV-Parameter\n    3. 升级启动器\n    4. 移除危险模式\n    5. 拼写错误修正\n    6. 提供智能加密/解密器 避免使用失误\n    7. 删除多余的加密/解密方法\n    8. 修复有安全校验的nested-lib在不加密其内部资源情况下启动时也无法通过校验的问题\n    9. 去除命令启动和手输密码启动的方式只保留Go启动器的模式\n    10. 增加可读性更强的Fluent风格的加密/解密API\n* 2.0.9\n    * 修复XJar类加载器加载的类没有 ProtectionDomain 以及 CodeSource 的问题\n    * 修复不同字符集机器间加密与运行的问题\n* 2.0.8\n    * 版本号去除\"v\"前缀\n* v2.0.7\n    * 支持加密后删除指定资源\n* v2.0.6\n    * 解决多jar包启动时无法找到准确的MANIFEST.MF导致无法正常启动的问题\n* v2.0.5\n    * 升级[LoadKit](https://github.com/core-lib/loadkit)依赖版本\n    * 修复ANT表达式无法正确匹配**/*通配符的问题\n* v2.0.4\n    * 解决危险模式不支持ubuntu系统的问题\n* v2.0.3\n    * 过滤器泛型协变支持\n    * 支持 includes 与 excludes 同时起效，当同时设置时即加密在includes范围内但又不在excludes范围内的资源\n* v2.0.2\n    * 原生jar增加密钥文件的启动方式，解决类似 nohup 和 javaw 的后台启动方式无法通过控制台输入密码的问题\n* v2.0.1\n    * 增加密钥文件的启动方式，解决类似 nohup 和 javaw 的后台启动方式无法通过控制台输入密码的问题\n    * 修复解密后没有删除危险模式中在MANIFEST.MF中保留的密钥信息\n* v2.0.0\n    * 升级为v2.0.0 与 xjar版本保持一致\n* v1.1.0\n    * 支持 Spring-Boot 以ZIP方式打包，即依赖外部化方式启动。\n    * 修复无加密资源时无法启动问题\n* v1.0.9\n    * 支持危险模式加密，实现免密码启动，但是请谨慎使用！\n* v1.0.8\n    * 避免过滤器使用不当造成无法启动\n* v1.0.7\n    * bug修复\n* v1.0.6\n    * 将对普通jar项目或模块和spring boot项目或模块的插件方式加密整合成一个智能分析goal，配置时无需关心当前项目或模块是哪一种。\n    * 对于无法加密的Jar进行友好提示\n    * 升级 XJar 版本为 v1.1.0\n* v1.0.5\n    * 引用新版本的XJar(v1.0.9)，修复不同版本的Spring-Boot加密无法运行问题\n* v1.0.4\n    * 第一个正式版发布\n\n## 协议声明\n[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\n## 加入群聊\nQQ 950956093 [![](https://pub.idqqimg.com/wpa/images/group.png)](https://shang.qq.com/wpa/qunwpa?idkey=e567db1c32de4b02da480d895566757b3df73e3f8827ed6c9149e2859e4cdc93)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcore-lib%2Fxjar-maven-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcore-lib%2Fxjar-maven-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcore-lib%2Fxjar-maven-plugin/lists"}