Initial commit
This commit is contained in:
1
.coveralls.yml
Normal file
1
.coveralls.yml
Normal file
@@ -0,0 +1 @@
|
||||
service_name: travis-ci
|
||||
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# maven ignore
|
||||
target/
|
||||
*.jar
|
||||
*.war
|
||||
*.zip
|
||||
*.tar
|
||||
*.tar.gz
|
||||
|
||||
# eclipse ignore
|
||||
.settings/
|
||||
.project
|
||||
.classpath
|
||||
|
||||
# idea ignore
|
||||
.idea/
|
||||
*.ipr
|
||||
*.iml
|
||||
*.iws
|
||||
|
||||
# temp ignore
|
||||
*.log
|
||||
*.cache
|
||||
*.diff
|
||||
*.patch
|
||||
*.tmp
|
||||
*.java~
|
||||
*.properties~
|
||||
*.xml~
|
||||
|
||||
# system ignore
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
7
.travis.yml
Normal file
7
.travis.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
language: java
|
||||
jdk:
|
||||
- openjdk8
|
||||
install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true
|
||||
script: mvn test
|
||||
after_success:
|
||||
- mvn clean cobertura:cobertura coveralls:report
|
||||
16
CHANGELOG.md
Normal file
16
CHANGELOG.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# 变更日志
|
||||
|
||||
| 类型 | 说明 |
|
||||
|:----|:----|
|
||||
| A | 新增 |
|
||||
| U | 更新 |
|
||||
| D | 删除 |
|
||||
| T | 测试 |
|
||||
| O | 优化 |
|
||||
| F | 修复BUG |
|
||||
|
||||
# release_0.0.1
|
||||
|
||||
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||
|:---|:---|:---|:---|:--|
|
||||
| 1 | A | 基本 api 定义 | 2020-9-2 14:45:40 | |
|
||||
334
LICENSE.txt
Normal file
334
LICENSE.txt
Normal file
@@ -0,0 +1,334 @@
|
||||
#set( $symbol_pound = '#' )
|
||||
#set( $symbol_dollar = '$' )
|
||||
#set( $symbol_escape = '\' )
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2016 ShenHuaJie iBase4J@163.com
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
======================================================================
|
||||
|
||||
Apache许可证
|
||||
版本 2.0,2004年1月
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
使用、重生成及分发的术语和条件:
|
||||
|
||||
1.定义
|
||||
|
||||
"许可证"是指根据本文档第1到第9部分关于使用、重生成和分发的术语和条件。
|
||||
|
||||
"许可证颁发者"是指版权所有者或者由版权所有者批准的授权许可证的实体。
|
||||
|
||||
"法律实体"是指实施实体和进行控制的所有其它实体受该实体控制,或者受该实体集中控制。
|
||||
根据此定义,"控制"是指(i)让无论是否签订协议的上述实体,进行指导或管理的直接权利或间接权利,
|
||||
或者(ii)拥有百分之五十(50%)或以上已发行股票的所有者,或者(iii)上述实体的实权所有者。
|
||||
|
||||
"用户"(或"用户的")是指行使本许可证所授予权限的个人或法律实体。
|
||||
|
||||
"源程序"形式是指对包含但不限制软件源代码、文档源程序和配置文件进行修改的首选形式。
|
||||
|
||||
"目标"形式是指对源程序形式进行机械转换或翻译的任何形式,包括但不限于对编译的目标代码,
|
||||
生成的文件以及转换为其它媒体类型。
|
||||
|
||||
"作品"是指根据本许可证所制作的源程序形式或目标形式的著作,在著作中包含的或附加的版权通知
|
||||
(在下面附录中提供了一个示例)。
|
||||
|
||||
"衍生作品"是指基于作品(或从作品衍生而来)的源程序形式或目标形式的任何作品,以及编辑修订、
|
||||
注释、详细描述或其它修订等构成原创著作作品的整体。根据本许可证,衍生作品不得包括与作品及其
|
||||
衍生作品分离之作品,或仅与作品及其衍生作品的接口相链接(或按名称结合)之作品。
|
||||
|
||||
"贡献"是指任何著作作品,包括作品的原始版本和对该作品或衍生作品所做的任何修订或补充,
|
||||
意在提交给许可证颁发者以让版权所有者或代表版权所有者的授权个人或法律实体包含在其作品中。
|
||||
根据此定义,"提交"一词表示发送给许可证颁发者或其代表人,任何电子的、口头的或书面的交流信息形式,
|
||||
包括但不限于在由许可证颁发者或者代表其管理的电子邮件清单、源代码控制系统、以及发布跟踪系统上为
|
||||
讨论和提高作品的交流,但不包括由版权所有者以书面形式明显标注或指定为"非贡献"的交流活动。
|
||||
|
||||
"贡献者"是指许可证颁发者和代表从许可证颁发者接受之贡献的并随后包含在作品之贡献中的任何个人或法律实体。
|
||||
|
||||
2.版权许可证的授予
|
||||
|
||||
根据本许可证的条款,每个贡献者授予用户永久性的、全球性的、非专有性的、免费的、无版权费的、
|
||||
不可撤销的版权许可证以源程序形式或目标形式复制、准备衍生作品、公开显示、公开执行、
|
||||
授予分许可证、以及分发作品和这样的衍生作品。
|
||||
|
||||
3.专利许可证的授予
|
||||
|
||||
根据本许可证的条款,每个贡献者授予用户永久性的、全球性的、非专有性的、免费的、无版权费的、
|
||||
不可撤销的(除在本部分进行说明)专利许可证对作品进行制作、让人制作、使用、提供销售、销售、
|
||||
进口和其它转让,且这样的许可证仅适用于在所递交作品的贡献中因可由单一的或多个这样的贡献者
|
||||
授予而必须侵犯的申请专利。如果用户对任何实体针对作品或作品中所涉及贡献提出因直接性或贡献性
|
||||
专利侵权而提起专利法律诉讼(包括交互诉讼请求或反索赔),那么根据本许可证,授予用户针对作品
|
||||
的任何专利许可证将在提起上述诉讼之日起终止。
|
||||
|
||||
4.重新分发
|
||||
|
||||
用户可在任何媒介中复制和分发作品或衍生作品之副本,无论是否修订,还是以源程序形式或目标形式,
|
||||
条件是用户需满足下列条款:
|
||||
|
||||
a) 用户必须为作品或衍生作品的任何其他接收者提供本许可证的副本;并且
|
||||
|
||||
b) 用户必须让任何修改过的文件附带明显的通知,声明用户已更改文件;并且
|
||||
|
||||
c) 用户必须从作品的源程序形式中保留衍生作品源程序形式的用户所分发的所有版权、专利、
|
||||
商标和属性通知,但不包括不属于衍生作品任何部分的类似通知;并且
|
||||
|
||||
d) 如果作品将"通知"文本文件包括为其分发作品的一部分,那么用户分发的任何衍生作品中须至少
|
||||
在下列地方之一包括,在这样的通知文件中所包含的属性通知的可读副本,但不包括那些不属于衍生
|
||||
作品任何部分的通知:在作为衍生作品一部分而分发的通知文本文件中;如果与衍生作品一起提供则
|
||||
在源程序形式或文件中;或者通常作为第三方通知出现的时候和地方,在衍生作品中产生的画面中。
|
||||
通知文件的内容仅供信息提供,并未对许可证进行修改。用户可在其分发的衍生作品中在作品的通知
|
||||
文本后或作为附录添加自己的属性通知,条件是附加的属性通知不得构成修改本许可证。
|
||||
|
||||
用户可以为自身所做出的修订添加自己的版权声明并可对自身所做出修订内容或为这样的衍生作品作为
|
||||
整体的使用、复制或分发提供附加或不同的条款,条件是用户对作品的使用、复制和分发必须符合本许
|
||||
可证中声明的条款。
|
||||
|
||||
5.贡献的提交。
|
||||
|
||||
除非用户明确声明,在作品中由用户向许可证颁发者的提交若要包含在贡献中,必须在无任何附加条款下
|
||||
符合本许可证的条款。尽管上面如此规定,执行许可证颁发者有关贡献的条款时,任何情况下均不得替代
|
||||
或修改任何单独许可证协议的条款。
|
||||
|
||||
6.商标。本许可证并未授予用户使用许可证颁发者的商号、商标、服务标记或产品名称,除非将这些名称
|
||||
用于合理性和惯例性描述作品起源和复制通知文件的内容时。
|
||||
|
||||
7.保证否认条款。除非因适用法律需要或书面同意,许可证颁发者以"按原样"基础提供作品(并且每个
|
||||
贡献者提供其贡献),无任何明示的或暗示的保证或条件,包括但不限于关于所有权、不侵权、
|
||||
商品适销性、或适用性的保证或条件。用户仅对使用或重新分发作品的正确性负责,并需承担根据本
|
||||
许可证行使权限时的任何风险。
|
||||
|
||||
8.责任限制条款。在任何情况下并根据任何法律,无论是因侵权(包括过失)或根据合同,还是其它原因,
|
||||
除非根据适用法律需要(例如故意行为和重大过失行为)或经书面同意,即使贡献者事先已被告知发生
|
||||
损害的可能性,任何贡献者不就用户因使用本许可证或不能使用或无法使用作品(包括但不限于商誉损失、
|
||||
停工、计算机失效或故障,或任何商业损坏或损失)而造成的损失,包括直接的、非直接的、特殊的、意外
|
||||
的或间接的字符损坏而负责。
|
||||
|
||||
9.接受保证或附加责任。重新分发作品或及其衍生作品时,用户可选择提供或为符合本许可证承担之支持、
|
||||
担保、赔偿或其它职责义务和/或权利而收取费用。但是,在承担上述义务时,用户只可代表用户本身和
|
||||
用户本身责任来执行,无需代表任何其它贡献者,并且用户仅可保证、防护并保持每个贡献者不受任何
|
||||
因此而产生的责任或对因用户自身承担这样的保证或附加责任而对这样的贡献者所提出的索赔。
|
||||
|
||||
条款结束
|
||||
|
||||
附录:如何向用户作品中应用Apache许可证。
|
||||
|
||||
若要向用户作品应用Apache许可证,请附加下列样本通知,将括号"[]"中的字段以用户自身的
|
||||
区分信息来替换(但不包括括号)。文本必须以文件格式适当的注释句法包含在其中。
|
||||
另外建议将文件名或类别名以及目的说明包含在相同的"打印页"上作为版权通知,以更加容易的区分出第三方档案。
|
||||
|
||||
版权所有 2016 ShenHuaJie iBase4J@163.com 根据2.0版本Apache许可证("许可证")授权;
|
||||
根据本许可证,用户可以不使用此文件。
|
||||
|
||||
用户可从下列网址获得许可证副本:http://www.apache.org/licenses/LICENSE-2.0
|
||||
除非因适用法律需要或书面同意,根据许可证分发的软件是基于"按原样"基础提供,
|
||||
无任何明示的或暗示的保证或条件。详见根据许可证许可下,特定语言的管辖权限和限制。
|
||||
|
||||
=======================================================
|
||||
|
||||
简要解释:
|
||||
|
||||
1.需要给代码的用户一份Apache Licence
|
||||
2.如果你修改了代码,需要在被修改的文件中说明。
|
||||
3.在延伸的代码中(修改和有源代码衍生的代码中)需要带有原来代码中的协议,商标,
|
||||
专利声明和其他原来作者规定需要包含的说明。
|
||||
4.如果再发布的产品中包含一个Notice文件,则在Notice文件中需要带有 Apache Licence。
|
||||
你可以在Notice中增加自己的许可,但不可以表现为对Apache Licence构成更改。
|
||||
37
README.md
Normal file
37
README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# 项目简介
|
||||
|
||||
为 java 设计的锁。
|
||||
|
||||
[](http://mvnrepository.com/artifact/com.github.houbb/lock)
|
||||
[](https://www.travis-ci.org/houbb/lock?branch=master)
|
||||
[](https://coveralls.io/github/houbb/lock?branch=master)
|
||||
|
||||
## 目的
|
||||
|
||||
- 基于 redis 的分布式锁
|
||||
|
||||
- 基于 oracle 的分布式锁
|
||||
|
||||
- 基于 mysql 的分布式锁
|
||||
|
||||
# 变更日志
|
||||
|
||||
> [变更日志](doc/CHANGELOG.md)
|
||||
|
||||
# 快速开始
|
||||
|
||||
## 需要
|
||||
|
||||
jdk1.7+
|
||||
|
||||
maven 3.x+
|
||||
|
||||
## maven 引入
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>lock</artifactId>
|
||||
<version>${最新版本}</version>
|
||||
</dependency>
|
||||
```
|
||||
10
cgit.bat
Normal file
10
cgit.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
:: 用于提交当前变更(windows)
|
||||
:: author: houbb
|
||||
:: LastUpdateTime: 2018-11-22 09:08:52
|
||||
:: 用法:双击运行,或者当前路径 cmd 直接输入 .\cgit.bat
|
||||
|
||||
git add .
|
||||
git commit -m "[Feature] add for new"
|
||||
git push
|
||||
git status
|
||||
|
||||
11
cgit.sh
Normal file
11
cgit.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
# 提交
|
||||
|
||||
git add .
|
||||
git commit -m "[Feature] add for new"
|
||||
git push
|
||||
git status
|
||||
|
||||
# 1. 赋值权限: chmod +x ./cgit.sh
|
||||
# 2. 执行: ./cgit.sh
|
||||
# Last Update Time: 2018-11-21 21:55:38
|
||||
# Author: houbb
|
||||
30
doc/CI集成.md
Normal file
30
doc/CI集成.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# 文档说明
|
||||
|
||||
作者:侯宾宾
|
||||
|
||||
时间:2018-04-24 10:11:43
|
||||
|
||||
说明:如何进行项目的持续集成+测试覆盖率
|
||||
|
||||
# Travis-CI
|
||||
|
||||
[https://www.travis-ci.org](https://www.travis-ci.org) 直接添加此项目
|
||||
|
||||
# Coveralls
|
||||
|
||||
- 添加项目
|
||||
|
||||
[https://coveralls.io/repos/new](https://coveralls.io/repos/new) 直接添加项目
|
||||
|
||||
- 生成密匙
|
||||
|
||||
```
|
||||
travis encrypt COVERALLS_TOKEN=${your_repo_token}
|
||||
```
|
||||
|
||||
- 添加到文件
|
||||
|
||||
```
|
||||
travis encrypt COVERALLS_TOKEN=${your_repo_token} --add
|
||||
```
|
||||
|
||||
26
doc/issues/v0.0.1.md
Normal file
26
doc/issues/v0.0.1.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# 基础类
|
||||
|
||||
# 规划好包
|
||||
|
||||
所有的包都需要有 `package-info.java`
|
||||
|
||||
按照功能点规划包名称。
|
||||
|
||||
# 命名规范
|
||||
|
||||
接口 I 开头
|
||||
|
||||
工具类 Util 结尾
|
||||
|
||||
常量类 Const 结尾
|
||||
|
||||
|
||||
禁止使用缩写,除非非常特殊的 i18n
|
||||
|
||||
使用全拼写。
|
||||
|
||||
# 使用 junit5 作为测试
|
||||
|
||||
复制所有的 paradise 有用基础的类。
|
||||
|
||||
gen-test 添加 comment
|
||||
2
doc/issues/v0.0.2.md
Normal file
2
doc/issues/v0.0.2.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# 反射相关类的添加
|
||||
|
||||
4
doc/issues/v0.0.3.md
Normal file
4
doc/issues/v0.0.3.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# 补全完善单元测试类。
|
||||
|
||||
|
||||
|
||||
46
doc/发布流程.md
Normal file
46
doc/发布流程.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# 文档说明
|
||||
|
||||
本文档用于说明当前项目如何进行发布。
|
||||
|
||||
|
||||
# 发布流程
|
||||
|
||||
## push to mvn center
|
||||
|
||||
```
|
||||
mvn clean deploy -P release
|
||||
```
|
||||
|
||||
## commit to github
|
||||
|
||||
```
|
||||
git push
|
||||
```
|
||||
|
||||
## merge to master
|
||||
|
||||
```
|
||||
git checkout master
|
||||
git pull
|
||||
git checkout branch
|
||||
git rebase master (用rebase合并主干的修改,如果有冲突在此时解决)
|
||||
git checkout master
|
||||
git merge branch
|
||||
git push
|
||||
```
|
||||
|
||||
## create new branch & checkout
|
||||
|
||||
```
|
||||
git branch release_XXX
|
||||
git checkout release_XXX
|
||||
```
|
||||
|
||||
## modify project version
|
||||
|
||||
```
|
||||
mvn versions:set -DgroupId=com.github.houbb -DartifactId=paradise* -DoldVersion=1.1.2 -DnewVersion=1.1.3-SNAPSHOT-->
|
||||
mvn -N versions:update-child-modules
|
||||
mvn versions:commit
|
||||
```
|
||||
|
||||
31
doc/版本迭代规范.md
Normal file
31
doc/版本迭代规范.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# 版本类型
|
||||
|
||||
x.y.z
|
||||
|
||||
x 表示大版本之间的迭代,可能出现前后的不兼容。
|
||||
|
||||
y 表示新特性,每次新加一个新特性,都会提升 y 的版本号。
|
||||
|
||||
z 表示修复版本号,如果为第一版,则 z=1。后续会依次提升。
|
||||
|
||||
## 使用的版本选择
|
||||
|
||||
如果在较为正式的环境使用,建议使用 x.y 相同,z 数值最大的版本。
|
||||
|
||||
因为这个版本为尽可能修复已知的 bug。
|
||||
|
||||
## 新特性
|
||||
|
||||
不同版本的新特性,参见变更日志。
|
||||
|
||||
# 版本的兼容性
|
||||
|
||||
在同一个 x 大版本中,禁止直接删除类信息。
|
||||
|
||||
所有的废弃使用 `@Depretectd` 注解、
|
||||
|
||||
## 必须有对应的测试
|
||||
|
||||
对应的测试信息。
|
||||
|
||||
保证代码的正确性。
|
||||
97
doc/项目原型.md
Normal file
97
doc/项目原型.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# 原型创建
|
||||
|
||||
- create
|
||||
|
||||
```
|
||||
$ mvn archetype:create-from-project
|
||||
```
|
||||
|
||||
- config
|
||||
|
||||
```
|
||||
~/target/generated-sources/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
|
||||
```
|
||||
|
||||
[archetype-descriptor](http://maven.apache.org/archetype/archetype-models/archetype-descriptor/archetype-descriptor.html)
|
||||
|
||||
# 文件内容
|
||||
|
||||
`~/maven-archetype/target/generated-sources/archetype/src/main/resources/META-INF/maven/archetype-metadata.xml`
|
||||
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="maven-archetype"
|
||||
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<fileSets>
|
||||
|
||||
<fileSet encoding="UTF-8">
|
||||
<directory></directory>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
<include>release.sh</include>
|
||||
<include>release_rm.sh</include>
|
||||
<include>.coveralls.yml</include>
|
||||
<include>.travis.yml</include>
|
||||
<include>.gitignore</include>
|
||||
<include>LICENSE.txt</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
<fileSet packaged="true" encoding="UTF-8">
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.md</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet encoding="UTF-8">
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.md</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
<fileSet encoding="UTF-8">
|
||||
<directory>src/test/java</directory>
|
||||
<includes>
|
||||
<include>**/*.md</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
<fileSet encoding="UTF-8">
|
||||
<directory>doc</directory>
|
||||
<includes>
|
||||
<include>**/*.md</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
|
||||
</fileSets>
|
||||
</archetype-descriptor>
|
||||
```
|
||||
|
||||
- install
|
||||
|
||||
```
|
||||
$ cd target/generated-sources/archetype/
|
||||
$ mvn install
|
||||
```
|
||||
|
||||
|
||||
- use
|
||||
|
||||
```
|
||||
$ mkdir /tmp/archetype
|
||||
$ cd /tmp/archetype
|
||||
$ mvn archetype:generate -DarchetypeCatalog=local
|
||||
```
|
||||
|
||||
## 注意
|
||||
|
||||
`.gitignore` 文件默认没有添加,需要手动添加。
|
||||
|
||||
`*.iml` 文件是多余的,手动删除
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
15
lock-api/pom.xml
Normal file
15
lock-api/pom.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>lock</artifactId>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>lock-api</artifactId>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.github.houbb.lock.api.core;
|
||||
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
* 锁定义
|
||||
* @author binbin.hou
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public interface ILock extends Lock {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package com.github.houbb.lock.api;
|
||||
29
lock-redis/pom.xml
Normal file
29
lock-redis/pom.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
<parent>
|
||||
<artifactId>lock</artifactId>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>lock-redis</artifactId>
|
||||
<description>The lock depends on redis.</description>
|
||||
|
||||
<dependencies>
|
||||
<!--============================== SELF ==============================-->
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>lock-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--============================== OTHER ==============================-->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.github.houbb.lock.redis.bs;
|
||||
|
||||
/**
|
||||
* 引导类
|
||||
* @author binbin.hou
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LockRedisBs {
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.github.houbb.lock.redis.constant;
|
||||
|
||||
/**
|
||||
* redis 锁常量
|
||||
*
|
||||
* @author binbin.hou
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public final class LockRedisConst {
|
||||
|
||||
private LockRedisConst() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 加锁成功
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static final String LOCK_SUCCESS = "OK";
|
||||
|
||||
/**
|
||||
* 如果不存在则设置值
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static final String SET_IF_NOT_EXIST = "NX";
|
||||
|
||||
/**
|
||||
* 设置过期时间
|
||||
*
|
||||
* 单位:milliseconds
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static final String SET_WITH_EXPIRE_TIME = "PX";
|
||||
|
||||
/**
|
||||
* 解锁成功
|
||||
*
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static final Long RELEASE_SUCCESS = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 默认的失效时间
|
||||
*
|
||||
* 暂时定为 30min
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static final long DEFAULT_EXPIRE_MILLS = 1000 * 60 * 30L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.github.houbb.lock.redis.core;
|
||||
|
||||
import com.github.houbb.lock.api.core.ILock;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
|
||||
/**
|
||||
* 抽象实现
|
||||
* @author binbin.hou
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public class AbstractLockRedis implements ILock {
|
||||
|
||||
@Override
|
||||
public void lock() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lockInterruptibly() throws InterruptedException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryLock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlock() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition newCondition() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.github.houbb.lock.redis.core;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
|
||||
/**
|
||||
* @author binbin.hou
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class LockRedis extends AbstractLockRedis {
|
||||
|
||||
@Override
|
||||
public void lock() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lockInterruptibly() throws InterruptedException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryLock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
|
||||
final long timeMills = unit.toMillis(time);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unlock() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Condition newCondition() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package com.github.houbb.lock.redis;
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.github.houbb.lock.redis.support.id;
|
||||
|
||||
/**
|
||||
* @author binbin.hou
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface IId {
|
||||
|
||||
/**
|
||||
* 返回唯一标识
|
||||
* @return 唯一标识
|
||||
*/
|
||||
String id();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.github.houbb.lock.redis.support.id.impl;
|
||||
|
||||
import com.github.houbb.lock.redis.support.id.IId;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author binbin.hou
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public class IdUUID implements IId {
|
||||
|
||||
/**
|
||||
* 返回唯一标识
|
||||
*
|
||||
* @return 唯一标识
|
||||
*/
|
||||
@Override
|
||||
public String id() {
|
||||
return UUID.randomUUID().toString().replace("-","");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
package com.github.houbb.lock.redis.support;
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.github.houbb.lock.redis.support.redis;
|
||||
|
||||
/**
|
||||
* Redis 客户端
|
||||
* @author binbin.hou
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface IRedisOperator {
|
||||
|
||||
/**
|
||||
* 尝试获取分布式锁
|
||||
*
|
||||
* @param lockKey 锁
|
||||
* @param requestId 请求标识
|
||||
* @param expireTimeMills 超期时间
|
||||
* @return 是否获取成功
|
||||
*/
|
||||
boolean tryLock(String lockKey, String requestId, int expireTimeMills);
|
||||
|
||||
/**
|
||||
* 解锁
|
||||
* @param lockKey 锁 key
|
||||
* @param requestId 请求标识
|
||||
* @return 结果
|
||||
* @since 0.0.1
|
||||
*/
|
||||
boolean unlock(String lockKey, String requestId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.github.houbb.lock.redis.support.redis.impl;
|
||||
|
||||
import com.github.houbb.lock.redis.constant.LockRedisConst;
|
||||
import com.github.houbb.lock.redis.support.redis.IRedisOperator;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Redis 客户端
|
||||
* @author binbin.hou
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public class JedisOperator implements IRedisOperator {
|
||||
|
||||
/**
|
||||
* jedis 客户端
|
||||
* @since 0.0.1
|
||||
*/
|
||||
private final Jedis jedis;
|
||||
|
||||
public JedisOperator(Jedis jedis) {
|
||||
this.jedis = jedis;
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试获取分布式锁
|
||||
*
|
||||
* expireTimeMills 保证当前进程挂掉,也能释放锁
|
||||
*
|
||||
* requestId 保证解锁的是当前进程(锁的持有者)
|
||||
*
|
||||
* @param lockKey 锁
|
||||
* @param requestId 请求标识
|
||||
* @param expireTimeMills 超期时间
|
||||
* @return 是否获取成功
|
||||
* @since 0.0.1
|
||||
*/
|
||||
@Override
|
||||
public boolean tryLock(String lockKey, String requestId, int expireTimeMills) {
|
||||
String result = jedis.set(lockKey, requestId, LockRedisConst.SET_IF_NOT_EXIST, LockRedisConst.SET_WITH_EXPIRE_TIME, expireTimeMills);
|
||||
return LockRedisConst.LOCK_SUCCESS.equals(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解锁
|
||||
*
|
||||
* (1)使用 requestId,保证为当前锁的持有者
|
||||
* (2)使用 lua 脚本,保证执行的原子性。
|
||||
*
|
||||
* @param lockKey 锁 key
|
||||
* @param requestId 请求标识
|
||||
* @return 结果
|
||||
* @since 0.0.1
|
||||
*/
|
||||
@Override
|
||||
public boolean unlock(String lockKey, String requestId) {
|
||||
String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
|
||||
Object result = jedis.eval(script, Collections.singletonList(lockKey), Collections.singletonList(requestId));
|
||||
return LockRedisConst.RELEASE_SUCCESS.equals(result);
|
||||
}
|
||||
|
||||
}
|
||||
6
maven_jdk7_install.bat
Normal file
6
maven_jdk7_install.bat
Normal file
@@ -0,0 +1,6 @@
|
||||
:: 用于 jdk7 的 maven clean install
|
||||
:: author: houbb
|
||||
:: LastUpdateTime: 2020-2-24 12:17:33
|
||||
:: 用法:双击运行,或者当前路径 cmd 直接输入 maven_jdk7_install.bat
|
||||
|
||||
call mvn clean install -Dhttps.protocols=TLSv1.2
|
||||
226
pom.xml
Normal file
226
pom.xml
Normal file
@@ -0,0 +1,226 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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.github.houbb</groupId>
|
||||
<artifactId>lock</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<modules>
|
||||
<module>lock-api</module>
|
||||
<module>lock-redis</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<!--============================== All Plugins START ==============================-->
|
||||
<plugin.compiler.version>3.2</plugin.compiler.version>
|
||||
<plugin.compiler.version>3.2</plugin.compiler.version>
|
||||
<plugin.surefire.version>2.18.1</plugin.surefire.version>
|
||||
<plugin.surefire.skip-it>false</plugin.surefire.skip-it>
|
||||
<plugin.surefire.ignore-failure>false</plugin.surefire.ignore-failure>
|
||||
|
||||
<plugin.maven-source-plugin.version>2.2.1</plugin.maven-source-plugin.version>
|
||||
<plugin.maven-javadoc-plugin.version>2.9.1</plugin.maven-javadoc-plugin.version>
|
||||
<plugin.maven-gpg-plugin.version>1.5</plugin.maven-gpg-plugin.version>
|
||||
|
||||
<plugin.coveralls.version>4.3.0</plugin.coveralls.version>
|
||||
<plugin.cobertura.version>2.7</plugin.cobertura.version>
|
||||
|
||||
<!--============================== MAIN ==============================-->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.compiler.level>1.7</project.compiler.level>
|
||||
|
||||
<!--============================== INTER ==============================-->
|
||||
<plugin.gen.version>1.0.6</plugin.gen.version>
|
||||
<heaven.version>0.1.113</heaven.version>
|
||||
|
||||
<!--============================== OTHER ==============================-->
|
||||
<junit.version>4.12</junit.version>
|
||||
<jedis.version>2.8.1</jedis.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!--============================== SELF ==============================-->
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>lock-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>lock-redis</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--============================== INTER ==============================-->
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>heaven</artifactId>
|
||||
<version>${heaven.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--============================== OTHER ==============================-->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<optional>true</optional>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>${jedis.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!--compiler plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${plugin.compiler.version}</version>
|
||||
<configuration>
|
||||
<source>${project.compiler.level}</source>
|
||||
<target>${project.compiler.level}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<compilerArgument>-proc:none</compilerArgument>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Javadoc -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${plugin.maven-javadoc-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!--============================== ADD For sonatype START ==============================-->
|
||||
<name>lock</name>
|
||||
<description>The lock tool for java.</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
<version>7</version>
|
||||
</parent>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<url>https://github.com/houbb/lock</url>
|
||||
<connection>https://github.com/houbb/lock.git</connection>
|
||||
<developerConnection>https://houbb.github.io/</developerConnection>
|
||||
</scm>
|
||||
<developers>
|
||||
<developer>
|
||||
<name>houbb</name>
|
||||
<email>houbinbin.echo@gmail.com</email>
|
||||
<url>https://houbb.github.io/</url>
|
||||
</developer>
|
||||
</developers>
|
||||
<!--============================== ADD For sonatype END ==============================-->
|
||||
|
||||
|
||||
<!--mvn clean deploy -P release -Darguments="gpg.passphrase=设置gpg设置密钥时候输入的Passphrase"-->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Source -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${plugin.maven-source-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Javadoc -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${plugin.maven-javadoc-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- GPG -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>${plugin.maven-gpg-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!--=================================== coveralls START ===================================-->
|
||||
<!--mvn cobertura:cobertura coveralls:report -DrepoToken=yourcoverallsprojectrepositorytoken-->
|
||||
<plugin>
|
||||
<groupId>org.eluder.coveralls</groupId>
|
||||
<artifactId>coveralls-maven-plugin</artifactId>
|
||||
<version>${plugin.coveralls.version}</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>cobertura-maven-plugin</artifactId>
|
||||
<version>${plugin.cobertura.version}</version>
|
||||
<configuration>
|
||||
<format>xml</format>
|
||||
<maxmem>256m</maxmem>
|
||||
<!-- aggregated reports for multi-module projects -->
|
||||
<aggregate>true</aggregate>
|
||||
<instrumentation>
|
||||
<excludes>
|
||||
<exclude>**/*Test.class</exclude>
|
||||
</excludes>
|
||||
</instrumentation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--=================================== coveralls END ===================================-->
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>oss</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>oss</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
</project>
|
||||
80
release.bat
Normal file
80
release.bat
Normal file
@@ -0,0 +1,80 @@
|
||||
:: 用于 release 当前项目(windows)
|
||||
:: author: houbb
|
||||
:: LastUpdateTime: 2018-1-22 09:08:52
|
||||
:: 用法:双击运行,或者当前路径 cmd 直接输入 release.bat
|
||||
|
||||
:: 关闭回显
|
||||
@echo OFF
|
||||
|
||||
ECHO "============================= RELEASE START..."
|
||||
|
||||
:: 版本号信息(需要手动指定)
|
||||
:::: 旧版本名称
|
||||
SET version=0.1.112
|
||||
:::: 新版本名称
|
||||
SET newVersion=0.1.113
|
||||
:::: 组织名称
|
||||
SET groupName=com.github.houbb
|
||||
:::: 项目名称
|
||||
SET projectName=lock
|
||||
|
||||
:: release 项目版本
|
||||
:::: snapshot 版本号
|
||||
SET snapshot_version=%version%"-SNAPSHOT"
|
||||
:::: 新的版本号
|
||||
SET release_version=%version%
|
||||
|
||||
call mvn versions:set -DgroupId=%groupName% -DartifactId=%projectName% -DoldVersion=%snapshot_version% -DnewVersion=%release_version%
|
||||
call mvn -N versions:update-child-modules
|
||||
call mvn versions:commit
|
||||
call echo "1. RELEASE %snapshot_version% TO %release_version% DONE."
|
||||
|
||||
:: 推送到 github
|
||||
git add .
|
||||
git commit -m "release branch %version%"
|
||||
git push
|
||||
git status
|
||||
|
||||
ECHO "2. PUSH TO GITHUB DONE."
|
||||
|
||||
:: 发布到 mvn 中央仓库
|
||||
mvn clean deploy -P release
|
||||
|
||||
ECHO "3. PUSH TO MAVEN CENTER DONE."
|
||||
|
||||
:: 合并到 master 分支
|
||||
:::: 分支名称
|
||||
::SET branchName="release_"%version%
|
||||
::git checkout master
|
||||
::git pull
|
||||
::git checkout %branchName%
|
||||
::git rebase master
|
||||
::git checkout master
|
||||
::git merge %branchName%
|
||||
::git push
|
||||
::
|
||||
::ECHO "3. MERGE TO MASTER DONE."
|
||||
|
||||
|
||||
:::: 拉取新的分支
|
||||
::SET newBranchName="release_"%newVersion%
|
||||
::git branch %newBranchName%
|
||||
::git checkout %newBranchName%
|
||||
::git push --set-upstream origin %newBranchName%
|
||||
::
|
||||
::ECHO "4. NEW BRANCH DONE."
|
||||
::
|
||||
:::: 修改新分支的版本号
|
||||
::SET snapshot_new_version=%newVersion%"-SNAPSHOT"
|
||||
::call mvn versions:set -DgroupId=%groupName% -DartifactId=%projectName% -DoldVersion=%release_version% -DnewVersion=%snapshot_new_version%
|
||||
::call mvn -N versions:update-child-modules
|
||||
::call mvn versions:commit
|
||||
::
|
||||
::git add .
|
||||
::git commit -m "modify branch %release_version% TO %snapshot_new_version%"
|
||||
::git push
|
||||
::git status
|
||||
::ECHO "5. MODIFY %release_version% TO %snapshot_new_version% DONE."
|
||||
::
|
||||
::ECHO "============================= RELEASE END..."
|
||||
|
||||
78
release.sh
Normal file
78
release.sh
Normal file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "============================= RELEASE START..."
|
||||
|
||||
## 版本号信息(需要手动指定)
|
||||
oldVersion="0.1.27"
|
||||
newVersion="0.1.28"
|
||||
projectName="lock"
|
||||
|
||||
# release 项目版本
|
||||
## snapshot 版本号
|
||||
snapshot_version=${oldVersion}"-SNAPSHOT"
|
||||
## 新的版本号
|
||||
release_version=${oldVersion}
|
||||
|
||||
mvn versions:set -DgroupId=com.github.houbb -DartifactId=${projectName} -DoldVersion=${snapshot_version} -DnewVersion=${release_version}
|
||||
mvn -N versions:update-child-modules
|
||||
mvn versions:commit
|
||||
echo "1. RELEASE ${snapshot_version} TO ${release_version} DONE."
|
||||
|
||||
|
||||
# 推送到 github
|
||||
git add .
|
||||
git commit -m "release branch ${oldVersion}"
|
||||
git push
|
||||
git status
|
||||
|
||||
echo "2. PUSH TO GITHUB DONE."
|
||||
|
||||
|
||||
# 推送到 maven 中央仓库
|
||||
mvn clean deploy -P release
|
||||
|
||||
echo "3. PUSH TO MAVEN CENTER DONE."
|
||||
|
||||
# 合并到 master 分支
|
||||
branchName="release_"${oldVersion} # 分支名称
|
||||
git checkout master
|
||||
git pull
|
||||
git checkout ${branchName}
|
||||
git rebase master
|
||||
git checkout master
|
||||
git merge ${branchName}
|
||||
git push
|
||||
|
||||
echo "4. MERGE TO MASTER DONE."
|
||||
|
||||
|
||||
# 拉取新的分支
|
||||
newBranchName="release_"${newVersion}
|
||||
git branch ${newBranchName}
|
||||
git checkout ${newBranchName}
|
||||
git push --set-upstream origin ${newBranchName}
|
||||
|
||||
echo "5. NEW BRANCH DONE."
|
||||
|
||||
# 修改新分支的版本号
|
||||
## snapshot 版本号
|
||||
snapshot_new_version=${newVersion}"-SNAPSHOT"
|
||||
mvn versions:set -DgroupId=com.github.houbb -DartifactId=${projectName} -DoldVersion=${release_version} -DnewVersion=${snapshot_new_version}
|
||||
mvn -N versions:update-child-modules
|
||||
mvn versions:commit
|
||||
|
||||
git add .
|
||||
git commit -m "modify branch ${release_version} TO ${snapshot_new_version}"
|
||||
git push
|
||||
git status
|
||||
echo "6. MODIFY ${release_version} TO ${snapshot_new_version} DONE."
|
||||
|
||||
echo "============================= RELEASE END..."
|
||||
|
||||
|
||||
# 使用方式:
|
||||
# 1. 赋值权限: chmod +x ./release.sh
|
||||
# 2. 执行: ./release.sh
|
||||
# Last Update Time: 2018-01-20 12:07:34
|
||||
# Author: houbb
|
||||
|
||||
|
||||
47
release_rm.sh
Normal file
47
release_rm.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
echo "============================= RELEASE START..."
|
||||
|
||||
## 版本号信息(需要手动指定)
|
||||
oldVersion="0.1.11"
|
||||
newVersion="0.1.11"
|
||||
projectName="lock"
|
||||
|
||||
# 删除分支
|
||||
oldBranchName="release_"${oldVersion}
|
||||
git branch -d ${oldBranchName}
|
||||
git push origin --delete ${oldBranchName}
|
||||
|
||||
echo "1. Branch remove success..."
|
||||
|
||||
# 拉取新的分支
|
||||
newBranchName="release_"${newVersion}
|
||||
git branch ${newBranchName}
|
||||
git checkout ${newBranchName}
|
||||
git push --set-upstream origin ${newBranchName}
|
||||
|
||||
echo "2. NEW BRANCH DONE."
|
||||
|
||||
# 修改新分支的版本号
|
||||
## snapshot 版本号
|
||||
snapshot_new_version=${newVersion}"-SNAPSHOT"
|
||||
mvn versions:set -DgroupId=com.github.houbb -DartifactId=${projectName} -DoldVersion=${release_version} -DnewVersion=${snapshot_new_version}
|
||||
mvn -N versions:update-child-modules
|
||||
mvn versions:commit
|
||||
|
||||
git add .
|
||||
git commit -m "modify branch ${release_version} TO ${snapshot_new_version}"
|
||||
git push
|
||||
git status
|
||||
echo "3. MODIFY ${release_version} TO ${snapshot_new_version} DONE."
|
||||
|
||||
echo "============================= BRANCH RE-CREATE END..."
|
||||
|
||||
echo "============================= BRANCH LIST ============================="
|
||||
git branch -a
|
||||
|
||||
# 使用方式:
|
||||
# 注意:本脚本用于删除分支,谨慎使用!
|
||||
# 1. 赋值权限: chmod +x ./release_rm.sh
|
||||
# 2. 执行: ./release_rm.sh
|
||||
# Last Update Time: 2018-06-21 11:10:42
|
||||
# Author: houbb
|
||||
Reference in New Issue
Block a user