1 Star 0 Fork 0

KunMinX/MVI-Dispatcher-KTX

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
publish-mavencentral.gradle 6.75 KB
一键复制 编辑 原始数据 按行查看 历史
KunMinX 提交于 2022-07-03 19:01 . update library info
apply plugin: 'maven-publish'
apply plugin: 'signing'
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
from android.sourceSets.main.java.srcDirs
} else {
from sourceSets.main.java.srcDirs
}
}
artifacts {
if (uploadJavadocs) {
archives javadocJar
}
if (uploadSources) {
archives sourcesJar
}
}
group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION
// leave them empty to allow compilation
ext["signing.keyId"] = '' // GPG Id
ext["signing.password"] = '' // gpg key pass
ext["signing.secretKeyRingFile"] = '' // location of key :|
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''
File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
p.load(new FileInputStream(secretPropsFile))
p.each { name, value ->
ext[name] = value
}
} else {
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
}
publishing {
publications {
release(MavenPublication) {
groupId group
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION
if (project.plugins.findPlugin("com.android.library")) {
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
} else {
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
}
pom {
name = PUBLISH_ARTIFACT_ID
description = ARTIFACT_DESCRIPTION
url = POM_URL
licenses {
license {
name = LICENSE_NAME
url = LICENSE_URL
}
}
developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
email = POM_DEVELOPER_EMAIL
}
}
scm {
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
url = POM_SCM_URL
}
withXml {
final dependenciesNode = asNode().appendNode('dependencies')
ext.addDependency = { Dependency dep, String scope ->
if (dep.group == null || dep.version == null || dep.name == null || dep.name == "unspecified")
return // invalid dependencies should be ignored
final dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('artifactId', dep.name)
if (dep.version == 'unspecified') {
dependencyNode.appendNode('groupId', project.ext.pomGroupID)
dependencyNode.appendNode('version', project.ext.pomVersion)
System.println("${project.ext.pomGroupID} ${dep.name} ${project.ext.pomVersion}")
} else {
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('version', dep.version)
System.println("${dep.group} ${dep.name} ${dep.version}")
}
dependencyNode.appendNode('scope', scope)
// Some dependencies may have types, such as aar, that should be mentioned in the POM file
def artifactsList = dep.properties['artifacts']
if (artifactsList != null && artifactsList.size() > 0) {
final artifact = artifactsList[0]
dependencyNode.appendNode('type', artifact.getType())
}
if (!dep.transitive) {
// In case of non transitive dependency, all its dependencies should be force excluded from them POM file
final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
exclusionNode.appendNode('groupId', '*')
exclusionNode.appendNode('artifactId', '*')
} else if (!dep.properties.excludeRules.empty) {
// For transitive with exclusions, all exclude rules should be added to the POM file
final exclusions = dependencyNode.appendNode('exclusions')
dep.properties.excludeRules.each { ExcludeRule rule ->
final exclusionNode = exclusions.appendNode('exclusion')
exclusionNode.appendNode('groupId', rule.group ?: '*')
exclusionNode.appendNode('artifactId', rule.module ?: '*')
}
}
}
configurations.api.getDependencies().each { dep -> addDependency(dep, "compile") }
configurations.implementation.getDependencies().each { dep -> addDependency(dep, "runtime") }
}
}
}
}
repositories {
maven {
name = "SonaType"
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
nexusStaging {
packageGroup = PUBLISH_GROUP_ID
stagingProfileId = sonatypeStagingProfileId
username = ossrhUsername
password = ossrhPassword
serverUrl = "https://s01.oss.sonatype.org/service/local/"
}
signing {
sign publishing.publications
}
task assembleAndPublishLocally(dependsOn: ['assembleRelease']) {
finalizedBy('publishToMavenLocal')
}
task assembleAndPublish(dependsOn: ['assembleRelease']) {
finalizedBy('publish')
}
configure(assembleAndPublishLocally) {
group = 'Publishing'
description = 'Publish the output locally'
}
configure(assembleAndPublish) {
group = 'Publishing'
description = 'Publish the output to mavenCentral'
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Kotlin
1
https://gitee.com/kunminx/MVI-Dispatcher-KTX.git
git@gitee.com:kunminx/MVI-Dispatcher-KTX.git
kunminx
MVI-Dispatcher-KTX
MVI-Dispatcher-KTX
main

搜索帮助