-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpublish.gradle
100 lines (90 loc) · 3.9 KB
/
publish.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// From https://proandroiddev.com/android-libraries-on-github-packages-21f135188d58 with modifications
apply plugin: 'maven-publish'
def LIB_GROUP_ID = "de.c1710"
def LIB_ARTIFACT_ID = "filemojicompat"
def LIB_VERSION = "2.0.0"
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.set("sources")
afterEvaluate {
archiveVersion.set(android.defaultConfig.versionName)
}
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
afterEvaluate {
// Wait after evaluation to add the android classpath
// to avoid "buildToolsVersion is not specified" error
classpath += files(android.getBootClasspath())
options.linkSource false
//options.links("http://d.android.com/reference/")
}
failOnError(false)
}
task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier.set('javadoc')
afterEvaluate {
archiveVersion.set(android.defaultConfig.versionName)
}
from javadoc.destinationDir
dependsOn(javadoc)
}
// This part is from https://stackoverflow.com/a/43279079
Properties localproperties = new Properties()
localproperties.load(project.rootProject.file("local.properties").newDataInputStream())
afterEvaluate {
publishing {
repositories {
maven {
name = "GithubPackages"
url = uri("https://maven.pkg.github.com/c1710/filemojicompat")
credentials {
username = System.getenv('GITHUB_USER') ?: project.properties['GITHUB_USER'] ?: localproperties.getProperty("GITHUB_USER")
password = System.getenv('GITHUB_PERSONAL_ACCESS_TOKEN') ?: project.properties['GITHUB_PERSONAL_ACCESS_TOKEN'] ?: localproperties.getProperty("GITHUB_PERSONAL_ACCESS_TOKEN")
}
}
}
publications {
filemojicompat(MavenPublication) {
groupId LIB_GROUP_ID
artifactId LIB_ARTIFACT_ID
version = android.defaultConfig.versionName
pom {
name = "FilemojiCompat"
description = "A library based on EmojiCompat that enables the usage of files as the source of an emoji font."
url = "https://github.com/c1710/filemojicompat"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = "Constantin A."
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/c1710/filemojicompat.git"
developerConnection = "scm:git:ssh://github.com:c1710/filemojicompat.git"
url = "https://github.com/c1710/filemojicompat/tree/master"
}
}
artifact("$buildDir/outputs/aar/filemojicompat-release.aar")
artifact(sourceJar)
artifact(javadocJar)
pom.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.api.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}