forked from JetBrains/rd
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
183 lines (159 loc) · 6.68 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import com.jetbrains.rd.gradle.dependencies.kotlinVersion
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
project.extra.apply {
val repoRoot = rootProject.projectDir
set("repoRoot", repoRoot)
set("cppRoot", File(repoRoot, "rd-cpp"))
set("ktRoot", File(repoRoot, "rd-kt"))
set("csRoot", File(repoRoot, "rd-net"))
}
}
plugins {
base
id("me.filippov.gradle.jvm.wrapper") version "0.14.0"
}
allprojects {
plugins.apply("maven-publish")
configurations.all {
resolutionStrategy {
force("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
force("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
force("org.jetbrains.kotlin:kotlin-runtime:$kotlinVersion")
force("org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion")
}
}
repositories {
mavenCentral()
}
tasks {
withType<Test> {
testLogging {
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
}
}
withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
withType<JavaCompile> {
targetCompatibility = "17"
}
}
}
val clean by tasks.getting(Delete::class) {
delete(rootProject.buildDir)
}
if (System.getenv("TEAMCITY_VERSION") == null) {
version = "SNAPSHOT"
}
tasks {
val nuGetTargetDir = buildDir.resolve("artifacts").resolve("nuget")
val publishingGroup = "publishing"
val dotNetBuild by registering(Exec::class) {
group = publishingGroup
executable = projectDir.resolve("rd-net").resolve("dotnet.cmd").canonicalPath
args("build", "/p:Configuration=Release", "/p:PackageVersion=$version", projectDir.resolve("rd-net").resolve("Rd.sln").canonicalPath)
environment("DOTNET_NOLOGO", "1")
environment("DOTNET_CLI_TELEMETRY_OPTOUT", "1")
}
val packNuGetLifetimes by registering(Exec::class) {
group = publishingGroup
dependsOn(dotNetBuild)
executable = project.projectDir.resolve("rd-net").resolve("dotnet.cmd").canonicalPath
args("pack", "--include-symbols", "/p:Configuration=Release", "/p:PackageVersion=$version", projectDir.resolve("rd-net").resolve("Lifetimes").resolve("Lifetimes.csproj").canonicalPath)
environment("DOTNET_NOLOGO", "1")
environment("DOTNET_CLI_TELEMETRY_OPTOUT", "1")
}
val copyNuGetLifetimes by registering(Copy::class) {
group = publishingGroup
dependsOn(packNuGetLifetimes)
from("${projectDir.resolve("rd-net").resolve("Lifetimes").resolve("bin").resolve("Release").canonicalPath}${File.separator}")
include("*.nupkg")
include("*.snupkg")
into(buildDir.resolve("artifacts").resolve("nuget"))
}
val packDotNetRdFramework by registering(Exec::class) {
group = publishingGroup
dependsOn(dotNetBuild)
executable = project.projectDir.resolve("rd-net").resolve("dotnet.cmd").canonicalPath
args("pack", "--include-symbols", "/p:Configuration=Release", "/p:PackageVersion=$version", projectDir.resolve("rd-net").resolve("RdFramework").resolve("RdFramework.csproj").canonicalPath)
environment("DOTNET_NOLOGO", "1")
environment("DOTNET_CLI_TELEMETRY_OPTOUT", "1")
}
val copyNuGetRdFramework by registering(Copy::class) {
group = publishingGroup
dependsOn(packDotNetRdFramework)
from("${projectDir.resolve("rd-net").resolve("RdFramework").resolve("bin").resolve("Release").canonicalPath}${File.separator}")
include("*.nupkg")
include("*.snupkg")
into(buildDir.resolve("artifacts").resolve("nuget"))
}
val packDotNetRdFrameworkReflection by registering(Exec::class) {
group = publishingGroup
dependsOn(dotNetBuild)
executable = project.projectDir.resolve("rd-net").resolve("dotnet.cmd").canonicalPath
args("pack", "--include-symbols", "/p:Configuration=Release", "/p:PackageVersion=$version", projectDir.resolve("rd-net").resolve("RdFramework.Reflection").resolve("RdFramework.Reflection.csproj").canonicalPath)
environment("DOTNET_NOLOGO", "1")
environment("DOTNET_CLI_TELEMETRY_OPTOUT", "1")
}
val copyNuGetRdFrameworkReflection by registering(Copy::class) {
group = publishingGroup
dependsOn(packDotNetRdFrameworkReflection)
from("${projectDir.resolve("rd-net").resolve("RdFramework.Reflection").resolve("bin").resolve("Release").canonicalPath}${File.separator}")
include("*.nupkg")
include("*.snupkg")
into(buildDir.resolve("artifacts").resolve("nuget"))
}
val cleanupArtifacts by registering {
group = publishingGroup
doLast {
if (nuGetTargetDir.exists()) {
nuGetTargetDir.deleteRecursively()
}
}
}
val createNuGetPackages by registering {
group = publishingGroup
dependsOn(cleanupArtifacts, copyNuGetLifetimes, copyNuGetRdFramework, copyNuGetRdFrameworkReflection)
}
fun enableNuGetPublishing(url: String, apiKey: String) {
val args = mutableListOf<Any>(
project.projectDir.resolve("rd-net").resolve("dotnet.cmd").canonicalPath,
"nuget",
"push",
"--source", url,
"--api-key", apiKey
)
for (file in nuGetTargetDir.listFiles()?.filter { it.extension == "nupkg" } ?: emptyList()) {
exec {
val argsForCurrentFile = (args + file).toTypedArray()
commandLine(*argsForCurrentFile)
}
}
}
val publishNuGet by registering {
group = publishingGroup
dependsOn(createNuGetPackages)
val deployToNuGetOrg = rootProject.extra["deployNuGetToNuGetOrg"].toString().toBoolean()
val deployToInternal = rootProject.extra["deployNuGetToInternal"].toString().toBoolean()
doLast {
if (deployToNuGetOrg) {
val nuGetOrgApiKey = rootProject.extra["nuGetOrgApiKey"].toString()
enableNuGetPublishing("https://api.nuget.org/v3/index.json", nuGetOrgApiKey)
}
if (deployToInternal) {
val internalFeedUrl = rootProject.extra["internalNuGetFeedUrl"].toString()
val internalFeedApiKey = rootProject.extra["internalDeployKey"].toString()
enableNuGetPublishing(internalFeedUrl, internalFeedApiKey)
}
}
}
named("publish") {
dependsOn(publishNuGet)
}
}