Added and tested safeManifest.

master Version_3.15
Robinson 2023-04-24 12:53:27 +02:00
parent 3f2debce43
commit d3fcd574a2
No known key found for this signature in database
GPG Key ID: 8E7DB78588BD6F5C
2 changed files with 26 additions and 1 deletions

View File

@ -34,7 +34,7 @@ object Extras {
// set for the project
const val description = "Gradle Plugin to manage various Gradle tasks, such as updating gradle and dependencies"
const val group = "com.dorkbox"
const val version = "3.14.1"
const val version = "3.15"
// set as project.ext
const val name = "Gradle Utils"

View File

@ -18,6 +18,7 @@ package dorkbox.gradle
import dorkbox.gradle.deps.GetVersionInfoTask
import org.gradle.api.*
import org.gradle.api.file.SourceDirectorySet
import org.gradle.jvm.tasks.Jar
import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import java.io.*
@ -181,3 +182,27 @@ fun JarFile.addFilesToJar(filesToAdd: List<Pair<File, String>>) {
}
}
}
/**
* Make sure that the creation of manifests happens AFTER task configuration, but before task execution.
*
* There are dependency issues if the manifest is configured during task configuration.
*
* These are NOT lambda's because of issues with gradle.
*/
fun org.gradle.jvm.tasks.Jar.safeManifest(action: Action<in org.gradle.api.java.archives.Manifest>) {
val task = this
task.doFirst(object: Action<Task> {
override fun execute(task: Task) {
task as Jar
task.manifest(object : Action<org.gradle.api.java.archives.Manifest> {
override fun execute(t: org.gradle.api.java.archives.Manifest) {
action.execute(t)
}
})
}
})
}