1- plugins {
2- id(" groovy" )
3- id(" gradlexbuild.lifecycle" )
4- id(" gradlexbuild.asciidoctor-conventions" )
5- id(" org.gradlex.internal.plugin-publish-conventions" ) version " 0.6"
6- }
1+ import java.net.URLClassLoader
2+ import org.asciidoctor.gradle.base.AsciidoctorAttributeProvider
73
8- group = " org.gradlex"
94version = " 2.4"
105
11- java {
12- toolchain.languageVersion = JavaLanguageVersion .of(17 )
13- }
14-
15- tasks.withType<JavaCompile >().configureEach {
16- options.release = 8
17- }
18-
19- tasks.withType<Javadoc >().configureEach {
20- options {
21- this as StandardJavadocDocletOptions
22- encoding = " UTF-8"
23- addStringOption(" Xdoclint:all,-missing" , " -quiet" )
24- addStringOption(" Xwerror" , " -quiet" )
25- }
26- }
27-
28- val tagsList = listOf (
29- " dependency" , " dependencies" , " dependency-management" , " capabilities" , " java" , " logging" ,
30- " asm" , " bouncycastle" , " cglib" , " commons-io" , " dom4j" , " guava" , " hamcrest" , " javax" , " jakarta" , " junit" ,
31- " mysql" , " postgresql" , " stax" , " slf4j" , " log4j2" , " velocity" , " woodstox"
32- )
33-
346pluginPublishConventions {
357 id(" org.gradlex.jvm-dependency-conflict-resolution" )
368 implementationClass(" org.gradlex.jvm.dependency.conflict.resolution.JvmDependencyConflictResolutionPlugin" )
379 displayName(" JVM Conflict Resolution Gradle Plugin" )
3810 description(" Convenient dependency conflict management for Java projects." )
39- tags(* tagsList.toTypedArray())
11+
12+ additionalPlugin(" org.gradlex.jvm-dependency-conflict-detection" ) {
13+ implementationClass(" org.gradlex.jvm.dependency.conflict.detection.JvmDependencyConflictDetectionPlugin" )
14+ displayName(" JVM Conflict Detection Gradle Plugin" )
15+ description(" Adds Capabilities to well-known Components hosted on Maven Central." )
16+ }
17+
18+ tags(
19+ " dependency" ,
20+ " dependencies" ,
21+ " dependency-management" ,
22+ " capabilities" ,
23+ " java" ,
24+ " logging" ,
25+ " asm" ,
26+ " bouncycastle" ,
27+ " cglib" ,
28+ " commons-io" ,
29+ " dom4j" ,
30+ " guava" ,
31+ " hamcrest" ,
32+ " javax" ,
33+ " jakarta" ,
34+ " junit" ,
35+ " mysql" ,
36+ " postgresql" ,
37+ " stax" ,
38+ " slf4j" ,
39+ " log4j2" ,
40+ " velocity" ,
41+ " woodstox" ,
42+ )
4043 gitHub(" https://github.com/gradlex-org/jvm-dependency-conflict-resolution" )
4144 website(" https://github.com/gradlex-org/jvm-dependency-conflict-resolution" )
4245 developer {
@@ -56,46 +59,60 @@ pluginPublishConventions {
5659 }
5760}
5861
59- gradlePlugin {
60- plugins {
61- create(" jvm-dependency-conflict-detection" ) {
62- id = " org.gradlex.jvm-dependency-conflict-detection"
63- implementationClass = " org.gradlex.jvm.dependency.conflict.detection.JvmDependencyConflictDetectionPlugin"
64- displayName = " JVM Conflict Detection Gradle Plugin"
65- description = " Adds Capabilities to well-known Components hosted on Maven Central."
66- tags = tagsList
67- }
62+ testingConventions { testGradleVersions(" 6.8.3" , " 6.9.4" , " 7.0.2" , " 8.0.2" , " 8.14.3" ) }
63+
64+ val generateCapabilitiesList =
65+ tasks.register<CapabilityListing >(" generateCapabilitiesList" ) {
66+ pluginClasses.from(tasks.jar)
67+ outputFile = layout.buildDirectory.file(" generated/docs/asciidoc/parts/capabilities-listing.adoc" )
6868 }
69- }
7069
71- dependencies {
72- testImplementation(" org.gradle.exemplar:samples-check:1.0.3" )
73- testImplementation(" org.spockframework:spock-core:2.3-groovy-4.0" )
74- testRuntimeOnly(" org.junit.vintage:junit-vintage-engine" )
70+ tasks.asciidoctor {
71+ dependsOn(generateCapabilitiesList)
72+ attributeProviders + = AsciidoctorAttributeProvider {
73+ mapOf (" capabilities-listing" to generateCapabilitiesList.get().outputFile.get().asFile.absolutePath)
74+ }
7575}
7676
77- testing.suites.named<JvmTestSuite >(" test" ) {
78- useJUnitJupiter()
79- listOf (" 6.8.3" , " 6.9.4" , " 7.0.2" , " 8.0.2" , " 8.14.3" ).forEach { gradleVersionUnderTest ->
80- targets.register(" test${gradleVersionUnderTest} " ) {
81- testTask {
82- group = LifecycleBasePlugin .VERIFICATION_GROUP
83- description = " Runs tests against Gradle $gradleVersionUnderTest "
84- useJUnitPlatform {
85- excludeTags(" no-cross-version" )
77+ abstract class CapabilityListing : DefaultTask () {
78+
79+ @get:OutputFile abstract val outputFile: RegularFileProperty
80+
81+ @get:Classpath abstract val pluginClasses: ConfigurableFileCollection
82+
83+ @TaskAction
84+ fun update () {
85+ val classesUrls = pluginClasses.files.map { it.toURI().toURL() }
86+ val loader =
87+ URLClassLoader (" pluginClasspath" , classesUrls.toTypedArray(), ComponentMetadataRule ::class .java.classLoader)
88+ val definitions = loader.loadClass(" org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefinition" )
89+
90+ val allCapabilities =
91+ definitions.enumConstants
92+ .map { rule ->
93+ val capability = definitions.getDeclaredMethod(" getCapability" ).invoke(rule) as String
94+ val modules = definitions.getDeclaredMethod(" getModules" ).invoke(rule) as List <* >
95+
96+ Pair (capability, modules)
8697 }
87- systemProperty( " gradleVersionUnderTest " , gradleVersionUnderTest)
98+ .sortedBy { it.first }
8899
89- exclude(" **/*SamplesTest.class" ) // Not yet cross-version ready
100+ val capabilityList =
101+ allCapabilities.joinToString(" " ) { c ->
102+ " * ${c.first} \n ${c.second.joinToString(" " ) { " ** ${(it as String ).asRepoLink()} \n " }} "
90103 }
104+
105+ outputFile.get().asFile.also {
106+ it.parentFile.mkdirs()
107+ it.writeText(capabilityList)
91108 }
92109 }
93- targets.all {
94- testTask {
95- maxParallelForks = 4
96- inputs.dir(layout.projectDirectory.dir(" samples" ))
97- inputs.dir(" src/docs/samples" )
98- }
99- }
110+
111+ private fun String.asRepoLink () = " https://search.maven.org/artifact/${replace(" :" , " /" )} [$this ]"
100112}
101113
114+ // === the following custom configuration should be removed once tests are migrated to Java
115+ apply (plugin = " groovy" )
116+
117+ dependencies { testImplementation(" org.spockframework:spock-core:2.3-groovy-4.0" ) } //
118+ // ====================================================================================
0 commit comments