-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
146 lines (131 loc) · 4.83 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
146 lines (131 loc) · 4.83 KB
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
plugins {
`kotlin-dsl`
`maven-publish`
`java-gradle-plugin`
kotlin("jvm") version "1.9.24" // Do not update
kotlin("plugin.serialization") version "1.9.24" // Do not update
id("com.gradle.plugin-publish") version "1.3.1"
id("org.jetbrains.dokka") version "1.9.20" // Do not update because of kotlin("jvm") version
}
// Get version
version =
System.getenv("GITHUB_REF_NAME")
?.takeIf { System.getenv("GITHUB_REF_TYPE") == "tag" }
?: System.getenv("GITHUB_SHA")
?.takeIf { it.isNotBlank() }
?.take(7)
?: "dev"
group = "xyz.srnyx"
description = "A Gradle plugin to simplify the process of creating projects"
val projectId: String = "gradle-galaxy"
val vcs: String = "github.com/srnyx/$projectId"
val includeJavadocsSources: Boolean = true
val javaVersion = 17
repositories {
maven("https://repo.srnyx.com/snapshots/")
mavenCentral()
gradlePluginPortal()
}
dependencies {
implementation(gradleApi())
implementation(kotlin("stdlib-jdk8"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.11.0")
// Plugins
compileOnly("com.gradleup.shadow:shadow-gradle-plugin:9.0.0")
compileOnly("me.modmuss50.mod-publish-plugin:me.modmuss50.mod-publish-plugin.gradle.plugin:675051c")
compileOnly("io.papermc.hangar-publish-plugin:io.papermc.hangar-publish-plugin.gradle.plugin:0.1.4")
compileOnly("xyz.jpenilla.run-paper:xyz.jpenilla.run-paper.gradle.plugin:3.0.2")
}
// Set Kotlin JVM version
kotlin.jvmToolchain(javaVersion)
// Set Java version, text encoding, & docs/sources jar task dependencies
tasks.withType<JavaCompile> {
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
options.encoding = "UTF-8"
}
// Add docs and sources jars
if (includeJavadocsSources) {
tasks.register("javadocJar", Jar::class) {
group = "build"
description = "Assembles a jar archive containing the javadoc files"
val dokkaTask = tasks.getByName("dokkaHtml")
dependsOn(dokkaTask)
from(dokkaTask)
archiveClassifier.set("javadoc")
}
tasks.register("sourcesJar", Jar::class) {
group = "build"
description = "Assembles a jar archive containing the sources"
from(sourceSets["main"].allSource.srcDirs)
archiveClassifier.set("sources")
}
}
gradlePlugin {
isAutomatedPublishing = true
website.set("https://${vcs}")
vcsUrl.set("https://${vcs}")
plugins.create(projectId) {
id = "${project.group}.$projectId"
implementationClass = "${project.group}.gradlegalaxy.GradleGalaxy"
displayName = project.name
description = project.description
tags.set(listOf("srnyx", "minecraft", "spigot", "paper", "adventure", "jda"))
}
}
// Custom/additional repository
providers.environmentVariable("MAVEN_URL")
.orNull
?.takeIf(String::isNotBlank)
?.let { mavenUrl -> publishing {
publications.create<MavenPublication>("pluginMaven") {
artifactId = projectId
pom {
name.set(project.name)
description.set(project.description)
url.set("https://${vcs}")
packaging = "jar"
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("srnyx")
url.set("https://srnyx.com")
email.set("contact@srnyx.com")
timezone.set("America/New_York")
organization.set("Venox Network")
organizationUrl.set("https://venox.network")
}
developer {
id.set("dkim19375")
timezone.set("America/New_York")
roles.add("contributor")
}
}
scm {
connection.set("scm:git:git://${vcs}.git")
developerConnection.set("scm:git:ssh://${vcs}.git")
url.set("https://${vcs}")
}
}
}
repositories.maven {
name = "srnyx"
url = uri(mavenUrl)
// Username/password
val mavenName = providers.environmentVariable("MAVEN_NAME")
.orNull
?.takeIf(String::isNotBlank)
val mavenSecret = providers.environmentVariable("MAVEN_SECRET")
.orNull
?.takeIf(String::isNotBlank)
if (mavenName != null && mavenSecret != null) credentials {
username = mavenName
password = mavenSecret
}
}
} }