-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
69 lines (60 loc) · 1.56 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
plugins {
`kotlin-dsl`
kotlin("jvm") version "2.0.0"
`maven-publish`
id("net.thauvin.erik.gradle.semver") version "1.0.4"
}
repositories {
mavenLocal()
gradlePluginPortal()
}
kotlin {
jvmToolchain(17)
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
// this is so they work for downstream
implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4")
}
group = "crackers.buildstuff"
gradlePlugin {
// Define the plugin
plugins {
create("libraryPublish") {
id = "crackers.buildstuff.library-publish"
implementationClass = "LibraryPublishPlugin"
project.afterEvaluate {
version = project.version
}
}
create("protobufGen") {
id = "crackers.buildstuff.generate-protobuf"
implementationClass = "GenerateProtobufPlugin"
project.afterEvaluate {
version = project.version
}
}
}
}
fun isDefaultBranch() = System.getenv("PUBLISH_LIB") == "true"
publishing {
repositories {
// "protected" by the environment variable
if (isDefaultBranch()) {
maven {
name = "some_name"
url = uri("http://localhost")
}
}
}
}
/**
* Publish the plugin JAR (no sources).
*/
tasks.create("pluginPublish") {
if (isDefaultBranch())
dependsOn("incrementPatch", "build", "publish")
else
dependsOn("build", "publishToMavenLocal")
}
defaultTasks("clean", "pluginPublish")