Skip to content

Commit

Permalink
maven to gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
yhyzgn committed Oct 5, 2020
1 parent 19955f6 commit 68a5cb9
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 233 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar
.gradle/
gradle*
build/
ext/
135 changes: 135 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
plugins {
id "java-library"
id "maven-publish"
id "signing"
}

repositories {
mavenCentral()
gradlePluginPortal()
google()
}

apply from: "ext.gradle"

group rootProject.ext.groupId
version rootProject.ext.version

dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'

api 'com.squareup.okhttp3:okhttp:4.9.0'
api 'com.fasterxml.jackson.core:jackson-core:2.11.0'
api 'com.fasterxml.jackson.core:jackson-databind:2.11.0'
api 'com.google.code.gson:gson:2.8.6'
api 'com.google.guava:guava:29.0-jre'
implementation 'org.slf4j:slf4j-api:2.0.0-alpha1'
implementation 'org.slf4j:slf4j-simple:2.0.0-alpha1'
compileOnly 'org.jetbrains:annotations:19.0.0'
}

task replaceVersion() {
ant.replaceregexp(
file: "./src/main/java/com/yhy/http/pigeon/utils/Utils.java",
match: "public final static String VERSION = \"(.+)\"",
replace: "public final static String VERSION = \"${rootProject.ext.version}\"",
flags: 'g',
byline: "true"
)
}

task sourceJar(type: Jar) {
classifier "sources"
from sourceSets.main.allJava
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier "javadoc"
from javadoc.destinationDir
}

javadoc {
description = "生成jar格式的javadoc。"
// 只显示 protected 和 public 的类和成员
options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
options.version = true
options.header = project.name
// 静默javadoc检查(比如不支持@date会报错等),jdk 8+
options.addStringOption('Xdoclint:none', '-quiet')
// 防止本地打开中文乱码
options.addStringOption("charset", "UTF-8")
// suppress warnings due to cross-module @see and @link references;
// note that global 'api' task does display all warnings.
logging.captureStandardError LogLevel.INFO
// suppress "## warnings" message
logging.captureStandardOutput LogLevel.INFO
// 编码一定要配置否则直接出错
options.encoding = "UTF-8"
options.charSet = "UTF-8"
// java9
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}

compileJava.dependsOn replaceVersion

java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
mavenJava(MavenPublication) {
groupId = rootProject.ext.groupId
artifactId = rootProject.ext.artifactId
version = rootProject.ext.version
from components.java

pom {
name = rootProject.ext.artifactId
description = rootProject.ext.description
url = "https://${rootProject.ext.url}"
licenses {
license {
name = 'Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
comments = 'A business-friendly OSS license'
}
}
developers {
developer {
name = 'yhyzgn'
email = 'yhyzgn@gmail.com'
url = "/~https://github.com/yhyzgn/"
}
}
scm {
url = "https://${rootProject.ext.url}.git"
connection = "scm:git:https://${rootProject.ext.url}.git"
developerConnection = "scm:git:https://${rootProject.ext.url}.git"
}
}
}
}

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

signing {
sign publishing.publications.mavenJava
}
7 changes: 7 additions & 0 deletions ext.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ext {
groupId = 'com.yhyzgn.http'
artifactId = 'pigeon'
version = '1.2.9'
description = 'Java http proxy.'
url = 'github.com/yhyzgn/pigeon'
}
230 changes: 0 additions & 230 deletions pom.xml

This file was deleted.

1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'pigeon'
Loading

0 comments on commit 68a5cb9

Please sign in to comment.