Skip to content

Commit

Permalink
Fix CopySpec usages and CC issues in ShadowApplicationPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Nov 14, 2024
1 parent 6dca3b1 commit a58ad6f
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class ShadowApplicationPlugin : Plugin<Project> {

private fun configureInstallTask() {
project.tasks.named(SHADOW_INSTALL_TASK_NAME, Sync::class.java).configure { task ->
val applicationName = project.providers.provider { javaApplication.applicationName }

task.doFirst {
if (
!task.destinationDir.listFiles().isNullOrEmpty() && (
Expand All @@ -88,15 +90,16 @@ public class ShadowApplicationPlugin : Plugin<Project> {
)
) {
throw GradleException(
"The specified installation directory '${task.destinationDir}' is neither empty nor does it contain an installation for '${javaApplication.applicationName}'.\n" +
"The specified installation directory '${task.destinationDir}' is neither empty nor does it contain an installation for '${applicationName.get()}'.\n" +
"If you really want to install to this directory, delete it and run the install task again.\n" +
"Alternatively, choose a different installation directory.",
)
}
}
task.doLast {
val applicationName = applicationName.get()
task.eachFile {
if (it.path == "bin/${javaApplication.applicationName}") {
if (it.path == "bin/${applicationName}") {
it.mode = 0x755
}
}
Expand All @@ -107,15 +110,15 @@ public class ShadowApplicationPlugin : Plugin<Project> {
private fun configureDistSpec() {
project.extensions.getByType(DistributionContainer::class.java)
.create(ShadowBasePlugin.DISTRIBUTION_NAME) { distributions ->
with(distributions.contents) {
from(project.file("src/dist"))
into("lib") {
from(shadowJar)
from(project.configurations.named(ShadowBasePlugin.CONFIGURATION_NAME))
distributions.contents { contents ->
contents.from(project.file("src/dist"))
contents.into("lib") { lib ->
lib.from(shadowJar)
lib.from(project.configurations.named(ShadowBasePlugin.CONFIGURATION_NAME))
}
into("bin") {
from(project.tasks.named(SHADOW_SCRIPTS_TASK_NAME))
filePermissions { it.unix(493) }
contents.into("bin") { bin ->
bin.from(project.tasks.named(SHADOW_SCRIPTS_TASK_NAME))
bin.filePermissions { it.unix(493) }
}
}
}
Expand Down

0 comments on commit a58ad6f

Please sign in to comment.