Skip to content

Commit 406db93

Browse files
committed
Setup maven central publish
1 parent d062a66 commit 406db93

File tree

4 files changed

+162
-47
lines changed

4 files changed

+162
-47
lines changed

build.gradle

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
apply plugin: 'io.codearte.nexus-staging'
23

34
buildscript {
45
ext.kotlin_version = '1.3.61'
56
ext.kotlin_coroutines_version = '1.3.3'
67
repositories {
78
google()
9+
mavenCentral()
810
jcenter()
11+
maven {
12+
url 'https://dl.bintray.com/kotlin/kotlin-dev'
13+
content {
14+
includeGroup('org.jetbrains.dokka')
15+
}
16+
}
17+
maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
918
}
1019
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.5.3'
20+
classpath 'com.android.tools.build:gradle:4.1.3'
1221
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13-
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.4'
22+
classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5-SNAPSHOT'
23+
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
24+
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.4.20.2-dev-64'
25+
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0'
1426
// NOTE: Do not place your application dependencies here; they belong
1527
// in the individual module build.gradle files
1628
}
@@ -19,7 +31,14 @@ buildscript {
1931
allprojects {
2032
repositories {
2133
google()
34+
mavenCentral()
2235
jcenter()
36+
maven {
37+
url 'https://dl.bintray.com/kotlin/kotlin-dev'
38+
content {
39+
includeGroup('org.jetbrains.dokka')
40+
}
41+
}
2342
}
2443
}
2544

compressor/build.gradle

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,14 @@ apply plugin: 'kotlin-android'
33
apply plugin: 'com.github.dcendents.android-maven'
44
apply plugin: 'jacoco-android'
55

6-
buildscript {
7-
repositories {
8-
mavenCentral()
9-
jcenter()
10-
}
11-
dependencies {
12-
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
13-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
14-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15-
}
16-
}
17-
186
ext {
19-
bintrayRepo = 'maven'
20-
bintrayName = 'compressor'
21-
22-
publishedGroupId = 'id.zelory'
23-
libraryName = 'Compressor'
24-
artifact = 'compressor'
25-
26-
libraryDescription = 'An android image compressor library'
27-
28-
siteUrl = 'https://github.com/zetbaitsu/Compressor'
29-
gitUrl = 'https://github.com/zetbaitsu/Compressor.git'
30-
31-
libraryVersion = '3.0.0'
32-
33-
developerId = 'zetbaitsu'
34-
developerName = 'Zetra'
35-
developerEmail = '[email protected]'
36-
37-
licenseName = 'The Apache Software License, Version 2.0'
38-
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
39-
allLicenses = ["Apache-2.0"]
7+
PUBLISH_GROUP_ID = 'id.zelory'
8+
PUBLISH_VERSION = '3.0.0'
9+
PUBLISH_ARTIFACT_ID = 'compressor'
4010
}
4111

12+
apply from: "$rootDir/gradle/publish_maven.gradle"
13+
4214
android {
4315
compileSdkVersion 29
4416
buildToolsVersion '29.0.2'
@@ -57,8 +29,6 @@ android {
5729
}
5830
}
5931

60-
apply from: 'https://raw.githubusercontent.com/zetbaitsu/JCenter/master/installv1.gradle'
61-
apply from: 'https://raw.githubusercontent.com/zetbaitsu/JCenter/master/bintrayv1.gradle'
6232

6333
dependencies {
6434
implementation fileTree(dir: 'libs', include: ['*.jar'])
@@ -70,11 +40,3 @@ dependencies {
7040
testImplementation 'com.natpryce:hamkrest:1.7.0.0'
7141
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlin_coroutines_version"
7242
}
73-
74-
repositories {
75-
mavenCentral()
76-
}
77-
78-
tasks.withType(Javadoc).all {
79-
enabled = false
80-
}

gradle/publish_maven.gradle

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
apply plugin: 'org.jetbrains.dokka'
4+
5+
task androidSourcesJar(type: Jar) {
6+
archiveClassifier.set('sources')
7+
if (project.plugins.findPlugin("com.android.library")) {
8+
from android.sourceSets.main.java.srcDirs
9+
from android.sourceSets.main.kotlin.srcDirs
10+
} else {
11+
from sourceSets.main.java.srcDirs
12+
from sourceSets.main.kotlin.srcDirs
13+
}
14+
}
15+
16+
tasks.withType(dokkaHtmlPartial.getClass()).configureEach {
17+
pluginsMapConfiguration.set(
18+
["org.jetbrains.dokka.base.DokkaBase": """{ "separateInheritedMembers": true}"""]
19+
)
20+
}
21+
22+
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
23+
archiveClassifier.set('javadoc')
24+
from dokkaJavadoc.outputDirectory
25+
}
26+
27+
artifacts {
28+
archives androidSourcesJar
29+
archives javadocJar
30+
}
31+
32+
33+
group = PUBLISH_GROUP_ID
34+
version = PUBLISH_VERSION
35+
36+
ext["signing.keyId"] = ''
37+
ext["signing.password"] = ''
38+
ext["signing.secretKeyRingFile"] = ''
39+
ext["ossrhUsername"] = ''
40+
ext["ossrhPassword"] = ''
41+
ext["sonatypeStagingProfileId"] = ''
42+
43+
File secretPropsFile = project.rootProject.file('local.properties')
44+
if (secretPropsFile.exists()) {
45+
Properties p = new Properties()
46+
p.load(new FileInputStream(secretPropsFile))
47+
p.each { name, value ->
48+
ext[name] = value
49+
}
50+
} else {
51+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
52+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
53+
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
54+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
55+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
56+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
57+
}
58+
59+
publishing {
60+
publications {
61+
release(MavenPublication) {
62+
groupId PUBLISH_GROUP_ID
63+
artifactId PUBLISH_ARTIFACT_ID
64+
version PUBLISH_VERSION
65+
if (project.plugins.findPlugin("com.android.library")) {
66+
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
67+
} else {
68+
artifact("$buildDir/libs/${project.getName()}-${version}.jar")
69+
}
70+
71+
artifact androidSourcesJar
72+
artifact javadocJar
73+
74+
pom {
75+
name = PUBLISH_ARTIFACT_ID
76+
description = 'An android image compressor library'
77+
url = 'https://github.com/zetbaitsu/Compressor'
78+
licenses {
79+
license {
80+
name = 'The Apache Software License, Version 2.0'
81+
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
82+
}
83+
}
84+
developers {
85+
developer {
86+
id = 'zetbaitsu'
87+
name = 'Zetra'
88+
89+
}
90+
}
91+
scm {
92+
connection = 'scm:git:github.com/zetbaitsu/Compressor.git'
93+
developerConnection = 'scm:git:ssh://github.com/zetbaitsu/Compressor.git'
94+
url = 'https://github.com/zetbaitsu/Compressor/tree/main'
95+
}
96+
withXml {
97+
def dependenciesNode = asNode().appendNode('dependencies')
98+
99+
project.configurations.implementation.allDependencies.each {
100+
def dependencyNode = dependenciesNode.appendNode('dependency')
101+
dependencyNode.appendNode('groupId', it.group)
102+
dependencyNode.appendNode('artifactId', it.name)
103+
dependencyNode.appendNode('version', it.version)
104+
}
105+
}
106+
}
107+
}
108+
}
109+
repositories {
110+
maven {
111+
name = "sonatype"
112+
113+
def releasesRepoUrl = "https://s01.oss.sonatype.org/content/repositories/releases/"
114+
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
115+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
116+
117+
credentials {
118+
username ossrhUsername
119+
password ossrhPassword
120+
}
121+
}
122+
}
123+
}
124+
125+
nexusStaging {
126+
packageGroup = PUBLISH_GROUP_ID
127+
stagingProfileId = sonatypeStagingProfileId
128+
username = ossrhUsername
129+
password = ossrhPassword
130+
}
131+
132+
signing {
133+
sign publishing.publications
134+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Jan 22 15:14:43 WIB 2020
1+
#Sun Mar 21 19:52:31 WIB 2021
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

0 commit comments

Comments
 (0)