Skip to content

Commit

Permalink
version 0.2.1 (wechatpay-apiv3#22)
Browse files Browse the repository at this point in the history
1. use gradle 6.4
2. publish to maven central
  • Loading branch information
xy-peng authored Jul 28, 2020
1 parent 5e326b0 commit 4fec0fe
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 76 deletions.
56 changes: 21 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,33 @@

## 项目状态

当前版本`0.2.0`为测试版本。请商户的专业技术人员在使用时注意系统和软件的正确性和兼容性,以及带来的风险。
当前版本`0.2.1`为测试版本。请商户的专业技术人员在使用时注意系统和软件的正确性和兼容性,以及带来的风险。

## 环境要求

+ Java 1.8+

## 安装

最新版本已经在 [Maven Central](https://search.maven.org/artifact/com.github.wechatpay-apiv3/wechatpay-apache-httpclient) 发布。

### Gradle

在你的`build.gradle`文件中加入如下的信息
在你的`build.gradle`文件中加入如下的依赖

```groovy
repositories {
...
maven { url 'https://jitpack.io' }
}
...
dependencies {
implementation 'com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.1.6'
...
}
implementation 'com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.2.1'
```

### Maven

加入JitPack仓库

```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
```

加入以下依赖

```xml
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.2.1</version>
</dependency>
```

## 开始
Expand Down Expand Up @@ -202,14 +184,18 @@ CloseableHttpClient httpClient = WechatPayHttpClientBuilder.create()

### 我想使用以前的版本,要怎么办

可以在gradle中指定版本号。例如希望使用0.1.6版本,可以使用以下的方式
之前的版本可以从 [jitpack](https://jitpack.io/#wechatpay-apiv3/wechatpay-apache-httpclient) 获取。例如希望使用0.1.6版本,gradle中可以使用以下的方式

```xml
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-apache-httpclient</artifactId>
<version>0.1.6</version>
</dependency>
```groovy
repositories {
...
maven { url 'https://jitpack.io' }
}
...
dependencies {
implementation 'com.github.wechatpay-apiv3:wechatpay-apache-httpclient:0.1.6'
...
}
```

## 联系我们
Expand Down
81 changes: 63 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
plugins {
id 'java-library'
id 'maven'
id 'maven-publish'
id 'signing'
}

group 'com.github.wechatpay-apiv3'
version '0.2.0'
version '0.2.1'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -14,12 +15,21 @@ repositories {
}

ext {
publishedArtifactId = project.name

httpclient_version = "4.5.12"
slf4j_version = "1.7.30"
junit_version = "4.12"
jackson_version = "2.9.10"
}

jar {
manifest {
attributes('Automatic-Module-Name': 'com.wechat.pay.contrib.apache.httpclient')
attributes('Implementation-Version': project.version)
}
}

dependencies {
api "org.apache.httpcomponents:httpclient:$httpclient_version"
implementation "org.apache.httpcomponents:httpmime:$httpclient_version"
Expand All @@ -29,25 +39,60 @@ dependencies {
testImplementation "junit:junit:$junit_version"
}

jar {
manifest {
attributes('Implementation-Title': 'wechatpay-java',
'Implementation-Version': project.version,
'Export-Package': 'com.wechat.pay.*'
)
publishing {
java {
withJavadocJar()
withSourcesJar()
}
}

task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier.set("sources")
publications {
maven(MavenPublication) {
artifactId = project.ext.publishedArtifactId
from components.java

pom {
name = project.name
description = 'An Apache HttpClient decorator for WeChat Pay\'s API'
url = 'https://github.com/wechatpay-apiv3/wechatpay-apache-httpclient'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name = 'WeChat Pay APIv3 Team'
}
}
scm {
connection = 'scm:git:https://github.com/wechatpay-apiv3/wechatpay-apache-httpclient.git'
developerConnection = 'scm:git:ssh://github.com/wechatpay-apiv3/wechatpay-apache-httpclient.git'
url = 'https://github.com/wechatpay-apiv3/wechatpay-apache-httpclient'
}
}
}
}

repositories {
maven {
name = "mavencentral"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username System.getenv('SONATYPE_NEXUS_USERNAME')
password System.getenv('SONATYPE_NEXUS_PASSWORD')
}
}
}
}

artifacts {
archives sourcesJar
signing {
sign publishing.publications.maven
}

wrapper {
gradleVersion = "5.4.1"
distributionType = Wrapper.DistributionType.ALL
}




Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Jun 03 16:31:01 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
53 changes: 33 additions & 20 deletions gradlew
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#

##############################################################################
##
## Gradle start up script for UN*X
Expand Down Expand Up @@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down Expand Up @@ -66,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -109,10 +126,11 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand All @@ -138,19 +156,19 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $i + 1`
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi

Expand All @@ -159,14 +177,9 @@ save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
APP_ARGS=`save "$@"`

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "$@"
22 changes: 21 additions & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down Expand Up @@ -65,6 +84,7 @@ set CMD_LINE_ARGS=%*

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

Expand Down

0 comments on commit 4fec0fe

Please sign in to comment.