Skip to content

Commit 706c3ae

Browse files
authored
Use JReleaser to publish libpag's AAR package in Maven Central Repository. (#2933)
1 parent e4eba4d commit 706c3ae

File tree

2 files changed

+66
-57
lines changed

2 files changed

+66
-57
lines changed

android/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ buildscript {
2828
// NOTE: Do not place your application dependencies here; they belong
2929
// in the individual module build.gradle files
3030
}
31+
32+
// Force commons-compress version for all configurations to resolve compatibility issues
33+
configurations.classpath {
34+
resolutionStrategy {
35+
force 'org.apache.commons:commons-compress:1.26.0'
36+
}
37+
}
3138
}
3239

3340
allprojects {

android/libpag/build.gradle

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
apply plugin: 'com.android.library'
2-
apply plugin: 'maven-publish'
3-
apply plugin: 'signing'
1+
plugins {
2+
id 'com.android.library'
3+
id 'maven-publish'
4+
id 'signing'
5+
id 'org.jreleaser' version '1.19.0'
6+
}
7+
48

59
version = '4.1.0'
610
project.ext.artifactId = 'libpag'
@@ -71,37 +75,29 @@ task androidSourcesJar(type: Jar) {
7175

7276
publishing {
7377
publications {
74-
mavenAar(MavenPublication) {
75-
// group id,发布后引用的依赖的 group id
76-
groupId 'com.tencent.tav'
77-
// 发布后引用的依赖的 artifact id
78-
artifactId 'libpag'
79-
println version
80-
// 发布的 arr 的文件和源码文件
78+
maven(MavenPublication) {
79+
groupId = 'com.tencent.tav'
80+
artifactId = 'libpag'
81+
8182
artifact("$buildDir/outputs/aar/libpag-release.aar")
8283
artifact androidSourcesJar
8384
pom {
84-
// 构件名称,可以自定义
8585
name = 'libpag'
86-
// 构件描述
8786
description = 'A real-time rendering library for PAG (Portable Animated Graphics) files that renders After Effects animations natively across multiple platforms.'
88-
// 构件主页
8987
url = 'https://github.com/Tencent/libpag'
90-
// 许可证名称和地址
9188
licenses {
9289
license {
9390
name = 'The Apache License, Version 2.0'
9491
url = 'https://github.com/Tencent/libpag/blob/main/LICENSE.txt'
9592
}
9693
}
97-
// 开发者信息
9894
developers {
9995
developer {
96+
id = 'libpag'
10097
name = 'libpag'
10198
email = 'libpag@tencent.com'
10299
}
103100
}
104-
// 版本控制仓库地址
105101
scm {
106102
url = 'https://github.com/Tencent/libpag'
107103
connection = 'scm:git:github.com/Tencent/libpag.git'
@@ -110,18 +106,59 @@ publishing {
110106
}
111107
}
112108
}
109+
113110
repositories {
114111
maven {
115-
// 发布的位置,这里根据发布的版本区分了 SNAPSHOT 和最终版本两种情况
116-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
117-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
118-
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
112+
name = 'staging'
113+
url = layout.buildDirectory.dir('staging-deploy')
119114
}
120115
}
121116
}
122117

123118
signing {
124-
sign publishing.publications
119+
// Completely disable Gradle signing - JReleaser will handle all signing
120+
required { false }
121+
}
122+
123+
jreleaser {
124+
gitRootSearch = true
125+
126+
project{
127+
description = "A real-time rendering library for PAG (Portable Animated Graphics) files that renders After Effects animations natively across multiple platforms."
128+
copyright = "Copyright © 2025 Tencent. All rights reserved."
129+
}
130+
131+
release {
132+
github {
133+
enabled = true
134+
skipTag = true
135+
skipRelease = true
136+
}
137+
}
138+
139+
signing {
140+
active = 'ALWAYS'
141+
armored = true
142+
}
143+
144+
deploy {
145+
maven {
146+
mavenCentral {
147+
sonatype {
148+
active = "ALWAYS"
149+
url = "https://central.sonatype.com/api/v1/publisher"
150+
stagingRepository(layout.buildDirectory.dir("staging-deploy").get().toString())
151+
setAuthorization("Basic")
152+
applyMavenCentralRules = false // Wait for fix: https://github.com/kordamp/pomchecker/issues/21
153+
sign = true
154+
checksums = true
155+
sourceJar = true
156+
javadocJar = true
157+
retryDelay = 60
158+
}
159+
}
160+
}
161+
}
125162
}
126163

127164
project.afterEvaluate {
@@ -166,39 +203,4 @@ project.afterEvaluate {
166203
include '*.so'
167204
}
168205
}
169-
publishing {
170-
repositories {
171-
}
172-
publications {
173-
aar(MavenPublication) {
174-
groupId project.group
175-
artifactId project.artifactId
176-
version project.version
177-
178-
artifact bundleReleaseAar
179-
180-
//The publication doesn't know about our dependencies, so we have to manually add them to the pom
181-
pom.withXml {
182-
// for dependencies and exclusions
183-
def dependenciesNode = asNode().appendNode('dependencies')
184-
configurations.api.allDependencies.withType(ModuleDependency) { ModuleDependency dp ->
185-
def dependencyNode = dependenciesNode.appendNode('dependency')
186-
dependencyNode.appendNode('groupId', dp.group)
187-
dependencyNode.appendNode('artifactId', dp.name)
188-
dependencyNode.appendNode('version', dp.version)
189-
190-
// for exclusions
191-
if (dp.excludeRules.size() > 0) {
192-
def exclusions = dependencyNode.appendNode('exclusions')
193-
dp.excludeRules.each { ExcludeRule ex ->
194-
def exclusion = exclusions.appendNode('exclusion')
195-
exclusion.appendNode('groupId', ex.group)
196-
exclusion.appendNode('artifactId', ex.module)
197-
}
198-
}
199-
}
200-
}
201-
}
202-
}
203-
}
204-
}
206+
}

0 commit comments

Comments
 (0)