1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- apply plugin: 'maven-publish'
- apply plugin: 'signing'
- def PUBLISH_VERSION = '1.13.0-SNAPSHOT'
- def PUBLISH_GROUP_ID = 'com.compdf'
- def PUBLISH_ARTIFACT_ID = 'compdfkit-tools'
- ext["signing.keyId"] = '' //签名的密钥后8位
- ext["signing.password"] = '' //签名设置的密码
- ext["signing.secretKeyRingFile"] = '' //生成的secring.gpg文件目录
- ext["ossrhUsername"] = '' //sonatype用户名
- ext["ossrhPassword"] = '' //sonatype密码
- task sourceJar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- classifier "source"
- }
- File secretPropsFile = project.rootProject.file('maven.properties')
- if (secretPropsFile.exists()) {
- println "Found secret props file, loading props"
- Properties p = new Properties()
- p.load(new FileInputStream(secretPropsFile))
- p.each { name, value ->
- ext[name] = value
- }
- } else {
- println "No props file, loading env vars"
- }
- afterEvaluate {
- publishing {
- publications {
- release(MavenPublication) {
- println("publish-maven Log-------> PUBLISH_GROUP_ID: $PUBLISH_GROUP_ID; PUBLISH_ARTIFACT_ID: $PUBLISH_ARTIFACT_ID; PUBLISH_VERSION: $PUBLISH_VERSION")
- groupId PUBLISH_GROUP_ID
- artifactId PUBLISH_ARTIFACT_ID
- version = PUBLISH_VERSION
- artifact("$buildDir/outputs/aar/ComPDFKit_Tools-release.aar")
- // artifact(sourceJar)
- pom {
- name = PUBLISH_ARTIFACT_ID
- url = 'https://www.compdf.com/'
- description = 'ComPDFKit SDK for Android'
- developers {
- developer {
- id = 'compdfkit'
- name = 'compdfkit' //你的sonatype用户名
- email = 'youna@compdf.com' //你的sonatype注册邮箱
- }
- }
- licenses {
- license {
- name = 'ComPDFKit License'
- url = 'https://github.com/ComPDFKit/PDF-SDK-Android/blob/main/LICENSE'
- }
- }
- scm {
- connection = 'https://github.com/ComPDFKit/PDF-SDK-Android'
- developerConnection = 'https://github.com/ComPDFKit/PDF-SDK-Android'
- url = 'https://github.com/ComPDFKit/PDF-SDK-Android/tree/main'
- }
- withXml{
- def dependenciesNode = asNode().appendNode('dependencies')
- //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
- configurations.implementation.allDependencies.each {
- if(it.group != null && (it.name != null || "unspecified".equals(it.name)) && it.version != null)
- {
- def dependencyNode = dependenciesNode.appendNode('dependency')
- dependencyNode.appendNode('groupId', it.group)
- dependencyNode.appendNode('artifactId', it.name)
- dependencyNode.appendNode('version', it.version)
- }
- }
- }
- }
- }
- }
- repositories {
- maven {
- name = PUBLISH_ARTIFACT_ID
- def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
- def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
- println("publish version:${PUBLISH_VERSION}")
- url = PUBLISH_VERSION.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
- credentials {
- username ossrhUsername
- password ossrhPassword
- }
- }
- }
- }
- }
- signing {
- sign publishing.publications
- }
|