@@ -12,7 +12,9 @@ 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
15
16
import org.gradle.api.plugins.ApplicationPlugin
17
+ import org.gradle.api.provider.Provider
16
18
import org.gradle.api.tasks.JavaExec
17
19
import org.gradle.api.tasks.Sync
18
20
import org.gradle.api.tasks.TaskContainer
@@ -87,7 +89,7 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
87
89
}
88
90
89
91
protected open fun Project.configureDistribution () {
90
- distributions.register( DISTRIBUTION_NAME ) { dist ->
92
+ registerShadowDistributionCommon { dist ->
91
93
dist.distributionBaseName.convention(
92
94
provider {
93
95
// distributionBaseName defaults to `$project.name-$distribution.name`, applicationName defaults to project.name
@@ -96,12 +98,6 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
96
98
},
97
99
)
98
100
dist.contents { distSpec ->
99
- distSpec.from(file(" src/dist" ))
100
- distSpec.into(" lib" ) { lib ->
101
- lib.from(tasks.shadowJar)
102
- // Reflects the value of the `Class-Path` attribute in the JAR manifest.
103
- lib.from(configurations.shadow)
104
- }
105
101
// Defaults to bin dir.
106
102
distSpec.into(provider(applicationExtension::getExecutableDir)) { bin ->
107
103
bin.from(tasks.startShadowScripts)
@@ -122,7 +118,7 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
122
118
/* *
123
119
* Reflects the number of 755.
124
120
*/
125
- private const val UNIX_SCRIPT_PERMISSIONS = " rwxr-xr-x"
121
+ internal const val UNIX_SCRIPT_PERMISSIONS = " rwxr-xr-x"
126
122
127
123
public const val DISTRIBUTION_NAME : String = SHADOW
128
124
@@ -159,5 +155,21 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
159
155
action.execute(task)
160
156
}
161
157
}
158
+
159
+ internal fun Project.registerShadowDistributionCommon (
160
+ action : Action <Distribution >,
161
+ ): Provider <Distribution > {
162
+ return distributions.register(DISTRIBUTION_NAME ) { dist ->
163
+ dist.contents { distSpec ->
164
+ distSpec.from(file(" src/dist" ))
165
+ distSpec.into(" lib" ) { lib ->
166
+ lib.from(tasks.shadowJar)
167
+ // Reflects the value of the `Class-Path` attribute in the JAR manifest.
168
+ lib.from(configurations.shadow)
169
+ }
170
+ }
171
+ action.execute(dist)
172
+ }
173
+ }
162
174
}
163
175
}
0 commit comments