Skip to content

Commit 7461dff

Browse files
committed
Tweaks
Took 50 minutes
1 parent 1f1399a commit 7461dff

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

build.gradle.kts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2-
import org.gradle.initialization.Environment.Properties
32

43
//The project's information.
54
group = "net.cameronbowe" //The project's group.
@@ -11,6 +10,7 @@ plugins {
1110
id("java") //Add the java plugin (for java development).
1211
id("signing") //Add the signing plugin (for signing to publish to maven).
1312
id("maven-publish") //Add the maven publish plugin (for publishing to maven).
13+
id("com.github.breadmoirai.github-release").version("2.5.2") //Add the github release plugin (for releasing to github).
1414
id("com.github.johnrengelman.shadow").version("7.1.2") //Add shadow (for shading dependencies).
1515
}
1616

@@ -29,15 +29,37 @@ dependencies {
2929
//The tasks.
3030
tasks {
3131

32+
//The moving of old files task.
33+
task("moveOldFiles", type = Copy::class) {
34+
val versionRegex = Regex("""${project.version}""") //The version regex.
35+
duplicatesStrategy = DuplicatesStrategy.INCLUDE //Include duplicates.
36+
val oldFiles = fileTree("build/libs") { include { fileTreeElement -> !fileTreeElement.isDirectory && !versionRegex.containsMatchIn(fileTreeElement.name) } } //Get the old files.
37+
if (oldFiles.isEmpty) return@task //If there are no old files, return.
38+
from(oldFiles) //From the old files.
39+
into("build/libs/other") //Into the other libs folder.
40+
doLast { delete(oldFiles) } //Delete the old files.
41+
}
42+
43+
//The publishing task.
44+
task("publishEverything") {
45+
println("Publishing everything...")
46+
dependsOn("publish", "githubRelease") //Depend on publishing and github release (to publish everything).
47+
println("Publishing everything!")
48+
}
49+
3250
//The without dependencies jar creation task.
3351
task("withoutDepends", type = Jar::class) {
52+
dependsOn("moveOldFiles") //Depend on moving old files.
53+
delete("${project.name}-${project.version}-without-depends.jar") //Delete the old jar (if it exists).
3454
from(sourceSets.main.get().allSource) //Add the main sources.
3555
archiveClassifier.set("withoutDepends") //Set the classifier.
3656
archiveFileName.set("${project.name}-${project.version}-without-depends.jar") //Set the file name.
3757
}
3858

3959
//The with dependencies jar creation task.
4060
task("withDepends", type = ShadowJar::class) {
61+
dependsOn("moveOldFiles") //Depend on moving old files.
62+
delete("${project.name}-${project.version}-with-depends.jar") //Delete the old jar (if it exists).
4163
from(sourceSets.main.get().allSource) //Add the main sources.
4264
archiveClassifier.set("withDepends") //Set the classifier.
4365
configurations = listOf(project.configurations.runtimeClasspath.get()) //Set the configurations.
@@ -49,6 +71,22 @@ tasks {
4971

5072
}
5173

74+
//The github release.
75+
githubRelease {
76+
token(findProperty("githubToken") as String?) //Set the token.
77+
releaseName = "${project.version}" //Set the release name.
78+
tagName = "${project.version}" //Set the tag name.
79+
targetCommitish = "master" //Set the target commitish.
80+
body = "The release of version ${project.version}." //Set the body.
81+
releaseAssets.setFrom(tasks["withDepends"], tasks["withoutDepends"]) //Set the release assets.
82+
generateReleaseNotes.set(false) //Don't generate release notes.
83+
allowUploadToExisting.set(true) //Allow upload to existing.
84+
dryRun.set(false) //Don't dry run.
85+
overwrite.set(true) //Allow overwrite.
86+
draft.set(false) //Don't make the release a draft.
87+
88+
}
89+
5290
//The publishing to my software repository.
5391
publishing {
5492

0 commit comments

Comments
 (0)