From f170eebb0660b5d1ac77dd6965866b6786066eeb Mon Sep 17 00:00:00 2001 From: mayouli <247067345@qq.com> Date: Fri, 23 Jul 2021 16:19:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=B7=BB=E5=8A=A0=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0Maven=E4=BB=93=E5=BA=93=E7=9A=84=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 3 +- library/build.gradle | 76 +++++++++++++++++++++++++++++++++++++-- library/gradle.properties | 9 +++-- 3 files changed, 82 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4d15d015..831f917b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,4 +18,5 @@ android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official \ No newline at end of file +kotlin.code.style=official +android.overridePathCheck=true \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index 25baa51b..2093121d 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'groovy' -apply plugin: "com.vanniktech.maven.publish" +apply plugin: "signing" +apply plugin: "maven-publish" dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) @@ -7,4 +8,75 @@ dependencies { implementation localGroovy() implementation 'com.squareup:javapoet:1.13.0' implementation 'com.android.tools.build:gradle:3.0.0' -} \ No newline at end of file +} + +task sourcesJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.java.srcDirs +} + + +task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir +} + +tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') + options.addStringOption('encoding', 'UTF-8') + options.addStringOption('charSet', 'UTF-8') +} + +afterEvaluate { + publishing { + publications { + mavenAndroid(MavenPublication) { + groupId "io.github.tokenyc" + artifactId "yc" + version "1.0.0" + artifact sourcesJar + artifact javadocJar + artifact('build/libs/dateAndTime-1.0.jar') // + // 配置 pom 文件格式 + pom { + packaging = 'jar' + name = "yc" + description = "yc" + url = "https://github.com/TokenYc/AndroidJunkCode" + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'yc' + name = 'yc' + email = '247067345@qq.com' + } + } + scm { + connection = "https://github.com/TokenYc/AndroidJunkCode" + developerConnection = "https://github.com/TokenYc/AndroidJunkCode.git" + url = "https://github.com/TokenYc/AndroidJunkCode" + } + } + } + } + // 配置远程仓库 + repositories { + maven { + url = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' + credentials { + username "xxxx" + password "xxxx" + } + } + } + } + + signing { + sign publishing.publications.mavenAndroid + } +} diff --git a/library/gradle.properties b/library/gradle.properties index b65f366a..447e702a 100644 --- a/library/gradle.properties +++ b/library/gradle.properties @@ -21,10 +21,13 @@ POM_LICENCE_DIST=repo POM_DEVELOPER_ID=qq549631030 POM_DEVELOPER_NAME=huangx POM_DEVELOPER_URL=https://github.com/qq549631030/ +android.overridePathCheck=true + +signing.keyId=xxxxx +signing.password=xxxxxx +signing.secretKeyRingFile=C\:\\Users\\YC\\secring.gpg + -#signing.keyId=[you keyId last 8bit] -#signing.password=[you key password] -#signing.secretKeyRingFile=[you gpg key file location] # #mavenCentralRepositoryUsername=[you sonatype username] #mavenCentralRepositoryPassword=[you sonatype password]