@@ -12,7 +12,10 @@ import org.gradle.api.Action
12
12
import org.gradle.api.GradleException
13
13
import org.gradle.api.Plugin
14
14
import org.gradle.api.Project
15
+ import org.gradle.api.distribution.Distribution
16
+ import org.gradle.api.file.CopySpec
15
17
import org.gradle.api.plugins.ApplicationPlugin
18
+ import org.gradle.api.provider.Provider
16
19
import org.gradle.api.tasks.JavaExec
17
20
import org.gradle.api.tasks.Sync
18
21
import org.gradle.api.tasks.TaskContainer
@@ -87,21 +90,13 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
87
90
}
88
91
89
92
protected open fun Project.configureDistribution () {
90
- distributions.register(DISTRIBUTION_NAME ) {
91
- it.contents { shadowDist ->
92
- shadowDist.from(file(" src/dist" ))
93
- shadowDist.into(" lib" ) { lib ->
94
- lib.from(tasks.shadowJar)
95
- // Reflects the value of the `Class-Path` attribute in the JAR manifest.
96
- lib.from(configurations.shadow)
97
- }
98
- // Defaults to bin dir.
99
- shadowDist.into(applicationExtension.executableDir) { bin ->
100
- bin.from(tasks.startShadowScripts)
101
- bin.filePermissions { permissions -> permissions.unix(UNIX_SCRIPT_PERMISSIONS ) }
102
- }
103
- shadowDist.with (applicationExtension.applicationDistribution)
93
+ registerShadowDistributionCommon { dist ->
94
+ // Defaults to bin dir.
95
+ dist.into(applicationExtension.executableDir) { bin ->
96
+ bin.from(tasks.startShadowScripts)
97
+ bin.filePermissions { permissions -> permissions.unix(UNIX_SCRIPT_PERMISSIONS ) }
104
98
}
99
+ dist.with (applicationExtension.applicationDistribution)
105
100
}
106
101
}
107
102
@@ -115,7 +110,7 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
115
110
/* *
116
111
* Reflects the number of 755.
117
112
*/
118
- private const val UNIX_SCRIPT_PERMISSIONS = " rwxr-xr-x"
113
+ internal const val UNIX_SCRIPT_PERMISSIONS = " rwxr-xr-x"
119
114
120
115
public const val DISTRIBUTION_NAME : String = SHADOW
121
116
@@ -152,5 +147,21 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
152
147
action.execute(task)
153
148
}
154
149
}
150
+
151
+ internal fun Project.registerShadowDistributionCommon (
152
+ action : Action <CopySpec >,
153
+ ): Provider <Distribution > {
154
+ return distributions.register(DISTRIBUTION_NAME ) {
155
+ it.contents { shadowDist ->
156
+ shadowDist.from(file(" src/dist" ))
157
+ shadowDist.into(" lib" ) { lib ->
158
+ lib.from(tasks.shadowJar)
159
+ // Reflects the value of the `Class-Path` attribute in the JAR manifest.
160
+ lib.from(configurations.shadow)
161
+ }
162
+ action.execute(shadowDist)
163
+ }
164
+ }
165
+ }
155
166
}
156
167
}
0 commit comments