forked from OneUIProject/oneui-design
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
129 lines (115 loc) · 4.4 KB
/
build.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.8.0" apply false
id("com.android.library") version "8.8.0" apply false
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
id("dev.rikka.tools.refine") version "4.4.0" apply false
}
apply from: "manifest.gradle"
/**
* Note: To configure GitHub credentials, you have to generate an access token with at least
* `read:packages` scope at https://github.com/settings/tokens/new and then
* add it to any of the following:
* <ul>
* <li>Add `githubUsername` and `githubAccessToken` to Global Gradle Properties</li>
* <li>Set `GITHUB_USERNAME` and `GITHUB_ACCESS_TOKEN` in your environment variables</li>
* <li>Create a `github.properties` file in your project folder with the following content:</li>
* </ul>
*
* <pre>
* githubUsername=<YOUR_GITHUB_USERNAME>
* githubAccessToken=<YOUR_GITHUB_ACCESS_TOKEN>
* </pre>
*/
def githubProperties = new Properties().with {
def file = this.rootProject?.file("github.properties")
if (file?.exists()) file.withInputStream { load(it) }
it
}
def githubUsername = githubProperties.getProperty("githubUsername") // github.properties file
?: rootProject.findProperty("githubUsername") // Global Gradle Properties
?: System.getenv("GITHUB_USERNAME") // Environment variable
?: { throw new GradleException("GitHub username not found") }()
def githubAccessToken = githubProperties.getProperty("githubAccessToken") // github.properties file
?: rootProject.findProperty("githubAccessToken") // Global Gradle Properties
?: System.getenv("GITHUB_ACCESS_TOKEN") // Environment variable
?: { throw new GradleException("GitHub access token not found") }()
allprojects {
repositories {
google()
mavenLocal()
mavenCentral()
maven { url = uri("https://jitpack.io") }
maven {
url = uri("https://maven.pkg.github.com/tribalfs/sesl-androidx")
credentials {
username = githubUsername
password = githubAccessToken
}
}
maven {
url = uri("https://maven.pkg.github.com/tribalfs/sesl-material-components-android")
credentials {
username = githubUsername
password = githubAccessToken
}
}
maven {
url = uri("https://maven.pkg.github.com/tribalfs/oneui-design")
credentials {
username = githubUsername
password = githubAccessToken
}
}
}
tasks.withType(Javadoc).tap {
configureEach {
options.addStringOption("Xdoclint:none", "-quiet")
options.addStringOption("encoding", "UTF-8")
options.addStringOption("charSet", "UTF-8")
}
}
}
def groupId = "io.github.tribalfs"
def artifact = "oneui-design"
subprojects {
plugins.withId("com.android.base") {
plugins.apply('dev.rikka.tools.refine')
}
afterEvaluate { project ->
if (!plugins.hasPlugin("maven-publish")) {
return
}
group = groupId
version = android.defaultConfig.versionName
def readmeFile = file("${rootProject.projectDir}/README.md")
def readmeContent = new String(readmeFile.bytes)
def newVersionString = "$groupId:$artifact:$version"
def pattern = ~/io\.github\.tribalfs:oneui-design:\S+oneui\d/
new File(readmeFile.path).text = readmeContent.replaceAll(pattern, newVersionString)
println "Updated README.md with version: $newVersionString"
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = artifact
afterEvaluate {
from components.release
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/tribalfs/oneui-design")
credentials {
username = githubUsername
password = githubAccessToken
}
}
}
}
}
}
tasks.register("clean", Delete) {
delete rootProject.layout.buildDirectory
}