Skip to content

Commit

Permalink
Fix wrong file order in distribution *.jar (MANIFEST.MF must come fir…
Browse files Browse the repository at this point in the history
…st!)
  • Loading branch information
floscher committed Jun 2, 2022
1 parent 7fa37db commit 5212794
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.AbstractArchiveTask
import org.gradle.api.tasks.bundling.Zip
import java.util.jar.JarInputStream
import javax.inject.Inject

/**
Expand Down Expand Up @@ -49,8 +50,11 @@ public open class RenameArchiveFile @Inject constructor(

init {
from(
archiverTask.map { project.zipTree(it.archiveFile).matching { it.exclude(GenerateJarManifest.MANIFEST_PATH) } },
manifestTask.map { project.fileTree(it.outputDirectory) { it.include(GenerateJarManifest.MANIFEST_PATH) } }
/* It is very important that the MANIFEST.MF file comes first!
* Otherwise it can't be read by a [JarInputStream]. See https://github.com/floscher/gradle-josm-plugin/pull/15
*/
manifestTask.map { project.fileTree(it.outputDirectory) { it.include(GenerateJarManifest.MANIFEST_PATH) } },
archiverTask.map { project.zipTree(it.archiveFile).matching { it.exclude(GenerateJarManifest.MANIFEST_PATH) } }
)
destinationDirectory.set(targetDir)
duplicatesStrategy = DuplicatesStrategy.FAIL
Expand Down

0 comments on commit 5212794

Please sign in to comment.