-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle.kts
101 lines (88 loc) · 3.11 KB
/
build.gradle.kts
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
buildscript {
val kotlinVersion: String by project
repositories {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
val localProperties = java.util.Properties().apply {
val file = File(rootProject.rootDir, "local.properties")
if (file.exists()) {
load(java.io.FileInputStream(file))
}
}
plugins {
id("maven-publish")
id("org.ajoberstar.git-publish") version "4.1.1"
id("org.ajoberstar.grgit") version "4.1.1"
id("org.jlleitschuh.gradle.ktlint") version "10.2.0"
}
allprojects {
group = "deezer.kustomexport"
version = "0.8.2"
repositories {
mavenLocal()
mavenCentral()
google()
}
}
// Required by M1 for now (no node build for v14 on M1)
/*rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
}*/
if (localProperties.getProperty("REPOSITORY_URL") != null)
subprojects {
publishing {
repositories {
maven {
url = uri(localProperties.getProperty("REPOSITORY_URL"))
credentials {
username = localProperties.getProperty("REPOSITORY_USERNAME")
password = localProperties.getProperty("REPOSITORY_PASSWORD")
}
}
}
}
}
val gitUser = System.getenv("GIT_USER")
val gitPassword = System.getenv("GIT_PASSWORD")
if (gitUser != null && gitPassword != null) {
System.setProperty("org.ajoberstar.grgit.auth.username", gitUser)
System.setProperty("org.ajoberstar.grgit.auth.password", gitPassword)
}
tasks.create<Delete>("cleanMavenLocalArtifacts") {
delete = setOf("$buildDir/mvn-repo/")
}
tasks.create<Sync>("copyMavenLocalArtifacts") {
group = "publishing"
dependsOn(":compiler:publishToMavenLocal", ":lib:publishToMavenLocal", ":lib-coroutines:publishToMavenLocal")
val userHome = System.getProperty("user.home")
val groupDir = project.group.toString().replace('.', '/')
val localRepository = "$userHome/.m2/repository/$groupDir/"
from(localRepository) {
include("*/${project.version}/**")
include("*/maven-metadata*.xml")
}
val basePath = "$buildDir/mvn-repo/$groupDir/"
into(basePath)
doLast {
File(basePath).listFiles()?.forEach {
val metadataLocal = File(it.absolutePath+ "/maven-metadata-local.xml")
if (metadataLocal.exists()) {
metadataLocal.renameTo(File(it.absolutePath + "/maven-metadata.xml"))
}
}
}
}
gitPublish {
repoUri.set("[email protected]:deezer/KustomExport.git")
branch.set("mvn-repo")
contents.from("$buildDir/mvn-repo")
preserve { include("**") }
val head = grgit.head()
commitMessage.set("${head.abbreviatedId}: ${project.version} : ${head.fullMessage}")
}
tasks["copyMavenLocalArtifacts"].dependsOn("cleanMavenLocalArtifacts")
tasks["gitPublishCopy"].dependsOn("copyMavenLocalArtifacts")