File tree Expand file tree Collapse file tree 6 files changed +88
-0
lines changed
functionalTest/groovy/com/autonomousapps/jvm
main/kotlin/com/autonomousapps/internal/artifacts
testkit/gradle-testkit-support/src/main/kotlin/com/autonomousapps/kit/gradle Expand file tree Collapse file tree 6 files changed +88
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com.autonomousapps.jvm
2
+
3
+ import com.autonomousapps.jvm.projects.CategoryProject
4
+
5
+ import static com.autonomousapps.utils.Runner.build
6
+
7
+ // This passes on Gradle 8.6 and failed on Gradle 8.7 (pre-fix)
8
+ // https://github.com/autonomousapps/dependency-analysis-gradle-plugin/issues/1159
9
+ final class CategorySpec extends AbstractJvmSpec {
10
+
11
+ def "project bundles are respected (#gradleVersion )" () {
12
+ given:
13
+ def project = new CategoryProject()
14
+ gradleProject = project.gradleProject
15
+
16
+ expect:
17
+ build(gradleVersion, gradleProject.rootDir, 'testCodeCoverageReport')
18
+
19
+ where:
20
+ gradleVersion << gradleVersions()
21
+ }
22
+ }
Original file line number Diff line number Diff line change
1
+ package com.autonomousapps.jvm.projects
2
+
3
+ import com.autonomousapps.AbstractProject
4
+ import com.autonomousapps.kit.GradleProject
5
+ import com.autonomousapps.kit.gradle.Plugin
6
+
7
+ import static com.autonomousapps.kit.gradle.Dependency.project
8
+
9
+ final class CategoryProject extends AbstractProject {
10
+
11
+ final GradleProject gradleProject
12
+
13
+ CategoryProject () {
14
+ this . gradleProject = build()
15
+ }
16
+
17
+ private GradleProject build () {
18
+ return newGradleProjectBuilder()
19
+ .withRootProject { r ->
20
+ r. withBuildScript { bs ->
21
+ bs. plugins. addAll(Plugin . javaLibrary, Plugin . jacocoReportAggregation)
22
+ bs. withGroovy(
23
+ ''' \
24
+ tasks.named('test', Test) {
25
+ useJUnitPlatform()
26
+ }
27
+ '''
28
+ )
29
+ bs. dependencies(
30
+ project(' jacocoAggregation' , ' :project' ),
31
+ )
32
+ }
33
+ }
34
+ .withSubproject(' project' ) { p ->
35
+ p. withBuildScript { bs ->
36
+ bs. plugins = javaLibrary + Plugin . jvmTestSuite
37
+ bs. withGroovy(
38
+ ''' \
39
+ tasks.named('test', Test) {
40
+ useJUnitPlatform()
41
+ }
42
+ '''
43
+ )
44
+ }
45
+ }
46
+ .write()
47
+ }
48
+ }
Original file line number Diff line number Diff line change @@ -4,12 +4,20 @@ package com.autonomousapps.internal.artifacts
4
4
5
5
import org.gradle.api.Named
6
6
import org.gradle.api.attributes.Attribute
7
+ import org.gradle.api.attributes.Category
8
+ import org.gradle.api.model.ObjectFactory
7
9
8
10
internal interface DagpArtifacts : Named {
9
11
companion object {
10
12
@JvmField val DAGP_ARTIFACTS_ATTRIBUTE : Attribute <DagpArtifacts > = Attribute .of(
11
13
" dagp.internal.artifacts" , DagpArtifacts ::class .java
12
14
)
15
+
16
+ @JvmField val CATEGORY_ATTRIBUTE : Attribute <Category > = Category .CATEGORY_ATTRIBUTE
17
+
18
+ fun category (objects : ObjectFactory ): Category {
19
+ return objects.named(Category ::class .java, " dependency-analysis" )
20
+ }
13
21
}
14
22
15
23
enum class Kind (
Original file line number Diff line number Diff line change @@ -68,6 +68,10 @@ internal class Publisher<T : Named>(
68
68
attr.attribute,
69
69
project.objects.named(attr.attribute.type, attr.attributeName)
70
70
)
71
+ attribute(
72
+ DagpArtifacts .CATEGORY_ATTRIBUTE ,
73
+ DagpArtifacts .category(project.objects)
74
+ )
71
75
}
72
76
}
73
77
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ internal class Resolver<T : Named>(
66
66
attr.attribute,
67
67
project.objects.named(attr.attribute.type, attr.attributeName)
68
68
)
69
+ attribute(
70
+ DagpArtifacts .CATEGORY_ATTRIBUTE ,
71
+ DagpArtifacts .category(project.objects)
72
+ )
69
73
}
70
74
}
71
75
}
Original file line number Diff line number Diff line change @@ -59,10 +59,12 @@ public class Plugin @JvmOverloads constructor(
59
59
@JvmStatic public val application: Plugin = Plugin (" application" )
60
60
@JvmStatic public val groovy: Plugin = Plugin (" groovy" )
61
61
@JvmStatic public val groovyGradle: Plugin = Plugin (" groovy-gradle-plugin" )
62
+ @JvmStatic public val jacocoReportAggregation: Plugin = Plugin (" jacoco-report-aggregation" )
62
63
@JvmStatic public val java: Plugin = Plugin (" java" )
63
64
@JvmStatic public val javaGradle: Plugin = Plugin (" java-gradle-plugin" )
64
65
@JvmStatic public val javaLibrary: Plugin = Plugin (" java-library" )
65
66
@JvmStatic public val javaTestFixtures: Plugin = Plugin (" java-test-fixtures" )
67
+ @JvmStatic public val jvmTestSuite: Plugin = Plugin (" jvm-test-suite" )
66
68
@JvmStatic public val scala: Plugin = Plugin (" scala" )
67
69
@JvmStatic public val war: Plugin = Plugin (" war" )
68
70
}
You can’t perform that action at this time.
0 commit comments