File tree Expand file tree Collapse file tree 2 files changed +41
-13
lines changed
buildSrc/src/main/kotlin/org/junit/gradle/java
junit-platform-console-standalone Expand file tree Collapse file tree 2 files changed +41
-13
lines changed Original file line number Diff line number Diff line change
1
+ package org.junit.gradle.java
2
+
3
+ import org.gradle.api.DefaultTask
4
+ import org.gradle.api.artifacts.Configuration
5
+ import org.gradle.api.artifacts.ModuleVersionIdentifier
6
+ import org.gradle.api.artifacts.ResolvedArtifact
7
+ import org.gradle.api.file.RegularFileProperty
8
+ import org.gradle.api.provider.Property
9
+ import org.gradle.api.provider.Provider
10
+ import org.gradle.api.provider.SetProperty
11
+ import org.gradle.api.tasks.*
12
+
13
+ abstract class WriteArtifactsFile : DefaultTask () {
14
+
15
+ @get:OutputFile
16
+ abstract val outputFile: RegularFileProperty
17
+
18
+ @get:Input
19
+ abstract val moduleVersions: SetProperty <ModuleVersionIdentifier >
20
+
21
+ fun from (configuration : Provider <Configuration >) {
22
+ moduleVersions.addAll(configuration.map {
23
+ it.resolvedConfiguration.resolvedArtifacts.map { it.moduleVersion.id }
24
+ })
25
+ }
26
+
27
+ @TaskAction
28
+ fun writeFile () {
29
+ outputFile.get().asFile.printWriter().use { out ->
30
+ moduleVersions.get()
31
+ .map { " ${it.group} :${it.name} :${it.version} " }
32
+ .sorted()
33
+ .forEach(out ::println)
34
+ }
35
+ }
36
+ }
Original file line number Diff line number Diff line change
1
+ import org.junit.gradle.java.WriteArtifactsFile
2
+
1
3
plugins {
2
4
`java- library- conventions`
3
5
`shadow- conventions`
@@ -26,19 +28,9 @@ tasks {
26
28
attributes(" Main-Class" to " org.junit.platform.console.ConsoleLauncher" )
27
29
}
28
30
}
29
- val shadowedArtifactsFile by registering {
30
- inputs.files(configurations.shadowed).withNormalizer(ClasspathNormalizer ::class )
31
- val outputFile = layout.buildDirectory.file(" shadowed-artifacts" )
32
- outputs.file(outputFile)
33
- doFirst {
34
- outputFile.get().asFile.printWriter().use { out ->
35
- configurations.shadowed.get().resolvedConfiguration.resolvedArtifacts
36
- .map { it.moduleVersion.id }
37
- .map { " ${it.group} :${it.name} :${it.version} " }
38
- .sorted()
39
- .forEach(out ::println)
40
- }
41
- }
31
+ val shadowedArtifactsFile by registering(WriteArtifactsFile ::class ) {
32
+ from(configurations.shadowed)
33
+ outputFile.set(layout.buildDirectory.file(" shadowed-artifacts" ))
42
34
}
43
35
shadowJar {
44
36
// https://github.com/junit-team/junit5/issues/2557
You can’t perform that action at this time.
0 commit comments