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+ tags(
12+ " dependency" ,
13+ " dependencies" ,
14+ " dependency-management" ,
15+ " capabilities" ,
16+ " java" ,
17+ " logging" ,
18+ " asm" ,
19+ " bouncycastle" ,
20+ " cglib" ,
21+ " commons-io" ,
22+ " dom4j" ,
23+ " guava" ,
24+ " hamcrest" ,
25+ " javax" ,
26+ " jakarta" ,
27+ " junit" ,
28+ " mysql" ,
29+ " postgresql" ,
30+ " stax" ,
31+ " slf4j" ,
32+ " log4j2" ,
33+ " velocity" ,
34+ " woodstox" ,
35+ )
4036 gitHub(" https://github.com/gradlex-org/jvm-dependency-conflict-resolution" )
4137 website(" https://github.com/gradlex-org/jvm-dependency-conflict-resolution" )
4238 developer {
@@ -58,44 +54,70 @@ pluginPublishConventions {
5854
5955gradlePlugin {
6056 plugins {
61- create (" jvm-dependency-conflict-detection" ) {
57+ register (" jvm-dependency-conflict-detection" ) {
6258 id = " org.gradlex.jvm-dependency-conflict-detection"
6359 implementationClass = " org.gradlex.jvm.dependency.conflict.detection.JvmDependencyConflictDetectionPlugin"
6460 displayName = " JVM Conflict Detection Gradle Plugin"
6561 description = " Adds Capabilities to well-known Components hosted on Maven Central."
66- tags = tagsList
62+ // tags = tagsList TODO
6763 }
6864 }
6965}
7066
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" )
67+ testingConventions { testGradleVersions(" 6.8.3" , " 6.9.4" , " 7.0.2" , " 8.0.2" , " 8.14.3" ) }
68+
69+ val generateCapabilitiesList =
70+ tasks.register<CapabilityListing >(" generateCapabilitiesList" ) {
71+ pluginClasses.from(tasks.jar)
72+ outputFile = layout.buildDirectory.file(" generated/docs/asciidoc/parts/capabilities-listing.adoc" )
73+ }
74+
75+ tasks.asciidoctor {
76+ dependsOn(generateCapabilitiesList)
77+ attributeProviders + = AsciidoctorAttributeProvider {
78+ mapOf (" capabilities-listing" to generateCapabilitiesList.get().outputFile.get().asFile.absolutePath)
79+ }
7580}
7681
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" )
82+ abstract class CapabilityListing : DefaultTask () {
83+
84+ @get:OutputFile abstract val outputFile: RegularFileProperty
85+
86+ @get:Classpath abstract val pluginClasses: ConfigurableFileCollection
87+
88+ @TaskAction
89+ fun update () {
90+ val classesUrls = pluginClasses.files.map { it.toURI().toURL() }
91+ val loader =
92+ URLClassLoader (" pluginClasspath" , classesUrls.toTypedArray(), ComponentMetadataRule ::class .java.classLoader)
93+ val definitions = loader.loadClass(" org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefinition" )
94+
95+ val allCapabilities =
96+ definitions.enumConstants
97+ .map { rule ->
98+ val capability = definitions.getDeclaredMethod(" getCapability" ).invoke(rule) as String
99+ val modules = definitions.getDeclaredMethod(" getModules" ).invoke(rule) as List <* >
100+
101+ Pair (capability, modules)
86102 }
87- systemProperty( " gradleVersionUnderTest " , gradleVersionUnderTest)
103+ .sortedBy { it.first }
88104
89- exclude(" **/*SamplesTest.class" ) // Not yet cross-version ready
105+ val capabilityList =
106+ allCapabilities.joinToString(" " ) { c ->
107+ " * ${c.first} \n ${c.second.joinToString(" " ) { " ** ${(it as String ).asRepoLink()} \n " }} "
90108 }
109+
110+ outputFile.get().asFile.also {
111+ it.parentFile.mkdirs()
112+ it.writeText(capabilityList)
91113 }
92114 }
93- targets.all {
94- testTask {
95- maxParallelForks = 4
96- inputs.dir(layout.projectDirectory.dir(" samples" ))
97- inputs.dir(" src/docs/samples" )
98- }
99- }
115+
116+ private fun String.asRepoLink () = " https://search.maven.org/artifact/${replace(" :" , " /" )} [$this ]"
100117}
101118
119+ // === the following custom configuration should be removed once tests are migrated to Java
120+ apply (plugin = " groovy" )
121+
122+ dependencies { testImplementation(" org.spockframework:spock-core:2.3-groovy-4.0" ) } //
123+ // ====================================================================================
0 commit comments