1
+ import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
2
+ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
3
+
4
+ plugins {
5
+ `maven- publish`
6
+ id(" io.github.gradle-nexus.publish-plugin" ) version " 1.1.0"
7
+ id(" com.github.johnrengelman.shadow" ) version " 7.1.2"
8
+ id(" cl.franciscosolis.blossom-extended" ) version " 1.3.1"
9
+
10
+ kotlin(" jvm" ) version " 1.8.10"
11
+ id(" org.jetbrains.dokka" ) version " 1.7.20"
12
+ }
13
+
14
+ val env = project.rootProject.file(" .env" ).let { file ->
15
+ if (file.exists()) file.readLines().filter { it.isNotBlank() && ! it.startsWith(" #" ) && it.split(" =" ).size == 2 }.associate { it.split(" =" )[0 ] to it.split(" =" )[1 ] } else emptyMap()
16
+ }.toMutableMap().apply { putAll(System .getenv()) }
17
+
18
+ val projectVersion = env[" VERSION" ] ? : " 0.2.0-SNAPSHOT"
19
+
20
+ group = " xyz.theprogramsrc"
21
+ version = projectVersion
22
+ description = " File configurations and utils for the SimpleCore API"
23
+
24
+ repositories {
25
+ mavenLocal()
26
+ mavenCentral()
27
+
28
+ maven(" https://s01.oss.sonatype.org/content/groups/public/" )
29
+ maven(" https://oss.sonatype.org/content/groups/public/" )
30
+ maven(" https://hub.spigotmc.org/nexus/content/repositories/snapshots/" )
31
+ maven(" https://repo.codemc.org/repository/maven-public/" )
32
+ maven(" https://jitpack.io/" )
33
+ }
34
+
35
+ dependencies {
36
+ compileOnly(" xyz.theprogramsrc:simplecoreapi:0.6.2-SNAPSHOT" )
37
+
38
+ implementation(" me.carleslc.Simple-YAML:Simple-Yaml:1.8.3" )
39
+
40
+ testImplementation(" org.junit.jupiter:junit-jupiter:5.9.2" )
41
+ }
42
+
43
+
44
+ tasks {
45
+ named<ShadowJar >(" shadowJar" ) {
46
+ relocate(" org.simpleyaml" , " xyz.theprogramsrc.filesmodule.libs.simpleyaml" )
47
+ relocate(" org.yaml.snakeyaml" , " xyz.theprogramsrc.filesmodule.libs.snakeyaml" )
48
+
49
+ mergeServiceFiles()
50
+ exclude(" **/*.kotlin_metadata" )
51
+ exclude(" **/*.kotlin_builtins" )
52
+
53
+ archiveBaseName.set(" FilesModule" )
54
+ archiveClassifier.set(" " )
55
+ }
56
+
57
+ test {
58
+ useJUnitPlatform()
59
+ }
60
+
61
+ java {
62
+ sourceCompatibility = JavaVersion .VERSION_11
63
+ targetCompatibility = JavaVersion .VERSION_11
64
+ withSourcesJar()
65
+ withJavadocJar()
66
+ }
67
+
68
+ compileKotlin {
69
+ kotlinOptions {
70
+ jvmTarget = " 11"
71
+ }
72
+ }
73
+
74
+ compileTestKotlin {
75
+ kotlinOptions {
76
+ jvmTarget = " 11"
77
+ }
78
+ }
79
+
80
+ compileJava {
81
+ options.encoding = " UTF-8"
82
+ }
83
+
84
+ jar {
85
+ duplicatesStrategy = DuplicatesStrategy .EXCLUDE
86
+ }
87
+
88
+ copy {
89
+ duplicatesStrategy = DuplicatesStrategy .EXCLUDE
90
+ }
91
+
92
+ dokkaHtml {
93
+ outputDirectory.set(file(project.buildDir.absolutePath + " /dokka" ))
94
+ }
95
+ }
96
+
97
+ configurations {
98
+ testImplementation {
99
+ extendsFrom(configurations.compileOnly.get())
100
+ }
101
+ }
102
+
103
+ val dokkaJavadocJar by tasks.register<Jar >(" dokkaJavadocJar" ) {
104
+ dependsOn(tasks.dokkaJavadoc, tasks.dokkaHtml)
105
+ from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
106
+ archiveClassifier.set(" javadoc" )
107
+ }
108
+
109
+ publishing {
110
+ repositories {
111
+ if (env[" ENV" ] == " prod" ) {
112
+ if (env.containsKey(" GITHUB_ACTOR" ) && env.containsKey(" GITHUB_TOKEN" )) {
113
+ maven {
114
+ name = " GithubPackages"
115
+ url = uri(" https://maven.pkg.github.com/TheProgramSrc/SimpleCore-FilesModule" )
116
+ credentials {
117
+ username = env[" GITHUB_ACTOR" ]
118
+ password = env[" GITHUB_TOKEN" ]
119
+ }
120
+ }
121
+ }
122
+ } else {
123
+ mavenLocal()
124
+ }
125
+ }
126
+
127
+ publications {
128
+ create<MavenPublication >(" shadow" ) {
129
+ project.extensions.configure<ShadowExtension > {
130
+ artifactId = rootProject.name.lowercase()
131
+
132
+ component(this @create)
133
+ artifact(dokkaJavadocJar)
134
+ artifact(tasks.kotlinSourcesJar)
135
+
136
+ pom {
137
+ name.set(rootProject.name)
138
+ description.set(project.description)
139
+ url.set(" https://github.com/TheProgramSrc/SimpleCore-FilesModule" )
140
+
141
+ licenses {
142
+ license {
143
+ name.set(" GNU GPL v3" )
144
+ url.set(" https://github.com/TheProgramSrc/SimpleCore-FilesModule/blob/master/LICENSE" )
145
+ }
146
+ }
147
+
148
+ developers {
149
+ developer {
150
+ id.set(" ImFran" )
151
+ name.set(" Francisco Solis" )
152
+
153
+ }
154
+ }
155
+
156
+ scm {
157
+ url.set(" https://github.com/TheProgramSrc/SimpleCore-FilesModule" )
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+
165
+ nexusPublishing {
166
+ repositories {
167
+ sonatype {
168
+ nexusUrl.set(uri(" https://s01.oss.sonatype.org/service/local/" ))
169
+ snapshotRepositoryUrl.set(uri(" https://s01.oss.sonatype.org/content/repositories/snapshots/" ))
170
+
171
+ username.set(env[" SONATYPE_USERNAME" ])
172
+ password.set(env[" SONATYPE_PASSWORD" ])
173
+ }
174
+ }
175
+ }
176
+
177
+ tasks.withType<PublishToMavenRepository > {
178
+ dependsOn(tasks.test, tasks.kotlinSourcesJar, dokkaJavadocJar, tasks.jar, tasks.shadowJar)
179
+ }
180
+
181
+ tasks.withType<PublishToMavenLocal > {
182
+ dependsOn(tasks.test, tasks.kotlinSourcesJar, tasks.jar, dokkaJavadocJar, tasks.shadowJar)
183
+ }
0 commit comments