-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle.kts
187 lines (169 loc) · 5.92 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
184
185
186
187
import com.install4j.gradle.Install4jTask
import de.griefed.common.gradle.LicenseAgreementRenderer
import de.griefed.common.gradle.SubprojectLicenseFilter
import org.cyclonedx.model.AttachmentText
import org.cyclonedx.model.License
import org.cyclonedx.model.OrganizationalContact
import org.gradle.internal.os.OperatingSystem
import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
import java.time.LocalDate
plugins {
idea
kotlin("jvm")
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.github.jk1.dependency-license-report")
id("com.install4j.gradle")
id("org.cyclonedx.bom") version "1.10.0"
}
idea {
project {
languageLevel = IdeaLanguageLevel(21)
modules.forEach {
it.isDownloadJavadoc = true
it.isDownloadSources = true
it.languageLevel = IdeaLanguageLevel(21)
}
}
}
allprojects {
repositories {
gradlePluginPortal()
google()
mavenCentral()
maven("https://jitpack.io")
}
tasks.withType<Test> {
jvmArgs("-XX:+EnableDynamicAgentLoading", "-Djdk.attach.allowAttachSelf=true")
}
}
evaluationDependsOnChildren()
project("serverpackcreator-app").tasks.build.get().mustRunAfter(
tasks.getByName("generateLicenseReport"),
project("serverpackcreator-web-frontend").tasks.build.get()
)
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("OSSRH_USERNAME"))
password.set(System.getenv("OSSRH_PASSWORD"))
}
}
}
tasks.cyclonedxBom {
setIncludeConfigs(listOf("runtimeClasspath"))
setSkipConfigs(listOf("compileClasspath", "testCompileClasspath"))
setProjectType("application")
setSchemaVersion("1.5")
setDestination(project.file("build/reports"))
setOutputName("bom")
//setOutputFormat("json")
setIncludeBomSerialNumber(true)
val organizationalContact = OrganizationalContact()
organizationalContact.name = "Griefed"
organizationalContact.email = "[email protected]"
setOrganizationalEntity { oe ->
oe.name = "Griefed"
oe.urls = listOf("griefed.de")
oe.addContact(organizationalContact)
}
val attachementText = AttachmentText()
attachementText.text = File(projectDir,"LICENSE").readText()
val license = License()
license.name = "LGPL-2.1"
license.setLicenseText(attachementText)
license.url = "https:github.com/Griefed/ServerPackCreator/blob/main/LICENSE"
setLicenseChoice { lc ->
lc.addLicense(license)
}
}
licenseReport {
outputDir = "$projectDir/licenses"
configurations = arrayOf("runtimeClasspath", "compileClasspath")
filters = arrayOf(
com.github.jk1.license.filter.LicenseBundleNormalizer(),
SubprojectLicenseFilter()
)
renderers = arrayOf(
com.github.jk1.license.render.InventoryHtmlReportRenderer("index.html", "Dependency Licences"),
com.github.jk1.license.render.InventoryMarkdownReportRenderer("licences.md", "Dependency Licenses"),
LicenseAgreementRenderer("LICENSE-AGREEMENT"),
LicenseAgreementRenderer("LICENSE-AGREEMENT.txt")
)
}
val appPlugins = File("serverpackcreator-app/tests/plugins")
val apiPlugins = File("serverpackcreator-api/src/test/resources/testresources/plugins")
val kotlinPlugin = project.childProjects["serverpackcreator-plugin-example"]?.tasks?.jar?.get()?.archiveFile?.get()?.asFile?.toPath()
tasks.register<Delete>("cleanAppPlugins") {
delete(
fileTree(appPlugins) {
include("**/*.jar")
}
)
}
tasks.register<Copy>("copyExamplePluginsToApp") {
dependsOn(
"cleanAppPlugins",
":serverpackcreator-plugin-example:build"
)
appPlugins.mkdirs()
from(kotlinPlugin!!)
into(appPlugins)
}
tasks.register<Delete>("cleanApiUnitTestPlugins") {
delete(
fileTree(apiPlugins) {
include("**/*.jar")
}
)
}
tasks.register<Copy>("copyPluginsApiUnitTests") {
dependsOn(
"cleanApiUnitTestPlugins",
":serverpackcreator-plugin-example:build"
)
from(kotlinPlugin!!)
into(apiPlugins)
}
tasks.register<Delete>("cleanLicenseReport") {
delete(projectDir.resolve("serverpackcreator-app/src/main/resources/de/griefed/resources/gui/LICENSE-AGREEMENT"))
}
tasks.register<Copy>("copyLicenseReport") {
from(rootDir.resolve("licenses/LICENSE-AGREEMENT"))
into(rootDir.resolve("serverpackcreator-app/src/main/resources/de/griefed/resources/gui"))
}
tasks.generateLicenseReport {
mustRunAfter(tasks.getByName("cleanLicenseReport"))
finalizedBy(tasks.getByName("copyLicenseReport"))
}
install4j {
//Set the install4jHomeDir-property for building on your own machine, or use the paths listed below according
//to your operating system family.
installDir = if (properties["install4jHomeDir"].toString().isNotBlank()) {
file(properties["install4jHomeDir"].toString())
} else if (OperatingSystem.current().isWindows) {
file("C:\\Program Files\\install4j")
} else if (OperatingSystem.current().isMacOsX) {
//Ensure your install4j installation is available under this location
file("/Applications/install4j.app")
} else if (OperatingSystem.current().isLinux) {
//Ensure your install4j installation is available under this location
file("/opt/install4j")
} else {
file(properties["install4jHomeDir"].toString())
}
verbose = true
}
tasks.register<Install4jTask>("media") {
dependsOn(tasks.build)
verbose = true
release = version.toString()
projectFile = file("spc.install4j")
variables.putAll(
mutableMapOf(
"projectDir" to rootDir.absolutePath,
"projectVersion" to version.toString(),
"projectYear" to LocalDate.now().year.toString()
))
}